public ActionResult Reset(string email, string password, string confirm_password, string otpCode)
        {
            var otp = DatabaseOtpService.GetByCode(otpCode);

            if (otp == null || !otp.IsActive())
            {
                return(Index());
            }
            DatabaseOtpService.Disable(otp.Id);

            var user = Login.GetLogin(email);

            if (user == null)
            {
                return(Index());
            }

            if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(confirm_password))
            {
                return(ResetResult(ResetResults.PasswordNotSet));
            }

            if (password != confirm_password)
            {
                return(ResetResult(ResetResults.PasswordsDontMatch));
            }

            user.SetPassword(password);

            return(ResetResult(null));
        }
Exemple #2
0
        public ActionResult Code(string userId, string loginCode)
        {
            if (userId == null || loginCode == null)
            {
                return(RedirectToAction("Index", "Login"));
            }

            long userIdLong;

            if (!long.TryParse(userId, out userIdLong))
            {
                return(RedirectToAction("Index", "Login"));
            }

            var otp = DatabaseOtpService.GetByCode(loginCode);

            if (otp.Time.AddMinutes(10) < DateTime.Now || otp.UserId != userIdLong)
            {
                return(RedirectToAction("Index", "Login"));
            }
            DatabaseOtpService.Disable(otp.Id);

            Session[Models.Login.UserIdSession] = otp.UserId;
            return(RedirectToAction("Index", "Patient"));
        }
Exemple #3
0
 public bool IsActive()
 {
     if (!object_active)
     {
         return(false);
     }
     if ((Time - DateTime.Now).TotalDays < 1)
     {
         return(true);
     }
     else
     {
         DatabaseOtpService.Disable(Id);
     }
     return(false);
 }