user password reset url changed + twilio settings moved to system settings
This commit is contained in:
parent
eb59ecf9c1
commit
6fbc5bd2f9
13 changed files with 244 additions and 50 deletions
|
@ -5,6 +5,7 @@ using System.Web.Mvc;
|
|||
using System.Web.Routing;
|
||||
using AutoMapper;
|
||||
using log4net;
|
||||
using Microsoft.Web.Services3.Addressing;
|
||||
using WebsitePanel.Providers.HostedSolution;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Security.Authentication;
|
||||
|
@ -186,7 +187,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
return View(model);
|
||||
}
|
||||
|
||||
WspContext.Services.Organizations.SendResetUserPasswordEmail(exchangeAccount.ItemId, exchangeAccount.AccountId, Resources.Messages.PasswordResetUserReason, exchangeAccount.PrimaryEmailAddress);
|
||||
WspContext.Services.Organizations.SendResetUserPasswordEmail(exchangeAccount.ItemId, exchangeAccount.AccountId, Resources.Messages.PasswordResetUserReason, exchangeAccount.PrimaryEmailAddress, false);
|
||||
|
||||
return View("PasswordResetEmailSent");
|
||||
}
|
||||
|
@ -257,15 +258,16 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public ActionResult PasswordResetFinalStep(Guid token)
|
||||
public ActionResult PasswordResetFinalStep(Guid token, string pincode)
|
||||
{
|
||||
var smsResponse = Session[WebDavAppConfigManager.Instance.SessionKeys.PasswordResetSmsKey] as string;
|
||||
var result = VerifyPincode(token, pincode);
|
||||
|
||||
if (_smsAuthService.VerifyResponse(token, smsResponse) == false)
|
||||
if (result != null)
|
||||
{
|
||||
return RedirectToRoute(AccountRouteNames.PasswordResetSms);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
var model = new PasswordEditor();
|
||||
|
||||
return View(model);
|
||||
|
@ -273,20 +275,18 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public ActionResult PasswordResetFinalStep(Guid token, PasswordEditor model)
|
||||
public ActionResult PasswordResetFinalStep(Guid token, string pincode, PasswordEditor model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View(model);
|
||||
}
|
||||
|
||||
var smsResponse = Session[WebDavAppConfigManager.Instance.SessionKeys.PasswordResetSmsKey] as string;
|
||||
var result = VerifyPincode(token, pincode);
|
||||
|
||||
if (_smsAuthService.VerifyResponse(token, smsResponse) == false)
|
||||
if (result != null)
|
||||
{
|
||||
AddMessage(MessageType.Error, Resources.Messages.IncorrectSmsResponse);
|
||||
|
||||
return RedirectToRoute(AccountRouteNames.PasswordResetSms);
|
||||
return result;
|
||||
}
|
||||
|
||||
var tokenEntity = WspContext.Services.Organizations.GetPasswordresetAccessToken(token);
|
||||
|
@ -333,6 +333,34 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
|
||||
#region Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Verify pincode, if it's absent - verifying pincode from session
|
||||
/// </summary>
|
||||
/// <param name="token">Password reset token</param>
|
||||
/// <param name="pincode">Pincode to verify if session pincode is absent</param>
|
||||
private ActionResult VerifyPincode(Guid token, string pincode)
|
||||
{
|
||||
var smsResponse = Session[WebDavAppConfigManager.Instance.SessionKeys.PasswordResetSmsKey] as string;
|
||||
|
||||
if (string.IsNullOrEmpty(pincode) == false)
|
||||
{
|
||||
smsResponse = pincode;
|
||||
}
|
||||
|
||||
if (_smsAuthService.VerifyResponse(token, smsResponse) == false)
|
||||
{
|
||||
AddMessage(MessageType.Error, Resources.Messages.IncorrectSmsResponse);
|
||||
|
||||
return RedirectToRoute(AccountRouteNames.PasswordResetSms);
|
||||
}
|
||||
|
||||
var tokenEntity = WspContext.Services.Organizations.GetPasswordresetAccessToken(token);
|
||||
|
||||
Session[WebDavAppConfigManager.Instance.SessionKeys.ItemId] = tokenEntity.ItemId;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private UserProfile GetUserProfileModel(int itemId, int accountId)
|
||||
{
|
||||
var user = WspContext.Services.Organizations.GetUserGeneralSettingsWithExtraData(itemId, accountId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue