Пример #1
0
 private bool checkUserAnswers(VerifyPasswordModal verifyPasswordObject, out User user)
 {
     user = userCRUD.GetUserByEmail(verifyPasswordObject.Email);
     if (user.Email == verifyPasswordObject.Email && user.Question1 == verifyPasswordObject.Question1 && user.Question2 == verifyPasswordObject.Question2)
     {
         return(true);
     }
     return(false);
 }
Пример #2
0
        public ErrorMessage SendLinkToResetPassword(VerifyPasswordModal verifyPasswordObject, string Authority, string Scheme)
        {
            ErrorMessage errorMessage;
            User         user;

            if (checkUserAnswers(verifyPasswordObject, out user))
            {
                //send email
                try
                {
                    string to      = verifyPasswordObject.Email;
                    string from    = "*****@*****.**";
                    string subject = "Reset your Password";

                    string tokenEmailPassword = JwtManager.GenerateToken(user.Email, user.Password);
                    string body = String.Format(@"
                                    Hello {0}! 
                                    Please click the following link to reset your password:
                                    {1}://{2}/resetPassword?authUser={3}
                                    Thanks!
                                    It's a deal team", user.Name, Scheme, Authority, tokenEmailPassword);


                    MailMessage mail   = new MailMessage(from, to, subject, body);
                    SmtpClient  client = new SmtpClient("smtp.gmail.com");
                    client.Credentials = new NetworkCredential("*****@*****.**", "Aa@123456");
                    client.Port        = 25;
                    client.EnableSsl   = true;
                    client.Send(mail);
                    errorMessage = new ErrorMessage
                    {
                        Code = HttpStatusCode.OK
                    };
                    return(errorMessage);
                }
                catch (Exception ex)
                {
                    return(null);

                    throw;
                }
            }
            else
            {
                errorMessage = new ErrorMessage
                {
                    Code    = HttpStatusCode.NotModified,
                    Message = "Validation Error"
                };
                return(errorMessage);
            }
        }
Пример #3
0
        public IHttpActionResult SendLinkToResetPassword(VerifyPasswordModal verifyPasswordObject)
        {
            ErrorMessage errorMessage = usersBL.SendLinkToResetPassword(verifyPasswordObject, Request.Headers.Referrer.Authority, Request.Headers.Referrer.Scheme);

            if (errorMessage.Code == HttpStatusCode.OK)
            {
                return(Ok(verifyPasswordObject));
            }
            return(new ResponseMessageResult(Request.CreateErrorResponse(
                                                 errorMessage.Code,
                                                 new HttpError(errorMessage.Message)
                                                 )
                                             ));
        }