Jet
BuyFollow on X
  • Home
  • Satisfied Requirements
  • License
  • Architecture
    • Overview
    • Internal Dependency Graph
    • External Dependencies
    • Conventions
  • Recipes
    • Get Started
    • Add a Page
    • Customise Fonts
    • Customise Icons
    • Customise Languages
    • Customise Themes
    • Add an Environment Variable
  • Classes
    • Jet Mat Paginator Intl
    • Transloco HTTP Loader
  • Components
    • App Component
    • Footer Component
    • Home Page Component
    • Message Page Component
    • Not Found Page Component
    • Page Component
    • Profile Page Component
    • Reset Password Page Component
    • Settings Page Component
    • Sign In Page Component
    • Sign Out Page Component
    • Sign Up Page Component
    • Update Password Page Component
  • Constants
    • Color Scheme Options
    • Default Color Scheme Option
    • Default Language Option
    • Default Settings
    • Language Options
    • Navigation Menu Items
  • Directives
    • Analytics Directive
  • Enums
    • Bucket
    • LocalStorage Key
    • Query Param
    • SessionStorage Key
    • Table
  • Guards
    • Is Authenticated
    • Is Not Authenticated
  • Interfaces
    • Color Scheme Option
    • Language Option
    • Navigation Menu Item
    • Profile
    • Progress Bar Configuration
    • Settings
  • Services
    • Alert Service
    • Analytics Service
    • Logger Service
    • Profile Service
    • Progress Bar Service
    • Service Worker Service
    • Settings Service
    • Storage Service
    • Supabase Service
    • Toolbar Title Service
    • User Service
  • Types
    • Available Color Scheme
    • Available Font
    • Available Language
    • Available OAuth Provider
Powered by GitBook
On this page

Was this helpful?

  1. Services

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
  }
}
PreviousToolbar Title ServiceNextAvailable Color Scheme

Last updated 4 months ago

Was this helpful?