示例#1
0
        public async Task <User> Register(User newUser, string password)
        {
            var userUsername = newUser.Username.ToString().ToLower();

            if (await isExistUser(userUsername))
            {
                return(null);
            }

            byte[] passwordSalt, passwordHash;
            EncryptPassword(password, out passwordSalt, out passwordHash);
            newUser.PasswordSalt = passwordSalt;
            newUser.PasswordHash = passwordHash;
            newUser.Username     = userUsername;
            newUser.isWithBadge  = false;
            _context.Add(newUser);
            await _context.SaveChangesAsync();

            return(newUser);
        }
示例#2
0
 private async Task <bool> ProcessSave()
 {
     return(await _context.SaveChangesAsync() > 0);
 }