From cd272fb61c1403744648308b12dd46acf8a49646 Mon Sep 17 00:00:00 2001 From: shakun Date: Wed, 4 Oct 2023 15:18:56 +0545 Subject: [PATCH] Merge branch 'feature/19315_Customer-Registration' into feature/19315_Customer-Registration-new # Conflicts: # CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs # CustomerOnlineV2/CustomerOnlineV2/Views/Customer/CustomerRegistration.cshtml --- .../AccountBusiness/AccountBusiness.cs | 4 + .../AccountBusiness/IAccountBusiness.cs | 2 +- .../Models/AccountModel/AccountModel.cs | 11 +- .../AccountRepository/AccountRepository.cs | 23 ++++ .../AccountRepository/IAccountRepository.cs | 1 + .../Controllers/AccountController.cs | 37 ++++++ .../Views/Account/Index.cshtml | 2 +- .../Views/Account/ResetPassword.cshtml | 120 ++++++++++++++++++ .../Views/ReceiverInformation/Receiver.cshtml | 48 ++++--- 9 files changed, 229 insertions(+), 19 deletions(-) create mode 100644 CustomerOnlineV2/CustomerOnlineV2/Views/Account/ResetPassword.cshtml diff --git a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/AccountBusiness.cs b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/AccountBusiness.cs index 66c4718..f57a876 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/AccountBusiness.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/AccountBusiness.cs @@ -30,5 +30,9 @@ namespace CustomerOnlineV2.Business.Business.AccountBusiness return await _accountRepo.ChangePassword(model, logindetails); } + public async Task PasswordReset(PasswordResetModel model, LoginResponse logindetails) + { + return await _accountRepo.PasswordReset(model, logindetails); + } } } diff --git a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/IAccountBusiness.cs b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/IAccountBusiness.cs index 430d1d9..e8f9f61 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/IAccountBusiness.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Business/Business/AccountBusiness/IAccountBusiness.cs @@ -7,6 +7,6 @@ namespace CustomerOnlineV2.Business.Business.AccountBusiness { Task Login(LoginModel model); Task ChangePassword(ForceChangePasswordModel model, LoginResponse logindetails); - //Task PasswordReset(PasswordResetModel model, LoginResponse logindetails); + Task PasswordReset(PasswordResetModel model, LoginResponse logindetails); } } diff --git a/CustomerOnlineV2/CustomerOnlineV2.Common/Models/AccountModel/AccountModel.cs b/CustomerOnlineV2/CustomerOnlineV2.Common/Models/AccountModel/AccountModel.cs index 33dea15..f92ae68 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Common/Models/AccountModel/AccountModel.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Common/Models/AccountModel/AccountModel.cs @@ -1,4 +1,6 @@ -namespace CustomerOnlineV2.Common.Models.AccountModel +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; +namespace CustomerOnlineV2.Common.Models.AccountModel { public class AccountModel { @@ -20,6 +22,13 @@ public string? ConfirmNewPassword { get; set; } public string? IpAddress { get; set; } } + public class PasswordResetModel + { + public string? Username { get; set; } + public string? Dob { get; set; } + public string? IpAddress { get; set; } + public string? RandomPassword { get; set; } + } public class LoginResponse : CommonResponse { diff --git a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/AccountRepository.cs b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/AccountRepository.cs index 8e5b872..8a2b7b6 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/AccountRepository.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/AccountRepository.cs @@ -92,5 +92,28 @@ namespace CustomerOnlineV2.Repository.Repository.AccountRepository } return await Task.FromResult(_response); } + public async Task PasswordReset(PasswordResetModel model, LoginResponse logindetails) + { + CommonResponse _response = new CommonResponse(); + try + { + var sql = "EXEC PROC_DYNAMIC_TABLE"; + sql += " @Flag = " + _connHelper.FilterString("ForceChange"); + sql += ",@UserEmail = " + _connHelper.FilterString(logindetails.UserName); + + sql += ",@ipAddress = " + _connHelper.FilterString(model.IpAddress); + + _logger.LogDebug("ACCOUNTREPOSITORY | CHANGEPASSWORD | SQL | " + sql); + return _connHelper.ParseDbResult(sql); + } + catch (Exception ex) + { + _response.ResponseCode = ResponseHelper.EXCEPTION; + _response.ResponseMessage = "Exception occured: " + ex.Message; + + _logger.LogError("ACCOUNTREPOSITORY | LOGIN | EXCEPTION | " + JsonConvert.SerializeObject(_response)); + } + return await Task.FromResult(_response); + } } } diff --git a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/IAccountRepository.cs b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/IAccountRepository.cs index 8ceef6f..bc994b3 100644 --- a/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/IAccountRepository.cs +++ b/CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/AccountRepository/IAccountRepository.cs @@ -7,5 +7,6 @@ namespace CustomerOnlineV2.Repository.Repository.AccountRepository { Task ChangePassword(ForceChangePasswordModel model, LoginResponse logindetails); Task Login(LoginModel model); + Task PasswordReset(PasswordResetModel model, LoginResponse logindetails); } } diff --git a/CustomerOnlineV2/CustomerOnlineV2/Controllers/AccountController.cs b/CustomerOnlineV2/CustomerOnlineV2/Controllers/AccountController.cs index fd55a70..120f5ba 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Controllers/AccountController.cs +++ b/CustomerOnlineV2/CustomerOnlineV2/Controllers/AccountController.cs @@ -147,5 +147,42 @@ namespace CustomerOnlineV2.Controllers } } } + public async Task ResetPassword() + { + return View(); + } + + [HttpPost] + [ValidateAntiForgeryToken] + public async Task ResetPassword(PasswordResetModel model) + { + var logindetails = HttpContext.GetLoginDetails(); + model.IpAddress = Utilities.GetIpAddressv2(HttpContext); + using (LogContext.PushProperty("DebugId", logindetails.UserName)) + { + _logger.LogDebug("ACCOUNTCONTROLLER | FORCECHANGEPASSWORD | REQUEST | " + JsonConvert.SerializeObject(model)); + if (string.IsNullOrEmpty(logindetails.UserName)) + { + _logger.LogError("ACCOUNTCONTROLLER | FORCECHANGEPASSWORD | INVALID logindetails.UserName"); + RedirectToAction("Index", "Account"); + } + + var response = await _accountBusiness.PasswordReset(model, logindetails); + Log.Debug("Change password response: " + JsonConvert.SerializeObject(response)); + if (response.ResponseCode == ResponseHelper.SUCCESS) + { + Log.Debug("ACCOUNTCONTROLLER | CHANGEPASSWORD | REQUEST ARRIVED | " + logindetails.UserName); + HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); + return RedirectToAction("Index", "Account"); + } + else + { + ViewBag.ResponseCode = response.ResponseCode; + ViewBag.ResponseMessage = response.ResponseMessage; + _logger.LogError("ACCOUNTCONTROLLER | LOGIN | ERROR OCCURED | " + JsonConvert.SerializeObject(response)); + return View(); + } + } + } } } diff --git a/CustomerOnlineV2/CustomerOnlineV2/Views/Account/Index.cshtml b/CustomerOnlineV2/CustomerOnlineV2/Views/Account/Index.cshtml index 3387e22..5de4cae 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Views/Account/Index.cshtml +++ b/CustomerOnlineV2/CustomerOnlineV2/Views/Account/Index.cshtml @@ -97,7 +97,7 @@ - +
Don't have an user ?
Registration won't take more than 5 min, Register Now
diff --git a/CustomerOnlineV2/CustomerOnlineV2/Views/Account/ResetPassword.cshtml b/CustomerOnlineV2/CustomerOnlineV2/Views/Account/ResetPassword.cshtml new file mode 100644 index 0000000..e891b75 --- /dev/null +++ b/CustomerOnlineV2/CustomerOnlineV2/Views/Account/ResetPassword.cshtml @@ -0,0 +1,120 @@ +@model CustomerOnlineV2.Common.Models.AccountModel.PasswordResetModel +@{ + Layout = "_Layout2"; +} + + + + +
+ +
+ +
+
+
+
+
+
+

Forgot Password

+
Reset passowrd is simple, your can reset your password right away
+

+
+
+ @* *@
+ + +
+ +
+
+ @* *@ + + +
+
+
+ +
Dont have username ? Registration won't take more than 5 min, Register Now
+
Already registered, Login Now
+ +
+ +
+
+
+
+ + Email Address + info@imelondon.co.uk +
+
+ + Contact Numbers + +44 02088660307 + +44 07984713677 +
+
+ + Our Head Office + Pentax House, South Hill Avenue, South Harrow, London, HA2 0DU +
+
+
+
+
+
+ + + + + +
+
+ + + \ No newline at end of file diff --git a/CustomerOnlineV2/CustomerOnlineV2/Views/ReceiverInformation/Receiver.cshtml b/CustomerOnlineV2/CustomerOnlineV2/Views/ReceiverInformation/Receiver.cshtml index b8d498a..3cc78d6 100644 --- a/CustomerOnlineV2/CustomerOnlineV2/Views/ReceiverInformation/Receiver.cshtml +++ b/CustomerOnlineV2/CustomerOnlineV2/Views/ReceiverInformation/Receiver.cshtml @@ -3,7 +3,13 @@ @{ Layout = "_Layout2"; } - +
@@ -100,7 +106,7 @@
- +
@@ -116,8 +122,8 @@ @* *@ @@ -142,7 +148,7 @@
- +
@@ -174,7 +180,7 @@
- @@ -294,18 +300,28 @@ // $(document).ready(function () { - // debugger; - // $('#Country').change(function () { - // if ($(this).val() == '' { - // PopulateDDL('paymentMode', 'payoutMethods', $(this).val(), true, ''); - // PopulateDDL('bankName', 'bankList', $(this).val(), true, ''); - // } - // else { - // $('#paymentMode').empty(); - // $('#bankName').empty(); + // // debugger; + // // $('#Country').change(function () { + // // if ($(this).val() == '' { + // // PopulateDDL('paymentMode', 'payoutMethods', $(this).val(), true, ''); + // // PopulateDDL('bankName', 'bankList', $(this).val(), true, ''); + // // } + // // else { + // // $('#paymentMode').empty(); + // // $('#bankName').empty(); + // // } + // // }); + + + // $('#paymentMode').change(function () { + + // if ($(this).val() == '2' { + // $('#bankName').attr("bankName", "required -control"); // } + // }); - // }); + // } +