public AccountInfo CreateAccount(string username, string password, string ip, Privilege privileges) { string bcryptPassword = BCryptProvider.HashPassword(password); (int rowsEffected, long lastInsertedId) = ExecutePreparedStatement(PreparedStatementId.AccountInsert, username, bcryptPassword, ip, (ushort)privileges); var account = new AccountInfo(); account.Read((uint)lastInsertedId, username, bcryptPassword, privileges); return(account); }
public void AccountCreateCommandHandler(ICommandContext context, string username, string password) { string encryptedPassword = BCryptProvider.HashPassword(password); if (DatabaseManager.Instance.AuthDatabase.CreateAccount(username.ToLower(), encryptedPassword)) { context.SendMessage($"Successfully created Account {username}."); } else { context.SendError($"Failed to create account {username}!"); } }
public static Account CreateAccount(string username, string password, IPAddress ip, Privilege privileges) { using (var context = new DatabaseContext()) { context.Account.Add(new Account { Username = username, Password = BCryptProvider.HashPassword(password), CreateIp = ip.ToString(), Privileges = (short)privileges }); context.SaveChanges(); return(context.Account.SingleOrDefault(a => a.Username == username)); } }
private static string GetPasswordHash(string password) { var workFactor = Common.ConfigManager.Config.Server.Accounts.PasswordHashWorkFactor; if (workFactor < 4) { log.Warn("PasswordHashWorkFactor in config less than minimum value of 4, using 4 and continuing."); workFactor = 4; } else if (workFactor > 31) { log.Warn("PasswordHashWorkFactor in config greater than minimum value of 31, using 31 and continuing."); workFactor = 31; } return(BCryptProvider.HashPassword(password, workFactor)); }