From 7f3dbcaac692646bd5f59a4f377e4a54d893c823 Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Wed, 30 Jul 2025 17:25:48 -0700 Subject: [PATCH] Remove local account related stuff --- database/mistox.sql | 19 --- src/Server/Entities/Account.cs | 6 - .../Services/DatabaseService/Account.cs | 160 ------------------ 3 files changed, 185 deletions(-) delete mode 100755 src/Server/Services/DatabaseService/Account.cs diff --git a/database/mistox.sql b/database/mistox.sql index 995ee57..4f83a81 100755 --- a/database/mistox.sql +++ b/database/mistox.sql @@ -1,25 +1,6 @@ CREATE DATABASE IF NOT EXISTS `boredcareers`; USE `boredcareers`; --- Account Section - -CREATE TABLE IF NOT EXISTS `Account` ( - `ID` int NOT NULL AUTO_INCREMENT, - `UserName` varchar(60) NOT NULL, - `Email` varchar(255) NOT NULL, - `EmailVerified` boolean DEFAULT 0, - `PasswordHash` char(60) DEFAULT NULL, - `FailedPasswordLock` boolean DEFAULT 0, - `PasswordAttempts` int(11) DEFAULT NULL, - `CurrentPasswordAttempts` int(11) DEFAULT NULL, - `Role` varchar(45) DEFAULT NULL, - `EmailToken` varchar(45) DEFAULT NULL, - `DataServer` varchar(200) DEFAULT NULL, - UNIQUE(`Email`), - UNIQUE(`UserName`), - PRIMARY KEY (`ID`) -) AUTO_INCREMENT=1; - -- Resume Section CREATE TABLE IF NOT EXISTS `Resume` ( diff --git a/src/Server/Entities/Account.cs b/src/Server/Entities/Account.cs index a98ddd4..601a831 100644 --- a/src/Server/Entities/Account.cs +++ b/src/Server/Entities/Account.cs @@ -3,13 +3,7 @@ namespace BoredCareers.Entities { public int ID { get; set; } // PK public string UserName { get; set; } = ""; public string Email { get; set; } = ""; - public bool EmailVerified { get; set; } = false; - public string PasswordHash { get; set; } = ""; - public bool FailedPasswordLock { get; set; } = false; - public int PasswordAttempts { get; set; } = 5; - public int CurrentPasswordAttempts { get; set; } = 0; public string Role { get; set; } = "Generic"; - public string EmailToken { get; set; } = ""; public string DataServer { get; set; } = ""; } } \ No newline at end of file diff --git a/src/Server/Services/DatabaseService/Account.cs b/src/Server/Services/DatabaseService/Account.cs deleted file mode 100755 index 09d5cf8..0000000 --- a/src/Server/Services/DatabaseService/Account.cs +++ /dev/null @@ -1,160 +0,0 @@ -using BoredCareers.Entities; -using MySql.Data.MySqlClient; -using System.Data; -using System.Data.Common; - -namespace BoredCareers.Services.DatabaseService { - public partial class DatabaseService { - - public async Task GetAccount( string UserNameOrEmail ) { - Account? account = null; - using( MySqlConnection connection = GetConnection() ) { - connection.Open(); - string command = @" - SELECT * - FROM Account - WHERE UserName = @UorE OR Email = @UorE; - "; - - MySqlCommand cmd = new MySqlCommand(command, connection); - cmd.Parameters.AddWithValue("@UorE", UserNameOrEmail); - - using( DbDataReader reader = await cmd.ExecuteReaderAsync() ) { - while( await reader.ReadAsync() ) { - if( reader == null ) { break; } - int _id = reader.GetInt32("ID"); - string _username = reader.GetString("UserName"); - string _email = reader.GetString("Email"); - bool _emailVerified = reader.GetBoolean("EmailVerified"); - string _passwordhash = reader.GetString("PasswordHash"); - bool _failedpasswordlock = reader.GetBoolean( "FailedPasswordLock" ); - int _passwordattempts = reader.GetInt32( "PasswordAttempts" ); - int _curpasswordattempts = reader.GetInt32( "CurrentPasswordAttempts" ); - string _role = reader.GetString( "Role" ); - string _emailtoken = reader.GetString( "EmailToken" ); - string _dataserver = reader.GetString( "DataServer" ); - - account = new Account() { - ID = _id, - UserName = _username, - Email = _email, - EmailVerified = _emailVerified, - PasswordHash = _passwordhash, - CurrentPasswordAttempts = _curpasswordattempts, - PasswordAttempts = _passwordattempts, - EmailToken = _emailtoken, - FailedPasswordLock = _failedpasswordlock, - Role = _role, - DataServer = _dataserver - }; - } - } - } - return account; - } - - public async Task GetAccount( int AccountID ) { - Account? account = null; - using( MySqlConnection connection = GetConnection() ) { - connection.Open(); - string command = @" - SELECT * - FROM Account - WHERE ID = @ID; - "; - - MySqlCommand cmd = new MySqlCommand(command, connection); - cmd.Parameters.AddWithValue("@ID", AccountID); - - using( DbDataReader reader = await cmd.ExecuteReaderAsync() ) { - while( await reader.ReadAsync() ) { - if( reader == null ) { - break; - } - int _id = reader.GetInt32("ID"); - string _username = reader.GetString("UserName"); - string _email = reader.GetString("Email"); - bool _emailVerified = reader.GetBoolean("EmailVerified"); - string _passwordhash = reader.GetString("PasswordHash"); - bool _failedpasswordlock = reader.GetBoolean( "FailedPasswordLock" ); - int _passwordattempts = reader.GetInt32( "PasswordAttempts" ); - int _curpasswordattempts = reader.GetInt32( "CurrentPasswordAttempts" ); - string _role = reader.GetString( "Role" ); - string _emailtoken = reader.GetString( "EmailToken" ); - string _dataserver = reader.GetString("DataServer"); - - account = new Account() { - ID = _id, - UserName = _username, - Email = _email, - EmailVerified = _emailVerified, - PasswordHash = _passwordhash, - CurrentPasswordAttempts = _passwordattempts, - PasswordAttempts = _passwordattempts, - EmailToken = _emailtoken, - FailedPasswordLock = _failedpasswordlock, - Role = _role, - DataServer = _dataserver - }; - } - } - } - return account; - } - - public async Task SetAccount( Account Profile ) { - using( MySqlConnection connection = GetConnection() ) { - connection.Open(); - - string command = @" - INSERT INTO Account - (ID,UserName,Email,EmailVerified,PasswordHash,FailedPasswordLock,PasswordAttempts,CurrentPasswordAttempts,Role,EmailToken,DataServer) - VALUES - (@ID,@UserName,@Email,@EmailVerified,@PasswordHash,@FailedPasswordLock,@PasswordAttempts,@CurrentPasswordAttempts,@Role,@EmailToken,@DataServer) - ON DUPLICATE KEY UPDATE - UserName = @UserName, - Email = @Email, - EmailVerified = @EmailVerified, - PasswordHash = @PasswordHash, - FailedPasswordLock = @FailedPasswordLock, - PasswordAttempts = @PasswordAttempts, - CurrentPasswordAttempts = @CurrentPasswordAttempts, - Role = @Role, - EmailToken = @EmailToken, - DataServer = @DataServer; - "; - - MySqlCommand cmd = new MySqlCommand( command , connection); - cmd.Parameters.AddWithValue("@ID", Profile.ID); - cmd.Parameters.AddWithValue("@UserName", Profile.UserName); - cmd.Parameters.AddWithValue("@Email", Profile.Email); - cmd.Parameters.AddWithValue("@EmailVerified", Profile.EmailVerified); - cmd.Parameters.AddWithValue("@PasswordHash", Profile.PasswordHash); - cmd.Parameters.AddWithValue("@FailedPasswordLock", Profile.FailedPasswordLock); - cmd.Parameters.AddWithValue("@PasswordAttempts", Profile.PasswordAttempts); - cmd.Parameters.AddWithValue("@CurrentPasswordAttempts", Profile.CurrentPasswordAttempts); - cmd.Parameters.AddWithValue("@Role", Profile.Role); - cmd.Parameters.AddWithValue("@EmailToken", Profile.EmailToken); - cmd.Parameters.AddWithValue("@DataServer", Profile.DataServer); - - await cmd.ExecuteNonQueryAsync(); - } - } - - public async Task DeleteAccount( int AccountID ) { - using( MySqlConnection connection = GetConnection() ) { - MySqlCommand cmd; - connection.Open(); - - string command = @" - DELETE FROM Account WHERE ID = @ID; - "; - cmd = new MySqlCommand( command, connection ); - cmd.Parameters.AddWithValue("@ID", AccountID); - - await cmd.ExecuteNonQueryAsync(); - } - } - - } -}