public async Task <IHttpActionResult> ResetPassword(ForgotPasswordViewModel model) { var user = await UserManager.FindByNameAsync(model.Email); if (user == null) { return(Ok <dynamic>(new { IsSuccess = 1, Status = 200, Message = "The User is not Registered!" })); } RepositoryBusinessProfiles repositoryBusiness = new RepositoryBusinessProfiles(); var businessModel = repositoryBusiness.GetBusinessProfileById(user.BusinessId.Value); var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var baseUrl = ConfigurationManager.AppSettings["PortalUrl"]; // if (!model.IsBusinessLogin) // { // var callbackUrl = Url.Route("ConfirmChangePassword", "Account", new { userId = user.Id, code = code, IsBusinessLogin = model.IsBusinessLogin }, protocol: "https"); //var callbackUrl = Url.Route("ConfirmChangePassword", new { controller = "Account", userId = user.Id, code = code, IsBusinessLogin = model.IsBusinessLogin }); var callbackUrl = string.Format("{0}/Account/ConfirmChangePassword?userId={1}&code={2}&IsBusinessLogin={3}", baseUrl, user.Id, code, model.IsBusinessLogin); callbackUrl = callbackUrl.Replace(":8080", ""); var emailBody = TemplateManager.Forgotpassword(ConfigurationManager.AppSettings["PortalUri"], callbackUrl, user.BusinessId.Value, businessModel.Model.BusinessName.ToLower()); await UserManager.SendEmailAsync(user.Id, "Change Password", emailBody); return(Ok <dynamic>(new { IsSuccess = 1, Status = 200, Message = "Success!" })); //ViewBag.Link = callbackUrl; //return View("UserVerification"); // } }
public async Task <ActionResult> ChangePassword() { try { ForgotPasswordViewModel model = (ForgotPasswordViewModel)TempData["ForgotPasswordViewModel"]; var user = await UserManager.FindByNameAsync(model.Email); if (user == null) { // Don't reveal that the user does not exist or is not confirmed if (model.IsBusinessLogin) { var returnurl = "/" + model.BusinessName.Replace(" ", "-") + "/BusinessUserVerification"; return(RedirectToLocal(returnurl)); //return RedirectToAction("BusinessUserVerification"); } return(View("UserVerification")); } else { } Session.Clear(); AuthenticationManager.SignOut(); var code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var rootPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath; if (model.IsBusinessLogin) { var route = "/" + model.BusinessName.Replace(" ", "-") + "/BusinessUserConfirmation"; var callbackUrl = Url.RouteUrl("BusinessUserConfirmation", new { businessname = model.BusinessName.Replace(" ", "-"), userId = user.Id, code = code, IsBusinessLogin = model.IsBusinessLogin, bizid = model.bizId }, protocol: "https"); callbackUrl = callbackUrl.Replace(":8080", ""); var emailBody = TemplateManager.Forgotpassword(rootPath, callbackUrl, user.BusinessId.Value, model.BusinessName); await UserManager.SendEmailAsync(user.Id, "Change Password", emailBody); ViewBag.Link = callbackUrl; var returnurl = "/" + model.BusinessName.Replace(" ", "-") + "/BusinessUserVerification"; return(RedirectToLocal(returnurl)); } else { RepositoryBusinessProfiles repositoryBusiness = new RepositoryBusinessProfiles(); var businessModel = repositoryBusiness.GetBusinessProfileById(user.BusinessId.Value); var callbackUrl = Url.Action("ConfirmChangePassword", "Account", new { userId = user.Id, code = code, IsBusinessLogin = model.IsBusinessLogin }, protocol: "https"); callbackUrl = callbackUrl.Replace(":8080", ""); var emailBody = TemplateManager.Forgotpassword(rootPath, callbackUrl, user.BusinessId.Value, businessModel.Model.BusinessName.ToLower()); await UserManager.SendEmailAsync(user.Id, "Change Password", emailBody); ViewBag.Link = callbackUrl; return(View("UserVerification")); } // If we got this far, something failed, redisplay form } catch (Exception ex) { ex.Log(); } return(View("Login")); }
public IHttpActionResult GetBusinessProfile() { var response = new DataResponse <EntityBusinessProfile>(); if (CurrentBusinessId.HasValue) { response = repository.GetBusinessProfileById(CurrentBusinessId.Value); } else { response.Model = new EntityBusinessProfile(); } return(Ok <DataResponse>(response)); }