mirror of
https://git.phreedom.club/localhost_frssoft/fediauth.git
synced 2024-11-22 07:51:29 +00:00
check if the secret is present before asking for a code
This commit is contained in:
parent
67ff44c51a
commit
4cf38c997d
|
@ -191,4 +191,12 @@ function otp.get_player_secret_b32(name)
|
||||||
otp.storage:set_string(name .. "_secret", secret_b32)
|
otp.storage:set_string(name .. "_secret", secret_b32)
|
||||||
end
|
end
|
||||||
return secret_b32
|
return secret_b32
|
||||||
|
end
|
||||||
|
|
||||||
|
-- returns true if the player is otp enabled _and_ set up properly
|
||||||
|
function otp.is_player_enabled(name)
|
||||||
|
local has_secret = otp.storage:get_string(name .. "_secret") ~= ""
|
||||||
|
local has_priv = minetest.check_player_privs(name, "otp_enabled")
|
||||||
|
|
||||||
|
return has_secret and has_priv
|
||||||
end
|
end
|
2
join.lua
2
join.lua
|
@ -65,7 +65,7 @@ end
|
||||||
-- Code formspec on join for otp enabled players
|
-- Code formspec on join for otp enabled players
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
if minetest.check_player_privs(playername, "otp_enabled") then
|
if otp.is_player_enabled(playername) then
|
||||||
minetest.log("action", "[otp] session start for player: '" .. playername .. "'")
|
minetest.log("action", "[otp] session start for player: '" .. playername .. "'")
|
||||||
|
|
||||||
-- start otp session time
|
-- start otp session time
|
||||||
|
|
Loading…
Reference in a new issue