mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-25 14:00:18 +01:00
Adds external auth (#6380)
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
var/client/my_client // Need to keep track of this ourselves, since by the time Logout() is called the client has already been nulled
|
||||
|
||||
/mob/abstract/new_player/Login()
|
||||
client.InitPerfs()
|
||||
update_Login_details() //handles setting lastKnownIP and computer_id for use by the ban systems as well as checking for multikeying
|
||||
|
||||
to_chat(src, "<div class='info'>Game ID: <div class='danger'>[game_id]</div></div>")
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/var/list/unauthed = list()
|
||||
|
||||
/mob/abstract/unauthed
|
||||
authed = FALSE
|
||||
var/token = ""
|
||||
|
||||
/mob/abstract/unauthed/New()
|
||||
verbs -= typesof(/mob/verb)
|
||||
|
||||
/mob/abstract/unauthed/Login()
|
||||
update_Login_details()
|
||||
to_chat(src, "<span class='danger'><b>You need to authenticate before you can continue.</b></span>")
|
||||
token = md5("[client.ckey][client.computer_id][world.time][rand()]")
|
||||
unauthed[token] = src
|
||||
client.verbs -= typesof(/client/verb)
|
||||
var/uihtml = "<html><head><style>body * {display: block;text-align:center;margin: 14px 0;font-size:24px;text-decoration:none;font-family:Segoe UI,Frutiger,Frutiger Linotype,Dejavu Sans,Helvetica Neue,Arial,sans-serif;}</style></head><body><p>Please select:</p>"
|
||||
if(config.guests_allowed)
|
||||
uihtml += "<a href='?src=\ref[src];authaction=guest'>Login as guest</a>"
|
||||
if(config.webint_url)
|
||||
uihtml += "<a href='?src=\ref[src];authaction=forums'>Login via forums</a>"
|
||||
if(!config.guests_allowed && config.webint_url)
|
||||
src.OpenForumAuthWindow()
|
||||
show_browser(src, uihtml, "window=auth;size=300x300;border=0;can_close=0;can_resize=0;can_minimize=0;titlebar=1")
|
||||
|
||||
/mob/abstract/unauthed/proc/ClientLogin(var/newkey)
|
||||
if(!client)
|
||||
qdel(src)
|
||||
var/client/c = client
|
||||
show_browser(src, null, "window=auth;")
|
||||
client.verbs += typesof(/client/verb) // Let's return regular client verbs
|
||||
client.authed = TRUE // We declare client as authed now
|
||||
// Check for bans
|
||||
var/list/ban_data = world.IsBanned(ckey(newkey), c.address, c.computer_id)
|
||||
if(ban_data)
|
||||
to_chat(c, "You are banned for this server.")
|
||||
to_chat(c, "Reason: [ban_data["reason"]]")
|
||||
to_chat(c, "Description: [ban_data["desc"]]")
|
||||
del(c)
|
||||
return
|
||||
directory -= client.ckey
|
||||
if(newkey)
|
||||
client.key = newkey // Try seeting ckey
|
||||
directory[c.ckey] = c
|
||||
// If mob exists for that ckey, then BYOND will transfer client to it.
|
||||
if(istype(c.mob, /mob/abstract/unauthed))
|
||||
c.mob = new /mob/abstract/new_player() // Else we just treat them as new player
|
||||
c.InitPerfs() // We init pers just in case mob transfer didn't
|
||||
c.InitClient() // And now we shal continue client initilization (permissions and stuff)
|
||||
unauthed -= token
|
||||
|
||||
/mob/abstract/unauthed/Topic(href, href_list)
|
||||
switch(href_list["authaction"])
|
||||
if("guest")
|
||||
src.ClientLogin(null)
|
||||
if("forums")
|
||||
src.OpenForumAuthWindow()
|
||||
|
||||
/mob/abstract/unauthed/proc/OpenForumAuthWindow()
|
||||
src << link("[config.webint_url]server/auth?token=[token]")
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
log_access("Notice: [key_name(src)] has the same [matches] as [key_name(M)] (no longer logged in).",ckey=key_name(src))
|
||||
|
||||
/mob/Login()
|
||||
client.InitPerfs() // Init perfs in case they wasn't initilized
|
||||
player_list |= src
|
||||
update_Login_details()
|
||||
SSfeedback.update_status()
|
||||
|
||||
@@ -236,3 +236,5 @@
|
||||
var/disconnect_time = null//Time of client loss, set by Logout(), for timekeeping
|
||||
|
||||
var/mob_thinks = TRUE
|
||||
|
||||
var/authed = TRUE
|
||||
Reference in New Issue
Block a user