User Service
class UserService
user.service.ts
import {
Injectable,
Signal,
WritableSignal,
inject,
signal,
} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { QueryParam } from '@jet/enums/query-param.enum';
import { AvailableOauthProvider } from '@jet/types/available-oauth-provider.type';
import {
AuthChangeEvent,
AuthError,
AuthOtpResponse,
AuthResponse,
AuthSession,
AuthTokenResponsePassword,
OAuthResponse,
SupabaseClient,
User,
UserAttributes,
UserResponse,
} from '@supabase/supabase-js';
import { LoggerService } from '../logger/logger.service';
import { SupabaseService } from '../supabase/supabase.service';
@Injectable({
providedIn: 'root',
})
export class UserService {
private readonly _activatedRoute = inject(ActivatedRoute);
private readonly _loggerService = inject(LoggerService);
private readonly _supabaseService = inject(SupabaseService);
private readonly _supabaseClient: SupabaseClient;
private readonly _user: WritableSignal<User | null>;
public constructor() {
// Buy to unlock
}
public get user(): Signal<User | null> {
// Buy to unlock
}
public getSession(): Promise<
| { data: { session: AuthSession }; error: null }
| { data: { session: null }; error: AuthError }
| { data: { session: null }; error: null }
> {
// Buy to unlock
}
public resetPasswordForEmail(
email: string,
): Promise<{ data: object; error: null } | { data: null; error: AuthError }> {
// Buy to unlock
}
public signInWithOauth(
oauthProvider: AvailableOauthProvider,
): Promise<OAuthResponse> {
// Buy to unlock
}
public signInWithOtp(email: string): Promise<AuthOtpResponse> {
// Buy to unlock
}
public signInWithPassword(
email: string,
password: string,
): Promise<AuthTokenResponsePassword> {
// Buy to unlock
}
public signOut(): Promise<{ error: AuthError | null }> {
// Buy to unlock
}
public signUp(email: string, password: string): Promise<AuthResponse> {
// Buy to unlock
}
public updateUser(userAttributes: UserAttributes): Promise<UserResponse> {
// Buy to unlock
}
private _getRedirectUrlWithReturnUrl(
returnUrl = this._activatedRoute.snapshot.queryParamMap.get(
QueryParam.ReturnUrl,
),
): string {
// Buy to unlock
}
}
Last updated
Was this helpful?