diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm
index 9380bd9310c..a7b2fa0753a 100644
--- a/code/modules/admin/admin_verbs.dm
+++ b/code/modules/admin/admin_verbs.dm
@@ -675,54 +675,56 @@ GLOBAL_LIST_INIT(admin_verbs_maintainer, list(
qdel(rank_read)
if(!D)
- if(!GLOB.configuration.admin.use_database_admins)
- if(GLOB.admin_ranks[rank] == null)
- error("Error while re-adminning [src], admin rank ([rank]) does not exist.")
- to_chat(src, "Error while re-adminning, admin rank ([rank]) does not exist.")
- return
-
- // Do a little check here
- if(GLOB.configuration.system.is_production && (GLOB.admin_ranks[rank] & R_ADMIN) && prefs._2fa_status == _2FA_DISABLED) // If they are an admin and their 2FA is disabled
- to_chat(src,"You do not have 2FA enabled. Admin verbs will be unavailable until you have enabled 2FA.") // Very fucking obvious
- return
- D = new(rank, GLOB.admin_ranks[rank], ckey)
- else
- if(!SSdbcore.IsConnected())
- to_chat(src, "Warning, MYSQL database is not connected.")
- return
-
- var/datum/db_query/admin_read = SSdbcore.NewQuery(
- "SELECT ckey, admin_rank, flags FROM admin WHERE ckey=:ckey",
- list("ckey" = ckey)
- )
-
- if(!admin_read.warn_execute())
- qdel(admin_read)
- return FALSE
-
- while(admin_read.NextRow())
- var/admin_ckey = admin_read.item[1]
- var/admin_rank = admin_read.item[2]
- var/flags = admin_read.item[3]
- if(!admin_ckey)
- to_chat(src, "Error while re-adminning, ckey [admin_ckey] was not found in the admin database.")
- qdel(admin_read)
- return
- if(admin_rank == "Removed") //This person was de-adminned. They are only in the admin list for archive purposes.
- to_chat(src, "Error while re-adminning, ckey [admin_ckey] is not an admin.")
- qdel(admin_read)
+ D = try_localhost_autoadmin()
+ if(!D)
+ if(!GLOB.configuration.admin.use_database_admins)
+ if(GLOB.admin_ranks[rank] == null)
+ error("Error while re-adminning [src], admin rank ([rank]) does not exist.")
+ to_chat(src, "Error while re-adminning, admin rank ([rank]) does not exist.")
return
- if(istext(flags))
- flags = text2num(flags)
- var/client/check_client = GLOB.directory[ckey]
// Do a little check here
- if(GLOB.configuration.system.is_production && (flags & R_ADMIN) && check_client.prefs._2fa_status == _2FA_DISABLED) // If they are an admin and their 2FA is disabled
+ if(GLOB.configuration.system.is_production && (GLOB.admin_ranks[rank] & R_ADMIN) && prefs._2fa_status == _2FA_DISABLED) // If they are an admin and their 2FA is disabled
to_chat(src,"You do not have 2FA enabled. Admin verbs will be unavailable until you have enabled 2FA.") // Very fucking obvious
- qdel(admin_read)
return
- D = new(admin_rank, flags, ckey)
- qdel(admin_read)
+ D = new(rank, GLOB.admin_ranks[rank], ckey)
+ else
+ if(!SSdbcore.IsConnected())
+ to_chat(src, "Warning, MYSQL database is not connected.")
+ return
+
+ var/datum/db_query/admin_read = SSdbcore.NewQuery(
+ "SELECT ckey, admin_rank, flags FROM admin WHERE ckey=:ckey",
+ list("ckey" = ckey)
+ )
+
+ if(!admin_read.warn_execute())
+ qdel(admin_read)
+ return FALSE
+
+ while(admin_read.NextRow())
+ var/admin_ckey = admin_read.item[1]
+ var/admin_rank = admin_read.item[2]
+ var/flags = admin_read.item[3]
+ if(!admin_ckey)
+ to_chat(src, "Error while re-adminning, ckey [admin_ckey] was not found in the admin database.")
+ qdel(admin_read)
+ return
+ if(admin_rank == "Removed") //This person was de-adminned. They are only in the admin list for archive purposes.
+ to_chat(src, "Error while re-adminning, ckey [admin_ckey] is not an admin.")
+ qdel(admin_read)
+ return
+
+ if(istext(flags))
+ flags = text2num(flags)
+ var/client/check_client = GLOB.directory[ckey]
+ // Do a little check here
+ if(GLOB.configuration.system.is_production && (flags & R_ADMIN) && check_client.prefs._2fa_status == _2FA_DISABLED) // If they are an admin and their 2FA is disabled
+ to_chat(src,"You do not have 2FA enabled. Admin verbs will be unavailable until you have enabled 2FA.") // Very fucking obvious
+ qdel(admin_read)
+ return
+ D = new(admin_rank, flags, ckey)
+ qdel(admin_read)
var/client/C = GLOB.directory[ckey]
D.associate(C)
diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm
index 20adff91cd8..5346e7d3d0b 100644
--- a/code/modules/client/client_procs.dm
+++ b/code/modules/client/client_procs.dm
@@ -254,9 +254,7 @@
GLOB.directory[ckey] = src
//Admin Authorisation
// Automatically makes localhost connection an admin
- if(GLOB.configuration.admin.enable_localhost_autoadmin)
- if(is_connecting_from_localhost())
- new /datum/admins("!LOCALHOST!", R_HOST, ckey) // Makes localhost rank
+ try_localhost_autoadmin()
holder = GLOB.admin_datums[ckey]
if(holder)
@@ -1184,6 +1182,9 @@
else
SSambience.ambience_listening_clients -= src
+/client/proc/try_localhost_autoadmin()
+ if(GLOB.configuration.admin.enable_localhost_autoadmin && is_connecting_from_localhost())
+ return new /datum/admins("!LOCALHOST!", R_HOST, ckey)
// Verb scoped to the client level so its ALWAYS available
/client/verb/open_tos()