You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
217 lines
9.0 KiB
217 lines
9.0 KiB
using Common.Utility;
|
|
using Newtonsoft.Json;
|
|
using Swift.API;
|
|
using Swift.API.Common;
|
|
using Swift.API.Common.Enum;
|
|
using Swift.API.Common.Helper;
|
|
using Swift.API.TPAPIs;
|
|
using Swift.DAL.OnlineAgent;
|
|
using Swift.DAL.SwiftDAL;
|
|
using Swift.web.Library;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Web.Helpers;
|
|
using DbResult = Swift.DAL.SwiftDAL.DbResult;
|
|
|
|
namespace Swift.web.AgentPanel.ResetPassword
|
|
{
|
|
public partial class ResetPassword : System.Web.UI.Page
|
|
{
|
|
private const string ViewFunctionId = "30111900";
|
|
private readonly RemittanceLibrary swiftLibrary = new RemittanceLibrary();
|
|
private readonly OnlineCustomerDao _cd = new OnlineCustomerDao();
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
swiftLibrary.CheckSession();
|
|
Authenticate();
|
|
if (!IsPostBack)
|
|
{
|
|
antiForgery.InnerHtml = AntiForgery.GetHtml().ToString();
|
|
}
|
|
}
|
|
private void Authenticate()
|
|
{
|
|
swiftLibrary.CheckAuthentication(ViewFunctionId);
|
|
}
|
|
protected void changePass_Click(object sender, EventArgs e)
|
|
{
|
|
if (IsPostBack)
|
|
{
|
|
AntiForgery.Validate();
|
|
}
|
|
DbResult _res = new DbResult();
|
|
CheckPasswordUtility _checkPass = new CheckPasswordUtility();
|
|
|
|
//var pwd = GeneratePassword(Convert.ToInt16(GetStatic.ReadWebConfig("passwordLength","9")));
|
|
|
|
_res = _cd.AutoSetPassword(GetStatic.GetUser(), txtEmail.Value);
|
|
if (_res.ErrorCode == "0")
|
|
{
|
|
GetStatic.CallBackJs1(this, "Success", "ShowMsg('" + _res.Msg + "');");
|
|
}
|
|
else
|
|
{
|
|
GetStatic.CallBackJs1(this, "Success", "ShowMsg('" + _res.Msg + "');");
|
|
}
|
|
}
|
|
|
|
protected void reset_click(object sender, EventArgs e)
|
|
{
|
|
if (IsPostBack)
|
|
{
|
|
AntiForgery.Validate();
|
|
}
|
|
DbResult _res = new DbResult();
|
|
CheckPasswordUtility _checkPass = new CheckPasswordUtility();
|
|
//var pwd = GeneratePassword(Convert.ToInt16(GetStatic.ReadWebConfig("passwordLength","9")));
|
|
|
|
var resetpassword = rbResetPassword.SelectedValue.ToString();
|
|
|
|
if (txtEmail.Value == "")
|
|
{
|
|
GetStatic.AlertMessage(this, "Please insert customer to proceed.");
|
|
rbResetPassword.SelectedIndex = -1;
|
|
}
|
|
if (resetpassword == "Pin")
|
|
{
|
|
JsonResponse _respin = _cd.ResetPinMobile(new PasswordReset()
|
|
{
|
|
CustomerId = txtEmail.Value,
|
|
User = GetStatic.GetUser()
|
|
});
|
|
if (_respin.ResponseCode == "0")
|
|
{
|
|
if (_respin.Id.IsValidEmail())
|
|
{
|
|
List<Mapping> bodyMappings = new List<Mapping>();
|
|
|
|
bodyMappings.Add(new Mapping() { SValue = "CustomerName", SText = _respin.Extra2 });
|
|
bodyMappings.Add(new Mapping() { SValue = "Pin", SText = _respin.Extra });
|
|
|
|
SendNotificationRequestMobile request = new SendNotificationRequestMobile()
|
|
{
|
|
IsBulkNotification = false,
|
|
UserName = _respin.Id,
|
|
ProcessId = "RESET",
|
|
ProviderId = NotifyTemplate.FORCE_PIN_CHANGE.ToString(),
|
|
NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
|
|
Template = NotifyTemplate.FORCE_PIN_CHANGE,
|
|
Recipients = new List<RecipientViewModel>()
|
|
{
|
|
new RecipientViewModel()
|
|
{
|
|
NotificationContent = new NotificationDTO() {
|
|
Body = JsonConvert.SerializeObject(bodyMappings),
|
|
//Title will be set by mapping json
|
|
},
|
|
Address= _respin.Id
|
|
}
|
|
}
|
|
};
|
|
|
|
_respin = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
|
|
txtEmail.Text = "";
|
|
txtEmail.Value = "";
|
|
rbResetPassword.SelectedIndex = -1;
|
|
if (_respin.ResponseCode == "0")
|
|
GetStatic.AlertMessage(this, "Pin sent to Customer's Email Successfully");
|
|
else
|
|
GetStatic.AlertMessage(this, "Reset pin error. " + _respin.Msg);
|
|
}
|
|
else
|
|
{
|
|
_respin.ResponseCode = "1";
|
|
_respin.Msg = "Email is not valid.";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
txtEmail.Text = "";
|
|
txtEmail.Value = "";
|
|
GetStatic.AlertMessage(this, _respin.Msg);
|
|
rbResetPassword.SelectedIndex = -1;
|
|
}
|
|
}
|
|
|
|
// _res = _cd.AutoSetPassword(GetStatic.GetUser(), txtEmail.Value);
|
|
else if (resetpassword == "Password")
|
|
{
|
|
PasswordReset pwdReset = new PasswordReset();
|
|
var randomPassword = PasswordGenerator.GenerateRandomPassword();
|
|
pwdReset.RandomPassword = randomPassword;
|
|
JsonResponse _resp = _cd.ResetPasswordMobile(new PasswordReset()
|
|
{
|
|
CustomerId = txtEmail.Value,
|
|
RandomPassword = randomPassword,
|
|
User = GetStatic.GetUser()
|
|
}); ;
|
|
if (_resp.ResponseCode == "0")
|
|
{
|
|
if (_resp.Id.IsValidEmail())
|
|
{
|
|
List<Mapping> bodyMappings = new List<Mapping>();
|
|
|
|
bodyMappings.Add(new Mapping() { SValue = "CustomerName", SText = _resp.Extra2 });
|
|
bodyMappings.Add(new Mapping() { SValue = "Password", SText = randomPassword });
|
|
|
|
SendNotificationRequestMobile request = new SendNotificationRequestMobile()
|
|
{
|
|
IsBulkNotification = false,
|
|
UserName = _resp.Id,
|
|
ProcessId = "RESET",
|
|
ProviderId = NotifyTemplate.FORCE_PASSWORD_CHANGE.ToString(),
|
|
NotificationTypeId = NOTIFICATION_TYPE.EMAIL.ToString(),
|
|
Template = NotifyTemplate.FORCE_PASSWORD_CHANGE,
|
|
Recipients = new List<RecipientViewModel>()
|
|
{
|
|
new RecipientViewModel()
|
|
{
|
|
NotificationContent = new NotificationDTO() {
|
|
Body = JsonConvert.SerializeObject(bodyMappings),
|
|
//Title will be set by mapping json
|
|
},
|
|
Address= _resp.Id
|
|
}
|
|
}
|
|
};
|
|
|
|
_resp = NotifierV2.SendNotification(request, NOTIFICATION_TYPE.EMAIL);
|
|
txtEmail.Text = "";
|
|
txtEmail.Value = "";
|
|
rbResetPassword.SelectedIndex = -1;
|
|
if (_resp.ResponseCode == "0")
|
|
GetStatic.AlertMessage(this, "Password sent to Customer's Email Successfully");
|
|
else
|
|
GetStatic.AlertMessage(this, "Reset Password error. " + _resp.Msg);
|
|
}
|
|
else
|
|
{
|
|
_resp.ResponseCode = "1";
|
|
_resp.Msg = "Email is not valid.";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
txtEmail.Text = "";
|
|
txtEmail.Value = "";
|
|
GetStatic.AlertMessage(this, "Please Select any one option for reset.");
|
|
rbResetPassword.SelectedIndex = -1;
|
|
}
|
|
}
|
|
|
|
//public static string GeneratePassword(int length)
|
|
//{
|
|
// Random random = new Random();
|
|
// string characters = "123456789ABCDEFGHKMNPQRSTUVWXYZabcdefghkmnpqrstuvwxyz@#$&*?";
|
|
// StringBuilder result = new StringBuilder(length);
|
|
// for (int i = 0; i < length; i++)
|
|
// {
|
|
// result.Append(characters[random.Next(characters.Length)]);
|
|
// }
|
|
// return result.ToString();
|
|
//}
|
|
}
|
|
}
|