public ActionResult RetriveLogin(string email, string mobile, string returnUrl) { ViewBag.ReturnUrl = returnUrl; List<Person> Persons = reposetory.GetPeople(email, mobile); LogFile.Write(string.Format("Retrive login {0}/{1}",email, mobile)); if (Persons != null) { foreach (Person P in Persons) { if (!WebSecurity.Login(P.UserName, P.Password, persistCookie: false)) { if (WebSecurity.ResetPassword(WebSecurity.GeneratePasswordResetToken(P.UserName), P.Password)) { } } else { WebSecurity.Logout(); } if (!String.IsNullOrWhiteSpace(P.Email)) { var mail = new ForgotLoginEmail { To = P.Email, UserName = P.UserName, Password = P.Password }; try { mail.Send(); } catch (Exception Ex) { LogFile.Write(Ex, "Send Mail Retrive Login"); } } if (!String.IsNullOrWhiteSpace(P.Mobile) && P.CurrentAssociation != Guid.Empty) { Association association = reposetory.GetAssociation(P.CurrentAssociation); #if DUMMYTEXT ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance("NR.Infrastructure.DummyTextGateway", association == null ? null : association.TextServiceProviderUserName, association == null ? null : association.TextServiceProviderPassword); #else ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance(association.TextServiceProvider, association == null ? null : association.TextServiceProviderUserName, association == null ? null : association.TextServiceProviderPassword); #endif SMSGateway.FromText = General.SystemTextMessagesFrom; SMSGateway.Message = String.Format(General.SystemTextMessagesForgetLogin, P.UserName, P.Password); SMSGateway.Recipient = new List<Person> { P }; reposetory.NewTextMessage(SMSGateway, association.AssociationID); SMSGateway.HandShakeUrl = Url.Action("TextXStatus", "Account", new { ID = SMSGateway.TextId }, "http"); if (SMSGateway.Send()) { }; } } } ViewBag.LoginRetrived = true; return View("Login"); }
public ActionResult _TestEmail(string email) { if (!String.IsNullOrWhiteSpace(email)) { var mail = new ForgotLoginEmail { To = email, UserName = "******", Password = "******" }; try { mail.Send(); //throw new NullReferenceException(""); } catch (Exception ex) { return Content(ex.ToString()); } } return new HttpStatusCodeResult(HttpStatusCode.NoContent); }
public ActionResult SendLogin(Guid Id) { Person CU = reposetory.GetPersonComplete(Id); if (CU != null && !String.IsNullOrWhiteSpace(CU.Email)) { var mail = new ForgotLoginEmail { To = CU.Email, UserName = CU.UserName, Password = CU.Password }; mail.Send(); } if (Request.IsAjaxRequest()) { return Json(new { errorMessage = @General.MessageSendLogin }); } return RedirectToAction("Index"); }