SSO implementiert
This commit is contained in:
@@ -8,9 +8,7 @@ import {
|
||||
PublicUserSearchResult,
|
||||
RegisterRequest,
|
||||
RegisterResponse,
|
||||
ResendVerificationResponse,
|
||||
TaskDigestPreference,
|
||||
VerifyEmailResponse,
|
||||
} from './auth.models';
|
||||
|
||||
const ACCESS_TOKEN_KEY = 'listify.accessToken';
|
||||
@@ -33,21 +31,26 @@ export class AuthService {
|
||||
.pipe(tap((response) => this.storeSession(response)));
|
||||
}
|
||||
|
||||
startSsoLogin(): void {
|
||||
if (typeof window !== 'undefined') {
|
||||
window.location.href = `${this.apiUrl}/sso/login`;
|
||||
}
|
||||
}
|
||||
|
||||
completeSsoLogin(response: AuthTokenResponse): void {
|
||||
this.storeSession(response);
|
||||
}
|
||||
|
||||
exchangeSsoCode(code: string, state: string): Observable<AuthTokenResponse> {
|
||||
return this.http
|
||||
.post<AuthTokenResponse>(`${this.apiUrl}/sso/exchange`, { code, state })
|
||||
.pipe(tap((response) => this.storeSession(response)));
|
||||
}
|
||||
|
||||
register(data: RegisterRequest): Observable<RegisterResponse> {
|
||||
return this.http.post<RegisterResponse>(`${this.apiUrl}/register`, data);
|
||||
}
|
||||
|
||||
verifyEmail(token: string): Observable<VerifyEmailResponse> {
|
||||
const params = new HttpParams().set('token', token);
|
||||
return this.http.get<VerifyEmailResponse>(`${this.apiUrl}/verify-email`, { params });
|
||||
}
|
||||
|
||||
resendVerificationEmail(email: string): Observable<ResendVerificationResponse> {
|
||||
return this.http.post<ResendVerificationResponse>(`${this.apiUrl}/resend-verification`, {
|
||||
email,
|
||||
});
|
||||
}
|
||||
|
||||
loadCurrentUser(): Observable<PublicUser> {
|
||||
return this.http.get<PublicUser>(`${this.apiUrl}/me`).pipe(tap((user) => this.storeUser(user)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user