public string ChangePassword(UserLogin userLogin)
 {
     using (var uow = new UnitOfWork())
     {
         var userLoginFrmDb = uow.GetRepository<UserLogin>().Items.FirstOrDefault(x => x.Id == userLogin.Id);
         var encryptedPassword = EncryptionExtensions.CreatePasswordHash(userLogin.Password,
                            userLogin.saltkey);
         if (userLoginFrmDb.Password.Equals(encryptedPassword))
             return "Current Password and New Password should not be the same.";
         userLoginFrmDb.Password = userLogin.Password = encryptedPassword;
         var userHstryFrmDb = uow.GetRepository<UserHistory>().Items.Where(x => x.UserloginId == userLogin.Id);
         foreach (var item in userHstryFrmDb)
         {
             var encryptedPasswordCap = EncryptionExtensions.CreatePasswordCapHash(userLogin.Password, item.saltkey, item.Captcha);
             item.PasswordCap = encryptedPasswordCap;
             uow.GetRepository<UserHistory>().Update(item);
         }
         userLoginFrmDb.PasswordCap = userHstryFrmDb.FirstOrDefault().PasswordCap;
         uow.GetRepository<UserLogin>().Update(userLoginFrmDb);
         uow.SaveChanges();
         return "Successfully Saved.";
     }
 }
 public string ChangeSecurityAnswer(UserLogin userLogin)
 {
     using (var uow = new UnitOfWork())
     {
         var userLoginFrmDb = uow.GetRepository<UserLogin>().Items.FirstOrDefault(x => x.Id == userLogin.Id);
         var encryptedSecurityAnswer = EncryptionExtensions.CreatePasswordHash(userLogin.SecurityAnswer, userLoginFrmDb.saltkey);
         if (userLoginFrmDb.SecurityAnswer.Equals(encryptedSecurityAnswer))
             return "Current Security Answer and New Security Answer should not be the same.";
         userLoginFrmDb.SecurityAnswer = encryptedSecurityAnswer;
         uow.GetRepository<UserLogin>().Update(userLoginFrmDb);
         return "Successfully saved.";
     }
 }
 private void AuthenticateUser(Domain.User user, UserLogin userLogin)
 {
     SessionContext.CurrentUser = user;
     FormsAuthentication.SetAuthCookie(userLogin.UserName, false);
     var ticket = new FormsAuthenticationTicket(1, userLogin.UserName, DateTime.UtcNow, DateTime.UtcNow.AddMinutes(System.Web.HttpContext.Current.Session.Timeout),
         false, user.ToString(), FormsAuthentication.FormsCookiePath);
     var encryptedTicket = FormsAuthentication.Encrypt(ticket);
     var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) { HttpOnly = true };
     authCookie.Expires = ticket.Expiration;
     System.Web.HttpContext.Current.Response.Cookies.Add(authCookie);
     _sessionContext.SetUpSessionContext(HttpContext, SessionContext.CurrentUser);
     SetUserIdentity(SessionContext.LoggedOnUser);
 }
Beispiel #4
0
 public string ChangeSecurityAnswer(UserLogin userlogin)
 {
     var userLogin = _userRepository.ChangeSecurityAnswer(userlogin);
     return userLogin;
 }
Beispiel #5
0
 public string ChangePassword(UserLogin userlogin)
 {
     var userLogin = _userRepository.ChangePassword(userlogin);
     return userLogin;
 }
 public string ChangeSecurityAnswer(UserLogin userlogin)
 {
     var userLogn = _userBl.ChangeSecurityAnswer(userlogin);
     return userLogn;
 }
 public string ChangePassword(UserLogin userlogin)
 {
     var userLogn = _userBl.ChangePassword(userlogin);
     return userLogn;
 }