feat: implement logout functionality and enhance contact layout
This commit is contained in:
@@ -25,6 +25,7 @@ export class AuthService {
|
||||
router = inject(Router);
|
||||
|
||||
private readonly storageKey = 'accessToken';
|
||||
tokenReady$ = new BehaviorSubject<boolean | null>(null);
|
||||
|
||||
constructor() {
|
||||
console.log('🔥 AuthService constructor started');
|
||||
@@ -36,31 +37,31 @@ export class AuthService {
|
||||
return `${this.baseUrl}${path.startsWith('/') ? '' : '/'}${path}`;
|
||||
}
|
||||
|
||||
// // Call on app start, or from guard
|
||||
// async ensureTokenReady(): Promise<void>{
|
||||
// if(this.tokenReady$.value) return;
|
||||
// Call on app start, or from guard
|
||||
async ensureTokenReady(): Promise<void>{
|
||||
if(this.tokenReady$.value) return;
|
||||
|
||||
// const stored = this.safeGetToken();
|
||||
const stored = this.safeGetToken();
|
||||
|
||||
// // try to restore from storage
|
||||
// if(stored){
|
||||
// this.accessTokenSub.next(stored);
|
||||
// this.tokenReady$.next(true);
|
||||
// return;
|
||||
// }
|
||||
// try to restore from storage
|
||||
if(stored){
|
||||
this.accessTokenSub.next(stored);
|
||||
this.tokenReady$.next(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// // // Optionally: try a silent refresh on startup to restore session using HttpOnly cookie
|
||||
// // try {
|
||||
// // const res = await firstValueFrom(this.refreshToken());
|
||||
// // this.safeSetToken(res.accessToken);
|
||||
// // }
|
||||
// // catch{
|
||||
// // console.warn('Silent token refresh failed on startup');
|
||||
// // }
|
||||
// // finally{
|
||||
// // this.tokenReady$.next(true);
|
||||
// // }
|
||||
// }
|
||||
// // Optionally: try a silent refresh on startup to restore session using HttpOnly cookie
|
||||
// try {
|
||||
// const res = await firstValueFrom(this.refreshToken());
|
||||
// this.safeSetToken(res.accessToken);
|
||||
// }
|
||||
// catch{
|
||||
// console.warn('Silent token refresh failed on startup');
|
||||
// }
|
||||
// finally{
|
||||
// this.tokenReady$.next(true);
|
||||
// }
|
||||
}
|
||||
|
||||
get currentToken(): string | null {
|
||||
return this.safeGetToken();
|
||||
@@ -123,7 +124,7 @@ export class AuthService {
|
||||
logout(): Observable<void> {
|
||||
this.accessToken = null;
|
||||
this.safeRemoveToken();
|
||||
this.router.navigate(['/login']);
|
||||
this.router.navigate(['/admin/login']);
|
||||
return of();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
<div class="verify-wrapper">
|
||||
<div class="verify-card">
|
||||
|
||||
<h2 class="title">🔐 OTP Verification</h2>
|
||||
@if(!isOtpSent()){
|
||||
<h2 class="title">🔐 Login</h2>
|
||||
}
|
||||
|
||||
@if(isOtpSent() && !isVerified()){
|
||||
<h2 class="title">🔐 OTP Verification</h2>
|
||||
}
|
||||
|
||||
<!-- Step 1: Enter Email -->
|
||||
@if (!isOtpSent()) {
|
||||
@@ -35,17 +41,5 @@
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Step 3: Success -->
|
||||
<!-- @if (isVerified()) {
|
||||
<div>
|
||||
<p class="success-msg">{{ message() }}✅</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (isError()) {
|
||||
<p class="error-message">{{ message() }}</p>
|
||||
} -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user