diff --git a/HRM.UI/ClientApp/src/app/login.component.css b/HRM.UI/ClientApp/src/app/login.component.css index 69d7fc4..e4ce42f 100644 --- a/HRM.UI/ClientApp/src/app/login.component.css +++ b/HRM.UI/ClientApp/src/app/login.component.css @@ -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; +} diff --git a/HRM.UI/ClientApp/src/app/login.component.html b/HRM.UI/ClientApp/src/app/login.component.html index 3b63dbd..c341e97 100644 --- a/HRM.UI/ClientApp/src/app/login.component.html +++ b/HRM.UI/ClientApp/src/app/login.component.html @@ -12,7 +12,7 @@
- @if (!apiService.isSSO) { + @if (!apiService.isSSO && !showMfaModal) {
Banner

Welcome, please use the form to sign-in.

@@ -44,6 +44,43 @@
} + @if (showMfaModal) { +
+ Banner +
+
+ + Verify Your Identity +
+ @if (!isResend) { +

We've sent a 6-digit verification code to your Email / Mobile. Please enter it below.

+
+ @for (i of otpIndexes; track i) { + + } +
+
+ + Code expires in + {{ timerValue }} +
+ + Resend Code + } @else { +

Your code has expired. Please resend a new one.

+ + } + +

Version: {{ appVersion }}

+
+
+ } @if (showModal) { diff --git a/HRM.UI/ClientApp/src/app/login.component.ts b/HRM.UI/ClientApp/src/app/login.component.ts index d7a47cb..1b78686 100644 --- a/HRM.UI/ClientApp/src/app/login.component.ts +++ b/HRM.UI/ClientApp/src/app/login.component.ts @@ -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 diff --git a/HRM.UI/Controllers/Auth/AuthController.cs b/HRM.UI/Controllers/Auth/AuthController.cs index 356163b..3249940 100644 --- a/HRM.UI/Controllers/Auth/AuthController.cs +++ b/HRM.UI/Controllers/Auth/AuthController.cs @@ -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;