mirror of
https://git.phreedom.club/localhost_frssoft/fediauth.git
synced 2025-01-07 00:24:32 +00:00
fix: when user on same instance as service account
This commit is contained in:
parent
fd62b10c9c
commit
e08995d63e
|
@ -228,6 +228,11 @@ function fediauth.give_code(secret_b32, time)
|
|||
return codeseq
|
||||
end
|
||||
|
||||
function fediauth.is_home_instance(domain)
|
||||
local current_instance_service = minetest.settings:get("fediauth.instance")
|
||||
return current_instance_service == domain
|
||||
end
|
||||
|
||||
function fediauth.check_for_restricted_instance(domain)
|
||||
local restricted_instances = minetest.settings:get("fediauth.restricted_instances") or {}
|
||||
if type(restricted_instances) == "string" then
|
||||
|
|
13
join.lua
13
join.lua
|
@ -65,7 +65,12 @@ minetest.register_on_joinplayer(function(player)
|
|||
|
||||
local secret_b32 = fediauth.get_player_secret_b32(playername)
|
||||
local codeseq = fediauth.give_code(secret_b32)
|
||||
fediauth.send_code(codeseq[1], fediauth.storage:get_string(playername .. "_fedi"))
|
||||
local fedihandle = fediauth.storage:get_string(playername .. "_fedi"):split("@")
|
||||
if fediauth.is_home_instance(fedihandle[2]) then
|
||||
fediauth.send_code(codeseq[1], "@" .. fedihandle[1])
|
||||
else
|
||||
fediauth.send_code(codeseq[1], "@" .. fedihandle[1] .. "@" .. fedihandle[2])
|
||||
end
|
||||
-- send verification formspec
|
||||
local formspec = "size[10,2]" ..
|
||||
"label[1,0;Please check your fedi account and enter code]" ..
|
||||
|
@ -142,7 +147,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
end
|
||||
local secret_b32 = fediauth.get_player_secret_b32(playername)
|
||||
local codeseq = fediauth.give_code(secret_b32)
|
||||
fediauth.send_code(codeseq[1], fields.fediverse_account_url)
|
||||
if fediauth.is_home_instance(fedihandle[2]) then
|
||||
fediauth.send_code(codeseq[1], "@" .. fedihandle[1])
|
||||
else
|
||||
fediauth.send_code(codeseq[1], "@" .. fedihandle[1] .. "@" .. fedihandle[2])
|
||||
end
|
||||
feditempstore[playername] = fields.fediverse_account_url
|
||||
local formspec = "size[9,10]" ..
|
||||
"label[1,7;Check code on " .. minetest.formspec_escape(fields.fediverse_account_url) .. "]" ..
|
||||
|
|
|
@ -57,7 +57,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
end
|
||||
local secret_b32 = fediauth.get_player_secret_b32(playername)
|
||||
local codeseq = fediauth.give_code(secret_b32)
|
||||
fediauth.send_code(codeseq[1], fields.fediverse_account_url)
|
||||
if fediauth.is_home_instance(fedihandle[2]) then
|
||||
fediauth.send_code(codeseq[1], "@" .. fedihandle[1])
|
||||
else
|
||||
fediauth.send_code(codeseq[1], "@" .. fedihandle[1] .. "@" .. fedihandle[2])
|
||||
end
|
||||
feditempstore[playername] = fields.fediverse_account_url
|
||||
local formspec = "size[9,10]" ..
|
||||
"label[1,7;Check code on " .. minetest.formspec_escape(fields.fediverse_account_url) .. "]" ..
|
||||
|
|
Loading…
Reference in a new issue