コード例 #1
0
ファイル: WebUserContext.cs プロジェクト: jacderida/JobSystem
 /// <summary>
 /// The user currently logged in. 
 /// </summary>
 /// <returns>The user account of the user currently logged ins</returns>
 public UserAccount GetCurrentUser()
 {
     UserAccount user = CurrentUser;
     if (user == null)
     {
         user = GetUserAccountFromPrincipal();
         if (user != UserAccount.Anonymous)
             CurrentUser = user;
     }
     return user;
 }
コード例 #2
0
 public UserAccount Create(Guid id, string name, string email, string password, string jobTitle)
 {
     if (id == null || id == Guid.Empty)
         throw new ArgumentException("An ID must be supplied to create a user");
     if (String.IsNullOrEmpty(password))
         throw new ArgumentException("A password must be supplied to create a user");
     var userAccount = new UserAccount
     {
         Id = id,
         EmailAddress = email,
         Name = name,
         JobTitle = jobTitle
     };
     SetPassword(userAccount, password);
     _userAccountValidator.ValidateThrowOnFailure(userAccount);
     _userAccountRepository.Create(userAccount);
     return userAccount;
 }
コード例 #3
0
 private bool ValidatePassword(UserAccount userAccount, string password)
 {
     var hash = _cryptographicService.ComputeHash(password, userAccount.PasswordSalt);
     return hash == userAccount.PasswordHash;
 }
コード例 #4
0
 private void SetPassword(UserAccount userAccount, string password)
 {
     userAccount.PasswordSalt = _cryptographicService.GenerateSalt();
     userAccount.PasswordHash = _cryptographicService.ComputeHash(password, userAccount.PasswordSalt);
 }