diff --git a/SQL/beestation_schema.sql b/SQL/beestation_schema.sql index f5afee8addc82..dbaae366d73e6 100644 --- a/SQL/beestation_schema.sql +++ b/SQL/beestation_schema.sql @@ -302,12 +302,14 @@ CREATE TABLE IF NOT EXISTS `SS13_player` ( `lastseen_round_id` int(11) unsigned NOT NULL, `ip` int(10) unsigned NOT NULL, `computerid` varchar(32) NOT NULL, + `uuid` varchar(64) DEFAULT NULL, `lastadminrank` varchar(32) NOT NULL DEFAULT 'Player', `accountjoindate` date DEFAULT NULL, `flags` smallint(5) unsigned NOT NULL DEFAULT '0', `antag_tokens` tinyint(4) unsigned DEFAULT '0', `metacoins` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`ckey`), + UNIQUE KEY (`uuid`), KEY `idx_player_cid_ckey` (`computerid`,`ckey`), KEY `idx_player_ip_ckey` (`ip`,`ckey`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; @@ -479,7 +481,7 @@ CREATE TABLE IF NOT EXISTS `SS13_schema_revision` ( `date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`major`,`minor`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 6); +INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 7); diff --git a/SQL/database_changelog.txt b/SQL/database_changelog.txt index fd661e450d6d6..a8fa7f1d021d4 100644 --- a/SQL/database_changelog.txt +++ b/SQL/database_changelog.txt @@ -1,13 +1,22 @@ Any time you make a change to the schema files, remember to increment the database schema version. Generally increment the minor number, major should be reserved for significant changes to the schema. Both values go up to 255. -The latest database version is 5.6; The query to update the schema revision table is: +The latest database version is 5.7; The query to update the schema revision table is: -INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 6); +INSERT INTO `schema_revision` (`major`, `minor`) VALUES (5, 7); or -INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 6); +INSERT INTO `SS13_schema_revision` (`major`, `minor`) VALUES (5, 7); In any query remember to add a prefix to the table names if you use one. +----------------------------------------------------- + +Version 5.7 20 July 2020, by ike709 +Adds a new `uuid` column in the `player` table that allows for discord verification. + +ALTER TABLE SS13_player +ADD COLUMN `uuid` VARCHAR(64) DEFAULT NULL AFTER `computerid`, +ADD CONSTRAINT `UUID` UNIQUE KEY (`uuid`) + ---------------------------------------------------- Version 5.6, 13 June 2020, by Jordie0608 diff --git a/code/__DEFINES/subsystems.dm b/code/__DEFINES/subsystems.dm index fc5857f65ae61..dd7e9ecb791ac 100644 --- a/code/__DEFINES/subsystems.dm +++ b/code/__DEFINES/subsystems.dm @@ -20,7 +20,7 @@ * * make sure you add an update to the schema_version stable in the db changelog */ -#define DB_MINOR_VERSION 6 +#define DB_MINOR_VERSION 7 //! ## Timing subsystem diff --git a/code/datums/browser.dm b/code/datums/browser.dm index e9b9e0e898653..c3add50464789 100644 --- a/code/datums/browser.dm +++ b/code/datums/browser.dm @@ -44,7 +44,7 @@ stylesheets["spritesheet_[sheet.name].css"] = "data/spritesheets/[sheet.name]" else var/asset_name = "[name].css" - + stylesheets[asset_name] = file if (!SSassets.cache[asset_name]) @@ -439,8 +439,8 @@ // to pass a "close=1" parameter to the atom's Topic() proc for special handling. // Otherwise, the user mob's machine var will be reset directly. // -/proc/onclose(mob/user, windowid, atom/ref=null) - if(!user.client) +/proc/onclose(user, windowid, atom/ref=null) + if(isnull(user)) return var/param = "null" if(ref) diff --git a/code/datums/world_topic.dm b/code/datums/world_topic.dm index 29d04efc7b421..89d5fbf1398ec 100644 --- a/code/datums/world_topic.dm +++ b/code/datums/world_topic.dm @@ -182,3 +182,30 @@ .["shuttle_timer"] = SSshuttle.emergency.timeLeft() // Shuttle timer, in seconds +/datum/world_topic/identify_uuid + keyword = "identify_uuid" + require_comms_key = TRUE + log = FALSE + +/datum/world_topic/identify_uuid/Run(list/input, addr) + var/uuid = input["uuid"] + . = list() + + if(!SSdbcore.Connect()) + return null + + var/datum/DBQuery/query_ckey_lookup = SSdbcore.NewQuery( + "SELECT ckey FROM [format_table_name("player")] WHERE uuid = :uuid", + list("uuid" = uuid) + ) + if(!query_ckey_lookup.Execute()) + qdel(query_ckey_lookup) + return null + + .["identified_ckey"] = null + if(query_ckey_lookup.NextRow()) + .["identified_ckey"] = query_ckey_lookup.item[1] + qdel(query_ckey_lookup) + return . + + diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index 25dc56bf24f38..87b9477de936a 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -404,6 +404,9 @@ GLOBAL_LIST_EMPTY(external_rsc_urls) check_ip_intel() validate_key_in_db() + fetch_uuid() + verbs += /client/proc/show_account_identifier + send_resources() generate_clickcatcher() @@ -471,6 +474,53 @@ GLOBAL_LIST_EMPTY(external_rsc_urls) src << link("[redirect_address]") qdel(src) +/client/proc/generate_uuid() + if(IsAdminAdvancedProcCall()) + log_admin("Attempted admin generate_uuid() proc call blocked.") + message_admins("Attempted admin generate_uuid() proc call blocked.") + return FALSE + + var/fiftyfifty = prob(50) ? FEMALE : MALE + var/hashtext = "[ckey][rand(0,9999)][world.realtime][rand(0,9999)][random_unique_name(fiftyfifty)][rand(0,9999)][address][rand(0,9999)][computer_id][rand(0,9999)][GLOB.round_id]" + var/uuid = "[rustg_hash_string(RUSTG_HASH_SHA256, hashtext)]" + + if(!SSdbcore.Connect()) + return FALSE + + var/datum/DBQuery/query_update_uuid = SSdbcore.NewQuery( + "UPDATE [format_table_name("player")] SET uuid = :uuid WHERE ckey = :ckey", + list("uuid" = uuid, "ckey" = ckey) + ) + query_update_uuid.Execute() + qdel(query_update_uuid) + + return uuid + +/client/proc/fetch_uuid() + if(IsAdminAdvancedProcCall()) + log_admin("Attempted admin fetch_uuid() proc call blocked.") + message_admins("Attempted admin fetch_uuid() proc call blocked.") + return FALSE + + if(!SSdbcore.Connect()) + return FALSE + + var/datum/DBQuery/query_get_uuid = SSdbcore.NewQuery( + "SELECT uuid FROM [format_table_name("player")] WHERE ckey = :ckey", + list("ckey" = ckey) + ) + if(!query_get_uuid.Execute()) + qdel(query_get_uuid) + return FALSE + var/uuid = null + if(query_get_uuid.NextRow()) + uuid = query_get_uuid.item[1] + qdel(query_get_uuid) + if(uuid == null) + return generate_uuid() + else + return uuid + ////////////// //DISCONNECT// ////////////// @@ -973,3 +1023,33 @@ GLOBAL_LIST_EMPTY(external_rsc_urls) screen -= S qdel(S) char_render_holders = null + +/client/proc/show_account_identifier() + set name = "Show Account Identifier" + set category = "OOC" + set desc ="Get your ID for account verification." + + verbs -= /client/proc/show_account_identifier + addtimer(CALLBACK(src, .proc/restore_account_identifier), 20) //Don't DoS DB queries, asshole + + var/confirm = alert("Do NOT share the verification ID in the following popup. Understand?", "Important Warning", "Yes", "Cancel") + if(confirm == "Cancel") + return + if(confirm == "Yes") + var/uuid = fetch_uuid() + if(!uuid) + alert("Failed to fetch your verification ID. Try again later. If problems persist, tell an admin.", "Account Verification", "Okay") + log_sql("Failed to fetch UUID for [key_name(src)]") + else + var/dat + dat += "