コード例 #1
0
        public LoginResult ValidateUser(Core.Domain.User.User user, string password)
        {
            if (user == null)
            {
                return(LoginResult.UserNotExists);
            }
            string pwd;

            switch (user.PasswordFormat)
            {
            case PasswordFormat.Encrypted:
                pwd = _encryptionService.EncryptText(password);
                break;

            case PasswordFormat.Hashed:
                pwd = _encryptionService.CreatePasswordHash(password, user.PasswordSalt);
                break;

            default:
                pwd = password;
                break;
            }
            if (user.Password != pwd)
            {
                return(LoginResult.WrongPassword);
            }
            return(LoginResult.Successful);
        }
コード例 #2
0
        public async Task SignIn(HttpContext context, Core.Domain.User.User user, bool remember = false)
        {
            //you can add all of ClaimTypes in this collection
            var claims = new List <Claim>()
            {
                new Claim(ClaimTypes.Name, user.UserName)
            };

            //init the identity instances
            var userPrincipal = new ClaimsPrincipal(new ClaimsIdentity(claims, "SuperSecureLogin"));

            //signin
            await context.Authentication.SignInAsync("Cookie", userPrincipal, new AuthenticationProperties
            {
                ExpiresUtc   = remember?DateTime.UtcNow.AddDays(30):DateTime.UtcNow.AddMinutes(20),
                IsPersistent = false,
                AllowRefresh = false
            });
        }
コード例 #3
0
ファイル: UserRepository.cs プロジェクト: Cule5/TaskManager
        public async System.Threading.Tasks.Task AddAsync(Core.Domain.User.User user)
        {
            await _dbContext.AddAsync(user);

            await _dbContext.SaveChangesAsync();
        }
コード例 #4
0
 public int UpdatUser(Core.Domain.User.User user)
 {
     return(_userRepository.Insert(user));
 }
コード例 #5
0
 public int DeleteUser(Core.Domain.User.User user)
 {
     return(_userRepository.Delete(user));
 }