コード例 #1
0
ファイル: Database.cs プロジェクト: TwE7k/Pegasus
        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);
        }
コード例 #2
0
        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}!");
            }
        }
コード例 #3
0
ファイル: DatabaseManager.cs プロジェクト: esoterick/Pegasus
        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));
            }
        }
コード例 #4
0
ファイル: AccountExtensions.cs プロジェクト: jacobtipp/trACE
        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));
        }