Beispiel #1
0
 public JsonResult Restore(string email)
 {
     try
     {
         User         user    = authProvider.GetUserByEmail(email);
         string       body    = String.Format("Hello, {0}! Your password is {1}.", user.UserName, user.Password);
         const string subject = "Password restoration.";
         try
         {
             authProvider.EmailSender(new System.Net.Mail.MailAddress("*****@*****.**", "Restaurant Rating Team"), "secret0000",
                                      new System.Net.Mail.MailAddress(email), subject, body);
             return(Json(new { result = "success", message = "Restore E-mail was sended successful!" }));
         }
         catch
         {
             return(Json(new { result = "error", message = "Error occured while sending e-mail\nPlease, try again later." }));
         }
     }
     catch
     {
         return(Json(new { result = "error", message = "User with this E-mail doesn't exist!\nWe cannot restore password unregistered user." }));
     }
 }