Browse Source

password validation

feature/19315_Customer-Registration-new
Dinesh 12 months ago
parent
commit
411ffc3679
  1. 16
      CustomerOnlineV2/CustomerOnlineV2.Common/Models/RegisterModel/UserRegisterResponse.cs
  2. 3
      CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/RegisterRepository.cs
  3. 26
      CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs
  4. 135
      CustomerOnlineV2/CustomerOnlineV2/Views/Customer/CustomerRegistration.cshtml
  5. 62
      DB/PROC_DROPDOWN_LIST.sql

16
CustomerOnlineV2/CustomerOnlineV2.Common/Models/RegisterModel/UserRegisterResponse.cs

@ -5,6 +5,7 @@ using System.Net.Http.Headers;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace CustomerOnlineV2.Common.Models.RegisterModel
{
@ -34,9 +35,20 @@ namespace CustomerOnlineV2.Common.Models.RegisterModel
public class OnlineCustomerRegisterModel : CommonResponse
{
[Required(ErrorMessage = "Password required")]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at most {1} characters long.", MinimumLength = 6)]
public string Password { get; set; }
[Required]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
// public string customerPassword { get; set; }
public string? flag { get; set; }
public string? customerId { get; set; }
public string? password { get; set; }
//public string? password { get; set; }
public string? membershipId { get; set; }
public string? firstName { get; set; }
public string? middleName { get; set; }
@ -95,7 +107,7 @@ namespace CustomerOnlineV2.Common.Models.RegisterModel
public string? idIssueDate { get; set; }
public string? onlineUser { get; set; }
public string? mobileUser { get; set; }
public string? customerPassword { get; set; }
public string? customerStatus { get; set; }
public string? isActive { get; set; }
public string? islocked { get; set; }

3
CustomerOnlineV2/CustomerOnlineV2.Repository/Repository/RegisterRepository/RegisterRepository.cs

@ -28,7 +28,7 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
//sql += ", @user = " + _connHelper.FilterString(model.ReceiverId.());
sql += ",@country =" + _connHelper.FilterString(model.country);
sql += ",@password =" + _connHelper.FilterString(model.password);
sql += ",@password =" + _connHelper.FilterString(model.Password);
sql += ",@custEmail =" + _connHelper.FilterString(model.email);
//sql += ",@custEmail =" + _connHelper.FilterString(model.onlineUser);
sql += ",@firstName =" + _connHelper.FilterString(model.firstName);
@ -47,6 +47,7 @@ namespace CustomerOnlineV2.Repository.Repository.RegisterRepository
sql += ",@custDOB =" + _connHelper.FilterString(model.dob);
sql += ",@occupation =" + _connHelper.FilterString(model.occupation);
sql += ",@custNativecountry =" + _connHelper.FilterString(model.nativeCountry);
//sql += ",@CreatedFrom =" + _connHelper.FilterString("O");

26
CustomerOnlineV2/CustomerOnlineV2/Controllers/CustomerController.cs

@ -1,12 +1,16 @@
using CustomerOnlineV2.Api.API.TPApi;
using CustomerOnlineV2.Authorization;
using CustomerOnlineV2.Business.Business.RegisterBusiness;
using CustomerOnlineV2.Common.Models;
using CustomerOnlineV2.Common.Models.ReceiverModel;
using CustomerOnlineV2.Common.Models.RegisterModel;
using CustomerOnlineV2.Common.Models.TransactionModel;
using Microsoft.AspNetCore.Mvc;
using Microsoft.DotNet.Scaffolding.Shared.Messaging;
using Microsoft.Win32;
using Newtonsoft.Json;
using Serilog.Context;
using System.Reflection;
namespace CustomerOnlineV2.Controllers
{
@ -15,7 +19,7 @@ namespace CustomerOnlineV2.Controllers
private readonly IRegisterBusiness _registerBusiness;
private readonly ILogger<CustomerController> _logger;
private readonly ITPApiService _tpApiService;
public CustomerController(ILogger<CustomerController> logger, ITPApiService tpApiService , IRegisterBusiness registerBusiness)
{
_logger = logger;
@ -23,6 +27,8 @@ namespace CustomerOnlineV2.Controllers
_registerBusiness = registerBusiness;
}
//[BindProperty]
//public OnlineCustomerRegisterModel Input { get; set; }
///[Authorization("Customer")]
public IActionResult CustomerRegistration()
{
@ -33,11 +39,21 @@ namespace CustomerOnlineV2.Controllers
[HttpPost]
[Authorization("AddCustomer")]
[ValidateAntiForgeryToken]
public async Task<OnlineCustomerRegisterModel> AddCustomer(OnlineCustomerRegisterModel register)
public async Task<IActionResult> AddCustomer(OnlineCustomerRegisterModel register)
{
//var loginDetails = HttpContext.GetLoginDetails();
var register1 = await _registerBusiness.AddCustomers(register);
return register1;
if (!ModelState.IsValid)
{
var register1 = await _registerBusiness.AddCustomers(register);
return View("CustomerRegistation", register1);
}
//return register1;
//return register;
return RedirectToPage("Index");
//return RedirectToAction("Success");
}

135
CustomerOnlineV2/CustomerOnlineV2/Views/Customer/CustomerRegistration.cshtml

@ -27,12 +27,7 @@
</head>
<body>
<!-- Preloader -->
<div id="preloader">
<div data-loader="dual-ring"></div>
</div>
<!-- Preloader End -->
<!-- Document Wrapper -->
<div id="main-wrapper">
<header id="header">
@ -102,19 +97,35 @@
</div>
</div>
</div>
<div class="col-md-4">
<div class="mb-4">
<div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="Password" asp-for="password">
<label for="floatingPassword">Password</label>
<input type="password" class="form-control" asp-for="Password">
<span id="password-validation" class="text-danger"></span>
<label asp-for="Password"></label>
@*
<input type="password" class="form-control" asp:RegularExpressionValidator asp-for="Password" runat="server" ErrorMessage="Invalid Password Charecters"
ValidationExpression="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8}$" ControlToValidate="txtPassword" ForeColor="Red">
<span asp-validation-for="@Model.Password" class="error"></span> *@
</div>
</div>
</div>
<div class="col-md-4">
<div class="mb-4">
<div class="form-floating">
<input type="password" class="form-control" id="ConfirmPassword" placeholder="Password" asp-for="password">
<label for="ConfirmPassword">Re-Type Password</label>
<input type="password" class="form-control" asp-for="ConfirmPassword" >
<span id="confirm-password-validation" class="text-danger"></span>
<label asp-for="ConfirmPassword"></label>
@* <input type="password" class="form-control" asp:RegularExpressionValidator asp-for="ConfirmPassword" runat="server" ErrorMessage="Invalid Password Charecters"
ValidationExpression="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8}$" ControlToValidate="txtPassword" ForeColor="Red">
<span asp-validation-for="@Model.ConfirmPassword" class="error"></span>
<label for="ConfirmPassword">Re-Type Password</label> *@
</div>
</div>
</div>
@ -154,7 +165,8 @@
<div class="col-md-4">
<div class="mb-4">
<div class="form-floating">
<input type="password" class="form-control" id="floatingPassword" placeholder="Password" asp-for="password">
<input type="password" class="form-control" asp-for="Password">
<span id="confirm-password-validation" class="text-danger"></span>
<label for="floatingPassword">Password</label>
</div>
</div>
@ -475,27 +487,94 @@
</div>
</div>
</footer>
<!-- Content end -->
</div>
<!-- Content end -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="vendor/bootstrap-select/js/bootstrap-select.min.js"></script>
<script src="vendor/datepicker/datepicker.min.js"></script>
<script src="vendor/datepicker/datepicker.en.js"></script>
<!-- custom -->
<script src="js/script.js"></script>
<script type="text/javascript">
loadDatePicker();
</script>
<a id="back-to-top" data-bs-toggle="tooltip" title="Back to Top" href="javascript:void(0)"><i class="fa fa-chevron-up"></i></a>
<!-- Video Modal
============================================= -->
<div class="modal fade" id="videoModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content bg-transparent border-0">
<button type="button" class="btn-close btn-close-white ms-auto me-n3" data-bs-dismiss="modal" aria-label="Close"></button>
<div class="modal-body p-0">
<div class="ratio ratio-16x9">
<iframe id="video" src="" allow="autoplay;" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
</div>
<script src="~/vendor/jquery/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.5/dist/jquery.validate.js"></script>
<script src="~/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="~/vendor/bootstrap-select/js/bootstrap-select.min.js"></script>
<script src="~/vendor/owl.carousel/owl.carousel.min.js"></script>
<script src="~/js/script.js"></script>
<script src="~/vendor/toast-alert/izitoast.min.js"></script>
<script src="~/js/register-validation.js"></script>
<script type="text/javascript">
// $(document).ready(function () {
// $('#Customer-form').submit(function (e) {
// e.preventDefault(); // Prevent form submission for now
// validatePasswords();
// });
// $('#password, #confirmPassword').on('keyup', function () {
// validatePasswords();
// });
// function validatePasswords() {
// var password = $('#password').val();
// var confirmPassword = $('#confirmPassword').val();
// if (password !== confirmPassword) {
// $('#confirmPassword').get(0).setCustomValidity('Passwords do not match');
// } else {
// $('#confirmPassword').get(0).setCustomValidity('');
// }
// }
// });
$(document).ready(function () {
// Select the password and confirmPassword input fields
var passwordField = $("#Password");
var confirmPasswordField = $("#ConfirmPassword");
// Select the password and confirmPassword validation elements
var passwordValidation = $("#password-validation");
var confirmPasswordValidation = $("#confirm-password-validation");
// Password regex: Minimum 8 characters, at least one uppercase letter, one lowercase letter, and one number
var passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d@('@')$#!%*?&]{8,}$/;
// Add event handlers to the password and confirmPassword fields
passwordField.on("keyup", function () {
var password = passwordField.val();
if (passwordRegex.test(password)) {
passwordValidation.text("Valid password").css("color", "green");
} else {
passwordValidation.text("Invalid password").css("color", "red");
}
});
confirmPasswordField.on("keyup", function () {
var password = passwordField.val();
var confirmPassword = confirmPasswordField.val();
if (password === confirmPassword) {
confirmPasswordValidation.text("Passwords match").css("color", "green");
} else {
confirmPasswordValidation.text("Passwords do not match").css("color", "red");
}
});
});
(function () {
@ -532,6 +611,8 @@
let email = $('#email').val();
let country = $('#country').val();
let firstName = $('#firstName').val();
let Password = $('#Password').val();
let ConfirmPassword = $('#ConfirmPassword').val();
let middleName = $('#middleName').val();
let lastName1 = $('#lastName1').val();
let idType = $('#idType').val();
@ -542,7 +623,7 @@
let mobile = $('#mobile').val();
let telNo = $('#telNo').val();
let occupation = $('#occupation').val();
let password = $('#password').val();
let customerPassword = $('#customerPassword').val();
let address = $('#address').val();
@ -569,7 +650,9 @@
address: address,
idIssueDate: idIssueDate,
idExpiryDate: idExpiryDate,
password: password,
Password: Password,
ConfirmPassword: ConfirmPassword,
customerPassword: customerPassword,

62
DB/PROC_DROPDOWN_LIST.sql

@ -213,13 +213,67 @@ BEGIN TRY
HAVING MIN(X.maxLimitAmt) > 0
ORDER BY serviceTypeId ASC
END
ELSE IF @Flag ='allCountrylist'
ELSE IF @Flag ='allCountrylist'
BEGIN
select Id = @CountryId,text = UPPER(countryName)
FROM dbo.countryMaster (nolock)
order by ISNULL(isOperativeCountry,'N') DESC,countryName
--select Id = @CountryId,text = UPPER(countryName)
--FROM dbo.countryMaster (nolock)
--order by ISNULL(isOperativeCountry,'N') DESC,countryName
SELECT countryId AS [id] ,
countryName AS [text]
FROM countryMaster with (NOLOCK)
ORDER BY ISNULL(isOperativeCountry, 'N') Desc, countryName
END
IF @flag = 'getSourceOfFound'
BEGIN
--SOURCE OF FUND
SELECT
valueId AS [id]
,detailTitle AS [text]
FROM staticDataValue(NOLOCK)
WHERE TYPEID = 3900
--AND ISNULL(ISACTIVE, 'Y') = 'Y'
--AND ISNULL(IS_DELETE, 'N') = 'N'
END
ELSE IF @Flag ='getGender'
BEGIN
SELECT valueId AS [id]
,detailTitle AS [text]
FROM staticdatavalue WITH (NOLOCK)
WHERE typeid = 4
--AND ISNULL(ISActive, 'N') = 'Y'
AND ISNULL(IS_DELETE, 'N') = 'N'
ORDER BY [text] --Gender
end
ELSE IF @Flag ='getOccuptttion'
BEGIN
SELECT valueId AS [id]
,detailTitle AS [text]
FROM staticdatavalue WITH (NOLOCK)
WHERE typeid = 2000
AND ISNULL(ISActive, 'Y') = 'Y'
AND ISNULL(IS_DELETE, 'N') = 'N'
--occuptttion
END
ELSE IF @Flag ='getIdType'
BEGIN
SELECT detailTitle AS id,detailTitle AS text
FROM dbo.staticDataValue (NOLOCK)
WHERE typeID=1300
AND ISNULL(ISACTIVE, 'Y') = 'Y'
AND ISNULL(IS_DELETE, 'N') = 'N'
END
ELSE IF @flag = 'payoutMethods'
BEGIN
DECLARE @payoutMethods TABLE ([Key] INT,[Value] VARCHAR(50),DISORDER INT)

Loading…
Cancel
Save