示例#1
0
 public TokenResponse()
 {
     var app = new Application("*****@*****.**", "password", "password");
       var regResult = new Registrator().ApplyForMembership(app);
       var svc = new MonkeyFist.Services.Reminders().SendReminderTokenToUser(regResult.NewUser.Email);
       result = new MonkeyFist.Services.Reminders().ResetUserPassword(svc.User.ReminderToken, "newPassword");
       user = result.User;
 }
示例#2
0
        public TokenResponseExpired()
        {
            var app = new Application("*****@*****.**", "password", "password");
              var regResult = new Registrator().ApplyForMembership(app);

              using (var session = new Session()) {
            var user = session.Users.FirstOrDefault(x => x.Email == regResult.NewUser.Email);
            user.ReminderSentAt = DateTime.Now.AddDays(-1);
            session.SaveChanges();
              }

              result = new MonkeyFist.Services.Reminders().ResetUserPassword(regResult.NewUser.ReminderToken, "newPassword");
        }
示例#3
0
        public ResetResult ResetUserPassword(Guid token, string newPassword)
        {
            var result = new ResetResult();
              _session = _session ?? new Session();
              var user = GetUserByToken(token);
              if (user != null) {
            if (PasswordResetIsValid(newPassword)) {
              if (ResetWindowIsOpen(user)) {

            var hashed = BCryptHelper.HashPassword(newPassword, BCryptHelper.GenerateSalt(10));
            user.HashedPassword = hashed;
            user.AddLogEntry("Login", "Password was reset");
            _session.SaveChanges();
            result.Successful = true;
            result.Message = Properties.Resources.PasswordResetSuccessful;
            result.User = user;
              } else {
            result.Message = Properties.Resources.PasswordResetExpired;
              }
            } else {
              result.Message = Properties.Resources.InvalidPassword;
            }
              } else {
            result.Message = Properties.Resources.PasswordResetTokenInvalid;
              }
              _session.Dispose();
              return result;
        }