Fixed localhost autoadmin for the re-admin verb (#18897)

* Fixed localhost autoadmin for the re-admin verb

* Update code/modules/client/client_procs.dm

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
This commit is contained in:
DamianX
2022-09-09 06:51:39 +02:00
committed by GitHub
parent c5b32512ab
commit ed9e232af5
2 changed files with 49 additions and 46 deletions
+45 -43
View File
@@ -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,"<span class='boldannounce'><big>You do not have 2FA enabled. Admin verbs will be unavailable until you have enabled 2FA.</big></span>") // 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,"<span class='boldannounce'><big>You do not have 2FA enabled. Admin verbs will be unavailable until you have enabled 2FA.</big></span>") // 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,"<span class='boldannounce'><big>You do not have 2FA enabled. Admin verbs will be unavailable until you have enabled 2FA.</big></span>") // 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)