This commit is contained in:
Mohaimen Hasan 2026-11-03 16:26:18 +06:00
parent 125d79ed75
commit df71ff1bec
4 changed files with 136 additions and 7 deletions

View File

@ -85,3 +85,98 @@
.login-cotrol {
color: black;
}
/* MFA / OTP verification — same column, colors and link style as the sign-in form */
.mfa-wrapper {
width: 300px;
margin: 0 auto;
}
@media screen and (min-width: 768px) {
.mfa-wrapper {
margin: 0;
}
}
.mfa-title {
display: flex;
align-items: center;
gap: 8px;
color: #ffffff;
font-size: 18px;
font-weight: bold;
margin-bottom: 8px;
}
.mfa-title .pi {
font-size: 18px;
}
.login-body .login-content .mfa-text {
color: rgb(177, 177, 177);
font-size: 14px;
font-weight: bolder;
line-height: 1.5;
margin: 0 0 20px 0;
}
.login-body .login-content .mfa-expired {
color: #ff8a80;
}
.mfa-otp-boxes {
display: flex;
justify-content: space-between;
margin-bottom: 16px;
}
.mfa-otp-box {
width: 42px;
height: 48px;
border: 1px solid #c4c4c4;
border-radius: 4px;
background: #ffffff;
color: black;
font-size: 20px;
font-weight: 600;
text-align: center;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
}
.mfa-otp-box:focus {
border-color: #52527A;
box-shadow: 0 0 0 2px rgba(82, 82, 122, 0.45);
}
.mfa-timer {
display: flex;
align-items: center;
gap: 6px;
color: rgb(177, 177, 177);
font-size: 13px;
margin-bottom: 20px;
}
.mfa-timer-value {
color: #ffffff;
font-weight: bold;
}
.mfa-link {
color: rgb(177, 177, 177);
cursor: pointer;
}
.mfa-link:hover {
color: #ffffff;
}
.mfa-back {
margin-top: 20px;
font-size: 13px;
}
.mfa-back .pi {
font-size: 11px;
}

View File

@ -12,7 +12,7 @@
<body class="login-body">
<app-loading-panel></app-loading-panel>
<div class="login-panel"></div>
@if (!apiService.isSSO) {
@if (!apiService.isSSO && !showMfaModal) {
<div class="login-content" style="margin-top: 100px;">
<img src="assets/layout/images/banner.png" alt="Banner" [style.width]="bannerWidth" [style.height]="bannerHeight"/>
<p style="color: rgb(177, 177, 177); font-weight: bolder;">Welcome, please use the form to sign-in.</p>
@ -44,6 +44,43 @@
</form>
</div>
}
@if (showMfaModal) {
<div class="login-content" style="margin-top: 100px;">
<img src="assets/layout/images/banner.png" alt="Banner" [style.width]="bannerWidth" [style.height]="bannerHeight"/>
<div class="mfa-wrapper">
<div class="mfa-title">
<i class="pi pi-shield"></i>
<span>Verify Your Identity</span>
</div>
@if (!isResend) {
<p class="mfa-text">We've sent a 6-digit verification code to your Email / Mobile. Please enter it below.</p>
<div class="mfa-otp-boxes">
@for (i of otpIndexes; track i) {
<input #otpBox type="text" inputmode="numeric" pattern="[0-9]*" maxlength="1"
class="mfa-otp-box" autocomplete="one-time-code"
(input)="onOtpInput($event, i)"
(keydown)="onOtpKeydown($event, i)"
(paste)="onOtpPaste($event)" />
}
</div>
<div class="mfa-timer">
<i class="pi pi-clock"></i>
<span>Code expires in</span>
<span class="mfa-timer-value">{{ timerValue }}</span>
</div>
<button kendoButton themeColor="primary" type="button" (click)="validateOTP()">Verify</button>
<a class="mfa-link" style="margin-left: 20px;" (click)="reSendOTP()">Resend Code</a>
} @else {
<p class="mfa-text mfa-expired">Your code has expired. Please resend a new one.</p>
<button kendoButton themeColor="primary" type="button" (click)="reSendOTP()">Resend Code</button>
}
<div class="mfa-back">
<a class="mfa-link" (click)="onPopUpOTPClose()"><i class="pi pi-arrow-left"></i> Back to Sign In</a>
</div>
<p style="margin-top:15px; font-size:12px;">Version: {{ appVersion }}</p>
</div>
</div>
}
@if (showModal) {
<kendo-dialog class="blur-background" (close)="onPopUpClose()" [minWidth]="390">
<kendo-dialog-titlebar>

View File

@ -395,11 +395,11 @@ export class LoginComponent implements OnInit {
}
validateOTP(){
if(this.secondsLeft > 0 && this.secondsLeft < 120){
this.loadingPanel.ShowLoadingPanel = true;
if(this.mfaCode === undefined || this.mfaCode === null || this.mfaCode.trim() === ''){
this.notificationService.showError('Please enter the MFA Code');
return;
}
this.loadingPanel.ShowLoadingPanel = true;
let params = {
mfaSessionId : ApiService.AuthenticationMFASessionID,
mfaCode : this.mfaCode

View File

@ -465,7 +465,7 @@ namespace HRM.UI.Controllers
};
claims.AddRange(roles.Select(role => new Claim(ClaimTypes.Role, role)));
var key = Encoding.ASCII.GetBytes(_jwt.Secret);
var key = Ease.Core.Utility.JwtSigningKey.FromSecret(this.Secret);
var token = new JwtSecurityToken(
issuer: _jwt.Issuer,
audience: _jwt.Audience,
@ -491,10 +491,7 @@ namespace HRM.UI.Controllers
audience: "abc",
claims: claims,
expires: DateTime.UtcNow.AddMinutes(_jwt.TokenLifetimeMinutes),
signingCredentials: new SigningCredentials(
new SymmetricSecurityKey(rtkey),
SecurityAlgorithms.HmacSha256
)
signingCredentials: new SigningCredentials(new SymmetricSecurityKey(rtkey),SecurityAlgorithms.HmacSha256)
);
string newuserToken = new JwtSecurityTokenHandler().WriteToken(rttoken);
return newuserToken;