add email verification after account registration

This commit is contained in:
Krrish Ghimire
2026-07-08 22:55:22 +05:45
parent 212785725f
commit 77c4cfc777
26 changed files with 1386 additions and 53 deletions

View File

@@ -14,9 +14,8 @@ export class AuthService {
constructor(private http: HttpClient) {}
register(name: string, email: string, password: string): Observable<AuthResponse> {
return this.http.post<AuthResponse>('/api/auth/register', { name, email, password })
.pipe(tap(res => this.setSession(res)));
register(name: string, email: string, password: string): Observable<{ message: string }> {
return this.http.post<{ message: string }>('/api/auth/register', { name, email, password });
}
login(email: string, password: string): Observable<AuthResponse> {
@@ -34,6 +33,18 @@ export class AuthService {
.pipe(tap(() => this.clearSession()));
}
verifyEmail(token: string): Observable<{ message: string; setupToken?: string }> {
return this.http.post<{ message: string; setupToken?: string }>('/api/auth/verify-email', { token });
}
resendVerification(email: string): Observable<{ message: string }> {
return this.http.post<{ message: string }>('/api/auth/resend-verification', { email });
}
setPassword(setupToken: string, password: string): Observable<void> {
return this.http.post<void>('/api/auth/set-password', { setupToken, password });
}
getAccessToken(): string | null {
return localStorage.getItem(this.ACCESS_TOKEN_KEY);
}
@@ -72,5 +83,4 @@ export class AuthService {
const data = localStorage.getItem(this.USER_KEY);
return data ? JSON.parse(data) : null;
}
}