@sneat/auth-ui 0.27.38 → 0.27.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/pages/login-page/auth-panel.component.js +4 -0
- package/esm2022/lib/pages/login-page/auth-panel.component.js.map +1 -1
- package/esm2022/lib/pages/login-page/email-login-form/email-login-form.component.js +18 -6
- package/esm2022/lib/pages/login-page/email-login-form/email-login-form.component.js.map +1 -1
- package/esm2022/lib/pages/login-page/login-page.component.js +138 -35
- package/esm2022/lib/pages/login-page/login-page.component.js.map +1 -1
- package/esm2022/lib/pages/login-page/login-redirect-intent.js +42 -0
- package/esm2022/lib/pages/login-page/login-redirect-intent.js.map +1 -0
- package/lib/pages/login-page/email-login-form/email-login-form.component.d.ts +1 -0
- package/lib/pages/login-page/login-page.component.d.ts +15 -1
- package/lib/pages/login-page/login-redirect-intent.d.ts +6 -0
- package/package.json +1 -1
- package/tsconfig.lib.prod.tsbuildinfo +1 -1
|
@@ -8,6 +8,7 @@ import { IonButton, IonCard, IonCol, IonGrid, IonIcon, IonItem, IonItemDivider,
|
|
|
8
8
|
import { EmailLoginFormComponent, } from './email-login-form/email-login-form.component';
|
|
9
9
|
import { LoginWithTelegramComponent } from './login-with-telegram.component';
|
|
10
10
|
import { safeAuthReturnPath } from './safe-auth-return-path';
|
|
11
|
+
import { clearLoginRedirectIntent, markLoginRedirectIntent, } from './login-redirect-intent';
|
|
11
12
|
import { combineLatest } from 'rxjs';
|
|
12
13
|
import { AUTH_PANEL_UI_CONFIG } from './auth-panel-ui-config';
|
|
13
14
|
import { RandomIdService } from '@sneat/random';
|
|
@@ -95,10 +96,13 @@ export class AuthPanelComponent {
|
|
|
95
96
|
}
|
|
96
97
|
async loginWith(provider) {
|
|
97
98
|
this.signingWith.set(provider);
|
|
99
|
+
markLoginRedirectIntent(this.safeReturnTo());
|
|
98
100
|
try {
|
|
99
101
|
await this.authStateService.signInWith(provider);
|
|
102
|
+
clearLoginRedirectIntent();
|
|
100
103
|
}
|
|
101
104
|
catch (error) {
|
|
105
|
+
clearLoginRedirectIntent();
|
|
102
106
|
const message = error.errorMessage;
|
|
103
107
|
if (message !== 'The user canceled the sign-in flow.' &&
|
|
104
108
|
!message?.includes('com.apple.AuthenticationServices.AuthorizationError error 1001.')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-panel.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/pages/login-page/auth-panel.component.ts","../../../../../../../../libs/auth/ui/src/lib/pages/login-page/auth-panel.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,YAAY,EAEZ,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,YAAY,EAEZ,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAC;AAExD,OAAO,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,cAAc,EACd,QAAQ,EACR,OAAO,EACP,MAAM,EACN,UAAU,EACV,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGL,uBAAuB,GACxB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE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AAK,EAAE,CAAC;YAC9B,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;YACnE,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,YAAY,CAAC,OAAO,CAAC,gBAAgB,EAAE,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;QACD,MAAM,SAAS,GAAoB;YACjC,MAAM,EAAE,YAAY,CAAC,aAAa;YAClC,IAAI,EAAE,cAAc,CAAC,IAAI;SAC1B,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;8GA1HU,kBAAkB;kGAAlB,kBAAkB,uqBAFlB,CAAC,eAAe,CAAC,0BC7E9B,2rOA0MA,4CD7II,UAAU,kPACV,uBAAuB,oJACvB,0BAA0B,oJAC1B,SAAS,sRACT,OAAO,yLACP,MAAM,kTACN,OAAO,wEACP,OAAO,2JACP,OAAO,0NACP,cAAc,kGACd,QAAQ,6FACR,OAAO,yFACP,MAAM,oDACN,UAAU,yGACV,OAAO;;2FAIE,kBAAkB;kBAvB9B,SAAS;+BACE,kBAAkB,mBAEX,uBAAuB,CAAC,MAAM,WACtC;wBACP,UAAU;wBACV,uBAAuB;wBACvB,0BAA0B;wBAC1B,SAAS;wBACT,OAAO;wBACP,MAAM;wBACN,OAAO;wBACP,OAAO;wBACP,OAAO;wBACP,cAAc;wBACd,QAAQ;wBACR,OAAO;wBACP,MAAM;wBACN,UAAU;wBACV,OAAO;qBACR,aACU,CAAC,eAAe,CAAC;;sBAY3B,MAAM","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n EventEmitter,\n OnInit,\n Output,\n computed,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { RouterLink } from '@angular/router';\nimport { Capacitor } from '@capacitor/core';\nimport {\n AuthProviderID,\n AuthStatuses,\n ISneatAuthState,\n SneatAuthStateService,\n SneatUserService,\n isSneatAccountReady,\n} from '@sneat/auth-core';\nimport { ErrorLogger, IErrorLogger } from '@sneat/core';\nimport { UserCredential } from 'firebase/auth';\nimport {\n IonButton,\n IonCard,\n IonCol,\n IonGrid,\n IonIcon,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonList,\n IonRow,\n IonSpinner,\n IonText,\n} from '@ionic/angular';\nimport {\n AuthPanelInitialMode,\n EmailFormSigningWith,\n EmailLoginFormComponent,\n} from './email-login-form/email-login-form.component';\nimport { LoginWithTelegramComponent } from './login-with-telegram.component';\nimport { safeAuthReturnPath } from './safe-auth-return-path';\nimport { combineLatest } from 'rxjs';\nimport { AUTH_PANEL_UI_CONFIG } from './auth-panel-ui-config';\nimport { RandomIdService } from '@sneat/random';\n\nexport interface AuthPanelAccountReadyChange {\n readonly uid?: string;\n readonly ready: boolean;\n}\n\n/** Shared auth methods without page-shell or navigation side effects. */\n@Component({\n selector: 'sneat-auth-panel',\n templateUrl: './auth-panel.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n RouterLink,\n EmailLoginFormComponent,\n LoginWithTelegramComponent,\n IonButton,\n IonCard,\n IonCol,\n IonGrid,\n IonIcon,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonList,\n IonRow,\n IonSpinner,\n IonText,\n ],\n providers: [RandomIdService],\n})\nexport class AuthPanelComponent implements OnInit {\n protected readonly uiConfig = inject(AUTH_PANEL_UI_CONFIG);\n protected providerVisible(provider: AuthProviderID | 'telegram'): boolean {\n return this.uiConfig.quickLoginProviders?.includes(provider) ?? true;\n }\n\n readonly returnTo = input<string | undefined>();\n readonly initialMode = input<AuthPanelInitialMode | undefined>();\n readonly showIntro = input(true);\n readonly showCredentials = input(true);\n @Output() readonly accountReadyChange =\n new EventEmitter<AuthPanelAccountReadyChange>();\n\n protected readonly signingWith = signal<\n AuthProviderID | EmailFormSigningWith | undefined\n >(undefined);\n protected readonly authRecoveryNeeded = signal(false);\n protected readonly recordState = signal<\n 'signed-out' | 'loading' | 'ready' | 'failed'\n >('loading');\n protected readonly isNativePlatform = Capacitor.isNativePlatform();\n protected readonly safeReturnTo = computed(() =>\n safeAuthReturnPath(this.returnTo()),\n );\n protected readonly ssoQueryParams = computed(() => {\n const returnTo = this.safeReturnTo();\n return returnTo ? { returnTo } : undefined;\n });\n\n private readonly authStateService = inject(SneatAuthStateService);\n private readonly userService = inject(SneatUserService);\n private readonly errorLogger = inject<IErrorLogger>(ErrorLogger);\n private readonly destroyRef = inject(DestroyRef);\n\n ngOnInit(): void {\n // This initial BehaviorSubject value is emitted after inputs and output\n // listeners are connected. Consumers can gate account-dependent work until\n // the matching user record is ready, even when auth resolved before mount.\n combineLatest([this.authStateService.authState, this.userService.userState])\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(([authState, userState]) => {\n const uid = authState.user?.uid;\n const authRecoveryNeeded = authState.loadingPhase === 'failed';\n const sameIdentity =\n !!uid &&\n userState.status === 'authenticated' &&\n userState.user?.uid === uid &&\n !userState.user.isAnonymous;\n const ready = isSneatAccountReady(authState, userState);\n const failed =\n !authRecoveryNeeded &&\n authState.status === 'authenticated' &&\n !authState.user?.isAnonymous &&\n sameIdentity &&\n userState.userRecordStatus === 'failed';\n const signedOut =\n authState.status === 'notAuthenticated' ||\n authState.user?.isAnonymous === true;\n this.authRecoveryNeeded.set(authRecoveryNeeded);\n this.recordState.set(\n ready\n ? 'ready'\n : failed\n ? 'failed'\n : signedOut || authRecoveryNeeded\n ? 'signed-out'\n : 'loading',\n );\n if (\n ready ||\n authRecoveryNeeded ||\n authState.status === 'notAuthenticated'\n ) {\n this.signingWith.set(undefined);\n }\n this.accountReadyChange.emit({\n uid,\n ready,\n });\n });\n }\n\n protected retryUserRecordInitialization(): void {\n this.userService.retryUserRecordInitialization();\n }\n\n protected onEmailFormStatusChanged(signingWith?: EmailFormSigningWith): void {\n this.signingWith.set(signingWith);\n }\n\n protected async loginWith(provider: AuthProviderID): Promise<void> {\n this.signingWith.set(provider);\n try {\n await this.authStateService.signInWith(provider);\n } catch (error) {\n const message = (error as { errorMessage?: string }).errorMessage;\n if (\n message !== 'The user canceled the sign-in flow.' &&\n !message?.includes(\n 'com.apple.AuthenticationServices.AuthorizationError error 1001.',\n )\n ) {\n this.errorLogger.logError(error, `Failed to sign-in with ${provider}`);\n }\n this.signingWith.set(undefined);\n }\n }\n\n protected onLoggedIn(userCredential: UserCredential): void {\n this.signingWith.set(undefined);\n if (!userCredential.user) return;\n if (userCredential.user.email) {\n const previousEmail = localStorage.getItem('emailForSignIn') || '';\n if (!previousEmail) {\n localStorage.setItem('emailForSignIn', userCredential.user.email);\n }\n }\n const authState: ISneatAuthState = {\n status: AuthStatuses.authenticated,\n user: userCredential.user,\n };\n this.userService.onUserSignedIn(authState);\n }\n}\n","@if (authRecoveryNeeded()) {\n <div class=\"ion-padding ion-text-center\" role=\"alert\">\n <p>\n We couldn't complete sign-in. Try again with email or another sign-in\n method.\n </p>\n </div>\n}\n\n@if (recordState() === 'failed') {\n <div class=\"ion-padding ion-text-center\" role=\"alert\">\n <p>Your account is still being prepared. Retry before continuing.</p>\n <ion-button fill=\"outline\" (click)=\"retryUserRecordInitialization()\">\n Retry account setup\n </ion-button>\n </div>\n} @else if (recordState() === 'loading') {\n <div class=\"ion-padding ion-text-center\" role=\"status\" aria-live=\"polite\">\n <ion-spinner name=\"lines-small\" />\n <p>Preparing your account…</p>\n </div>\n} @else {\n @if (showCredentials() || authRecoveryNeeded()) {\n @if (showIntro()) {\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">Sign in with your Sneat account.</ion-text>\n </p>\n }\n\n <sneat-email-login-form\n [returnTo]=\"safeReturnTo()\"\n [initialMode]=\"initialMode()\"\n (signingWithChange)=\"onEmailFormStatusChanged($event)\"\n (loggedIn)=\"onLoggedIn($event)\"\n />\n\n <div class=\"ion-padding-horizontal ion-text-center\">\n <ion-button\n fill=\"outline\"\n expand=\"block\"\n routerLink=\"/sso\"\n [queryParams]=\"ssoQueryParams()\"\n [disabled]=\"!!signingWith()\"\n >\n <ion-icon name=\"business-outline\" slot=\"start\" />\n Sign in with company SSO\n </ion-button>\n </div>\n\n @if (uiConfig.quickLoginProviders?.length !== 0) {\n <ion-card>\n @if (uiConfig.showQuickLoginHeader !== false) {\n <ion-item-divider color=\"light\">\n <ion-label\n color=\"medium\"\n style=\"text-align: center; width: 100%; font-weight: bold\"\n >\n Quick login\n </ion-label>\n </ion-item-divider>\n }\n <ion-grid class=\"ion-grid-layout\">\n @if (!isNativePlatform && providerVisible('telegram')) {\n <ion-row>\n <ion-col>\n <div class=\"ion-padding\" style=\"text-align: center\">\n <sneat-login-with-telegram />\n </div>\n </ion-col>\n </ion-row>\n }\n <ion-row>\n @if (providerVisible('google.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('google.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'google.com') {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon\n color=\"danger\"\n name=\"logo-google\"\n slot=\"start\"\n />\n }\n <ion-label color=\"danger\"> Login with Google</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n }\n @if (providerVisible('apple.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('apple.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'apple.com') {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"dark\" name=\"logo-apple\" slot=\"start\" />\n }\n <ion-label color=\"dark\">Login with Apple</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n }\n </ion-row>\n <ion-row>\n @if (providerVisible('microsoft.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('microsoft.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'microsoft.com') {\n <ion-spinner\n slot=\"start\"\n color=\"secondary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon\n slot=\"start\"\n color=\"secondary\"\n name=\"logo-windows\"\n />\n }\n <ion-label color=\"secondary\"\n >Login with Microsoft</ion-label\n >\n </ion-item>\n </ion-list>\n </ion-col>\n }\n @if (providerVisible('facebook.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('facebook.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'facebook.com') {\n <ion-spinner\n slot=\"start\"\n color=\"primary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon\n slot=\"start\"\n color=\"primary\"\n name=\"logo-facebook\"\n />\n }\n <ion-label color=\"primary\">Login with Facebook</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n }\n </ion-row>\n <ion-row>\n @if (providerVisible('github.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('github.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'github.com') {\n <ion-spinner\n slot=\"start\"\n color=\"tertiary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon\n slot=\"start\"\n color=\"tertiary\"\n name=\"logo-github\"\n />\n }\n <ion-label color=\"tertiary\">Login with GitHub</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n }\n </ion-row>\n </ion-grid>\n </ion-card>\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth-panel.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/pages/login-page/auth-panel.component.ts","../../../../../../../../libs/auth/ui/src/lib/pages/login-page/auth-panel.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,YAAY,EAE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AoB;YACjC,MAAM,EAAE,YAAY,CAAC,aAAa;YAClC,IAAI,EAAE,cAAc,CAAC,IAAI;SAC1B,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;8GA7HU,kBAAkB;kGAAlB,kBAAkB,uqBAFlB,CAAC,eAAe,CAAC,0BCjF9B,2rOA0MA,4CDzII,UAAU,kPACV,uBAAuB,oJACvB,0BAA0B,oJAC1B,SAAS,sRACT,OAAO,yLACP,MAAM,kTACN,OAAO,wEACP,OAAO,2JACP,OAAO,0NACP,cAAc,kGACd,QAAQ,6FACR,OAAO,yFACP,MAAM,oDACN,UAAU,yGACV,OAAO;;2FAIE,kBAAkB;kBAvB9B,SAAS;+BACE,kBAAkB,mBAEX,uBAAuB,CAAC,MAAM,WACtC;wBACP,UAAU;wBACV,uBAAuB;wBACvB,0BAA0B;wBAC1B,SAAS;wBACT,OAAO;wBACP,MAAM;wBACN,OAAO;wBACP,OAAO;wBACP,OAAO;wBACP,cAAc;wBACd,QAAQ;wBACR,OAAO;wBACP,MAAM;wBACN,UAAU;wBACV,OAAO;qBACR,aACU,CAAC,eAAe,CAAC;;sBAY3B,MAAM","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n EventEmitter,\n OnInit,\n Output,\n computed,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { RouterLink } from '@angular/router';\nimport { Capacitor } from '@capacitor/core';\nimport {\n AuthProviderID,\n AuthStatuses,\n ISneatAuthState,\n SneatAuthStateService,\n SneatUserService,\n isSneatAccountReady,\n} from '@sneat/auth-core';\nimport { ErrorLogger, IErrorLogger } from '@sneat/core';\nimport { UserCredential } from 'firebase/auth';\nimport {\n IonButton,\n IonCard,\n IonCol,\n IonGrid,\n IonIcon,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonList,\n IonRow,\n IonSpinner,\n IonText,\n} from '@ionic/angular';\nimport {\n AuthPanelInitialMode,\n EmailFormSigningWith,\n EmailLoginFormComponent,\n} from './email-login-form/email-login-form.component';\nimport { LoginWithTelegramComponent } from './login-with-telegram.component';\nimport { safeAuthReturnPath } from './safe-auth-return-path';\nimport {\n clearLoginRedirectIntent,\n markLoginRedirectIntent,\n} from './login-redirect-intent';\nimport { combineLatest } from 'rxjs';\nimport { AUTH_PANEL_UI_CONFIG } from './auth-panel-ui-config';\nimport { RandomIdService } from '@sneat/random';\n\nexport interface AuthPanelAccountReadyChange {\n readonly uid?: string;\n readonly ready: boolean;\n}\n\n/** Shared auth methods without page-shell or navigation side effects. */\n@Component({\n selector: 'sneat-auth-panel',\n templateUrl: './auth-panel.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n RouterLink,\n EmailLoginFormComponent,\n LoginWithTelegramComponent,\n IonButton,\n IonCard,\n IonCol,\n IonGrid,\n IonIcon,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonList,\n IonRow,\n IonSpinner,\n IonText,\n ],\n providers: [RandomIdService],\n})\nexport class AuthPanelComponent implements OnInit {\n protected readonly uiConfig = inject(AUTH_PANEL_UI_CONFIG);\n protected providerVisible(provider: AuthProviderID | 'telegram'): boolean {\n return this.uiConfig.quickLoginProviders?.includes(provider) ?? true;\n }\n\n readonly returnTo = input<string | undefined>();\n readonly initialMode = input<AuthPanelInitialMode | undefined>();\n readonly showIntro = input(true);\n readonly showCredentials = input(true);\n @Output() readonly accountReadyChange =\n new EventEmitter<AuthPanelAccountReadyChange>();\n\n protected readonly signingWith = signal<\n AuthProviderID | EmailFormSigningWith | undefined\n >(undefined);\n protected readonly authRecoveryNeeded = signal(false);\n protected readonly recordState = signal<\n 'signed-out' | 'loading' | 'ready' | 'failed'\n >('loading');\n protected readonly isNativePlatform = Capacitor.isNativePlatform();\n protected readonly safeReturnTo = computed(() =>\n safeAuthReturnPath(this.returnTo()),\n );\n protected readonly ssoQueryParams = computed(() => {\n const returnTo = this.safeReturnTo();\n return returnTo ? { returnTo } : undefined;\n });\n\n private readonly authStateService = inject(SneatAuthStateService);\n private readonly userService = inject(SneatUserService);\n private readonly errorLogger = inject<IErrorLogger>(ErrorLogger);\n private readonly destroyRef = inject(DestroyRef);\n\n ngOnInit(): void {\n // This initial BehaviorSubject value is emitted after inputs and output\n // listeners are connected. Consumers can gate account-dependent work until\n // the matching user record is ready, even when auth resolved before mount.\n combineLatest([this.authStateService.authState, this.userService.userState])\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe(([authState, userState]) => {\n const uid = authState.user?.uid;\n const authRecoveryNeeded = authState.loadingPhase === 'failed';\n const sameIdentity =\n !!uid &&\n userState.status === 'authenticated' &&\n userState.user?.uid === uid &&\n !userState.user.isAnonymous;\n const ready = isSneatAccountReady(authState, userState);\n const failed =\n !authRecoveryNeeded &&\n authState.status === 'authenticated' &&\n !authState.user?.isAnonymous &&\n sameIdentity &&\n userState.userRecordStatus === 'failed';\n const signedOut =\n authState.status === 'notAuthenticated' ||\n authState.user?.isAnonymous === true;\n this.authRecoveryNeeded.set(authRecoveryNeeded);\n this.recordState.set(\n ready\n ? 'ready'\n : failed\n ? 'failed'\n : signedOut || authRecoveryNeeded\n ? 'signed-out'\n : 'loading',\n );\n if (\n ready ||\n authRecoveryNeeded ||\n authState.status === 'notAuthenticated'\n ) {\n this.signingWith.set(undefined);\n }\n this.accountReadyChange.emit({\n uid,\n ready,\n });\n });\n }\n\n protected retryUserRecordInitialization(): void {\n this.userService.retryUserRecordInitialization();\n }\n\n protected onEmailFormStatusChanged(signingWith?: EmailFormSigningWith): void {\n this.signingWith.set(signingWith);\n }\n\n protected async loginWith(provider: AuthProviderID): Promise<void> {\n this.signingWith.set(provider);\n markLoginRedirectIntent(this.safeReturnTo());\n try {\n await this.authStateService.signInWith(provider);\n clearLoginRedirectIntent();\n } catch (error) {\n clearLoginRedirectIntent();\n const message = (error as { errorMessage?: string }).errorMessage;\n if (\n message !== 'The user canceled the sign-in flow.' &&\n !message?.includes(\n 'com.apple.AuthenticationServices.AuthorizationError error 1001.',\n )\n ) {\n this.errorLogger.logError(error, `Failed to sign-in with ${provider}`);\n }\n this.signingWith.set(undefined);\n }\n }\n\n protected onLoggedIn(userCredential: UserCredential): void {\n this.signingWith.set(undefined);\n if (!userCredential.user) return;\n if (userCredential.user.email) {\n const previousEmail = localStorage.getItem('emailForSignIn') || '';\n if (!previousEmail) {\n localStorage.setItem('emailForSignIn', userCredential.user.email);\n }\n }\n const authState: ISneatAuthState = {\n status: AuthStatuses.authenticated,\n user: userCredential.user,\n };\n this.userService.onUserSignedIn(authState);\n }\n}\n","@if (authRecoveryNeeded()) {\n <div class=\"ion-padding ion-text-center\" role=\"alert\">\n <p>\n We couldn't complete sign-in. Try again with email or another sign-in\n method.\n </p>\n </div>\n}\n\n@if (recordState() === 'failed') {\n <div class=\"ion-padding ion-text-center\" role=\"alert\">\n <p>Your account is still being prepared. Retry before continuing.</p>\n <ion-button fill=\"outline\" (click)=\"retryUserRecordInitialization()\">\n Retry account setup\n </ion-button>\n </div>\n} @else if (recordState() === 'loading') {\n <div class=\"ion-padding ion-text-center\" role=\"status\" aria-live=\"polite\">\n <ion-spinner name=\"lines-small\" />\n <p>Preparing your account…</p>\n </div>\n} @else {\n @if (showCredentials() || authRecoveryNeeded()) {\n @if (showIntro()) {\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">Sign in with your Sneat account.</ion-text>\n </p>\n }\n\n <sneat-email-login-form\n [returnTo]=\"safeReturnTo()\"\n [initialMode]=\"initialMode()\"\n (signingWithChange)=\"onEmailFormStatusChanged($event)\"\n (loggedIn)=\"onLoggedIn($event)\"\n />\n\n <div class=\"ion-padding-horizontal ion-text-center\">\n <ion-button\n fill=\"outline\"\n expand=\"block\"\n routerLink=\"/sso\"\n [queryParams]=\"ssoQueryParams()\"\n [disabled]=\"!!signingWith()\"\n >\n <ion-icon name=\"business-outline\" slot=\"start\" />\n Sign in with company SSO\n </ion-button>\n </div>\n\n @if (uiConfig.quickLoginProviders?.length !== 0) {\n <ion-card>\n @if (uiConfig.showQuickLoginHeader !== false) {\n <ion-item-divider color=\"light\">\n <ion-label\n color=\"medium\"\n style=\"text-align: center; width: 100%; font-weight: bold\"\n >\n Quick login\n </ion-label>\n </ion-item-divider>\n }\n <ion-grid class=\"ion-grid-layout\">\n @if (!isNativePlatform && providerVisible('telegram')) {\n <ion-row>\n <ion-col>\n <div class=\"ion-padding\" style=\"text-align: center\">\n <sneat-login-with-telegram />\n </div>\n </ion-col>\n </ion-row>\n }\n <ion-row>\n @if (providerVisible('google.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('google.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'google.com') {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon\n color=\"danger\"\n name=\"logo-google\"\n slot=\"start\"\n />\n }\n <ion-label color=\"danger\"> Login with Google</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n }\n @if (providerVisible('apple.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('apple.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'apple.com') {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"dark\" name=\"logo-apple\" slot=\"start\" />\n }\n <ion-label color=\"dark\">Login with Apple</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n }\n </ion-row>\n <ion-row>\n @if (providerVisible('microsoft.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('microsoft.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'microsoft.com') {\n <ion-spinner\n slot=\"start\"\n color=\"secondary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon\n slot=\"start\"\n color=\"secondary\"\n name=\"logo-windows\"\n />\n }\n <ion-label color=\"secondary\"\n >Login with Microsoft</ion-label\n >\n </ion-item>\n </ion-list>\n </ion-col>\n }\n @if (providerVisible('facebook.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('facebook.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'facebook.com') {\n <ion-spinner\n slot=\"start\"\n color=\"primary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon\n slot=\"start\"\n color=\"primary\"\n name=\"logo-facebook\"\n />\n }\n <ion-label color=\"primary\">Login with Facebook</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n }\n </ion-row>\n <ion-row>\n @if (providerVisible('github.com')) {\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('github.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === 'github.com') {\n <ion-spinner\n slot=\"start\"\n color=\"tertiary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon\n slot=\"start\"\n color=\"tertiary\"\n name=\"logo-github\"\n />\n }\n <ion-label color=\"tertiary\">Login with GitHub</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n }\n </ion-row>\n </ion-grid>\n </ion-card>\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChangeDetectionStrategy, Component, EventEmitter, Output, inject, input, signal, viewChild, } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { sendSignInLinkToEmail, } from 'firebase/auth';
|
|
3
3
|
import { SNEAT_FIREBASE_AUTH } from '@sneat/core';
|
|
4
4
|
import { FormsModule } from '@angular/forms';
|
|
5
5
|
import { ToastController, IonButton, IonButtons, IonCard, IonCardContent, IonIcon, IonInput, IonItem, IonItemDivider, IonLabel, IonSegment, IonSegmentButton, IonSpinner, IonText, } from '@ionic/angular';
|
|
@@ -237,13 +237,25 @@ export class EmailLoginFormComponent {
|
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
resetPassword() {
|
|
240
|
+
if (this.signingWith())
|
|
241
|
+
return;
|
|
240
242
|
this.setSigningWith('resetPassword');
|
|
241
|
-
|
|
242
|
-
.
|
|
243
|
-
this.
|
|
244
|
-
|
|
243
|
+
this.sneatApiService
|
|
244
|
+
.postAsAnonymous('auth/request-password-reset', {
|
|
245
|
+
email: this.email(),
|
|
246
|
+
returnUrl: this.passwordResetReturnUrl(),
|
|
245
247
|
})
|
|
246
|
-
.
|
|
248
|
+
.subscribe({
|
|
249
|
+
next: () => {
|
|
250
|
+
this.setSigningWith(undefined);
|
|
251
|
+
this.showToast('If an account exists for this email, password reset instructions will be sent.');
|
|
252
|
+
},
|
|
253
|
+
error: this.errorHandler('Failed to send password reset email', 'FailedToSendPasswordResetEmail'),
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
passwordResetReturnUrl() {
|
|
257
|
+
const safeReturnTo = safeAuthReturnPath(this.returnTo());
|
|
258
|
+
return new URL(safeReturnTo ?? '/login', window.location.origin).toString();
|
|
247
259
|
}
|
|
248
260
|
sendVerificationEmail(userCredential) {
|
|
249
261
|
setTimeout(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-login-form.component.js","sourceRoot":"","sources":["../../../../../../../../../libs/auth/ui/src/lib/pages/login-page/email-login-form/email-login-form.component.ts","../../../../../../../../../libs/auth/ui/src/lib/pages/login-page/email-login-form/email-login-form.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,YAAY,EAEZ,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;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AM,WACtC;wBACP,WAAW;wBACX,OAAO;wBACP,cAAc;wBACd,UAAU;wBACV,gBAAgB;wBAChB,OAAO;wBACP,QAAQ;wBACR,cAAc;wBACd,OAAO;wBACP,QAAQ;wBACR,UAAU;wBACV,OAAO;wBACP,SAAS;wBACT,UAAU;qBACX;;sBAqCA,MAAM;;sBAGN,MAAM;0DAE6C,YAAY,yEACP,iBAAiB","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n OnInit,\n Output,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\nimport {\n Auth,\n sendPasswordResetEmail,\n sendSignInLinkToEmail,\n} from 'firebase/auth';\nimport { SNEAT_FIREBASE_AUTH } from '@sneat/core';\nimport { FormsModule } from '@angular/forms';\nimport {\n ToastController,\n IonButton,\n IonButtons,\n IonCard,\n IonCardContent,\n IonIcon,\n IonInput,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonSegment,\n IonSegmentButton,\n IonSpinner,\n IonText,\n} from '@ionic/angular';\nimport { SneatApiService } from '@sneat/api';\nimport {\n IInitUserRecordRequest,\n SneatAuthStateService,\n UserRecordService,\n} from '@sneat/auth-core';\nimport { createSetFocusToInput } from '@sneat/ui';\nimport {\n AnalyticsService,\n APP_INFO,\n IAnalyticsService,\n IAppInfo,\n} from '@sneat/core';\nimport { ErrorLogger, IErrorLogger } from '@sneat/core';\nimport { RandomIdService } from '@sneat/random';\nimport { UserCredential, sendEmailVerification } from 'firebase/auth';\nimport { FirebaseError } from 'firebase/app';\nimport { safeAuthReturnPath } from '../safe-auth-return-path';\n\nexport type EmailFormSigningWith = 'email' | 'emailLink' | 'resetPassword';\nexport type AuthPanelInitialMode = 'sign-in' | 'sign-up';\nimport {\n createUserWithEmailAndPassword,\n signInWithEmailAndPassword,\n} from 'firebase/auth';\n\n@Component({\n selector: 'sneat-email-login-form',\n templateUrl: 'email-login-form.component.html',\n styleUrl: 'email-login-form.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n FormsModule,\n IonCard,\n IonItemDivider,\n IonSegment,\n IonSegmentButton,\n IonIcon,\n IonLabel,\n IonCardContent,\n IonItem,\n IonInput,\n IonSpinner,\n IonText,\n IonButton,\n IonButtons,\n ],\n})\nexport class EmailLoginFormComponent implements OnInit {\n readonly returnTo = input<string | undefined>();\n /**\n * Which tab the form opens on. Defaults to 'sign-in' because most visitors are\n * returning users; pass 'sign-up' to open on the registration tab.\n */\n readonly initialMode = input<AuthPanelInitialMode | undefined>();\n readonly appInfo = inject<IAppInfo>(APP_INFO);\n private readonly analyticsService =\n inject<IAnalyticsService>(AnalyticsService);\n private readonly errorLogger = inject<IErrorLogger>(ErrorLogger);\n private readonly toastController = inject(ToastController);\n private readonly afAuth = inject(SNEAT_FIREBASE_AUTH);\n private readonly randomIdService = inject(RandomIdService);\n private readonly sneatApiService = inject(SneatApiService);\n private readonly userRecordService = inject(UserRecordService);\n private readonly authStateService = inject(SneatAuthStateService, {\n optional: true,\n });\n\n /** The selected tab: 'in' is Sign in (existing account), 'up' is Sign up (new account). */\n protected readonly sign = signal<'in' | 'up'>('in');\n /** Set when a sign-up attempt found the email already registered; shows a hint on the Sign in tab. */\n protected readonly existingAccountHint = signal(false);\n protected readonly email = signal('');\n protected readonly password = signal('');\n protected readonly firstName = signal('');\n protected readonly lastName = signal('');\n protected readonly spaceTitle = signal('');\n protected readonly wrongPassword = signal(false);\n\n protected readonly signingWith = signal<EmailFormSigningWith | undefined>(\n undefined,\n );\n\n @Output() readonly signingWithChange = new EventEmitter<\n EmailFormSigningWith | undefined\n >();\n @Output() readonly loggedIn = new EventEmitter<UserCredential>();\n\n protected readonly emailInput = viewChild<IonInput>('emailInput');\n protected readonly spaceTitleInput = viewChild<IonInput>('spaceTitleInput');\n\n public readonly setFocusToInput = createSetFocusToInput(this.errorLogger);\n\n constructor() {\n const email = localStorage.getItem('emailForSignIn') || '';\n this.email.set(email);\n if (this.authStateService) {\n this.authStateService.authStatus.subscribe((status) => {\n if (status === 'notAuthenticated') {\n this.setSigningWith(undefined);\n }\n });\n }\n }\n\n ngOnInit(): void {\n // Sign in is the default tab. A consumer can explicitly choose the first\n // view without restricting later user toggles.\n const initialMode = this.initialMode();\n if (initialMode) {\n this.sign.set(initialMode === 'sign-in' ? 'in' : 'up');\n }\n }\n\n public get validEmail(): boolean {\n const email = this.email(),\n i = email?.indexOf('@');\n return i > 0 && i < email.length - 1;\n }\n\n public getFirebaseAuth(): Auth {\n // Since 0.27.0 the injected instance IS the firebase modular `Auth`, so the\n // `as unknown as Auth` cast this used to need (angular/angularfire#3402 —\n // @angular/fire's `Auth` was a distinct nominal class) is gone.\n return this.afAuth;\n }\n\n public async signUp(): Promise<void> {\n if (!this.firstName()) {\n // this.toaster.showToast('Full name is required');\n return;\n }\n // this.signingWith = 'email';\n const email = this.email().trim();\n this.email.set(email);\n const firstName = this.firstName().trim();\n const lastName = this.lastName().trim();\n if (!email) {\n alert('Email is a required field');\n return;\n }\n if (!firstName) {\n alert('First name is a required field');\n return;\n }\n if (!lastName) {\n alert('Last name is a required field');\n return;\n }\n const spaceTitle = this.spaceTitle().trim();\n this.spaceTitle.set(spaceTitle);\n if (this.appInfo.requiredSpaceType && !spaceTitle) {\n alert('Company title is a required field');\n this.setFocusToSpaceTitle();\n return;\n }\n localStorage.setItem('emailForSignIn', email);\n const password = this.randomIdService.newRandomId({ len: 9 });\n\n this.setSigningWith('email');\n try {\n // const auth = getAuth(getApp());\n const auth = this.getFirebaseAuth();\n const userCredential = await createUserWithEmailAndPassword(\n auth,\n email,\n password,\n );\n this.sendVerificationEmail(userCredential);\n userCredential.user\n ?.getIdToken()\n .then((token) => {\n this.sneatApiService.setApiAuthToken(token);\n const request: IInitUserRecordRequest = {\n authProvider: 'password',\n email,\n ianaTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n names: { firstName, lastName },\n space: this.appInfo.requiredSpaceType\n ? {\n type: this.appInfo.requiredSpaceType,\n title: spaceTitle,\n }\n : undefined,\n };\n this.userRecordService.initUserRecord(request).subscribe({\n next: () => this.onLoggedIn(userCredential),\n error: (err) => {\n this.analyticsService.logEvent('FailedToSetUserTitle');\n this.errorLogger.logError(err, 'Failed to set user title', {\n feedback: false,\n });\n this.onLoggedIn(userCredential);\n },\n });\n })\n .catch(\n this.errorHandler(\n 'Failed to get Firebase ID token',\n 'FirebaseGetIdTokenFailed',\n ),\n );\n } catch (e) {\n if ((e as FirebaseError).code === 'auth/email-already-in-use') {\n this.switchToSignInForExistingAccount();\n return;\n }\n this.handleError(\n e,\n 'Failed to sign up with email',\n 'FailedToSignUpWithEmail',\n );\n }\n }\n\n public keyupEnter(): void {\n switch (this.sign()) {\n case 'in':\n this.signIn();\n break;\n case 'up':\n this.signUp().catch(() => this.errorHandler('Failed to sign up'));\n break;\n }\n }\n\n /**\n * The email already has an account (a returning user landed on Sign up).\n * That is not an error: move to the Sign in tab, keep the typed email and say why.\n */\n private switchToSignInForExistingAccount(): void {\n this.analyticsService.logEvent('SignUpEmailAlreadyInUse');\n this.setSigningWith(undefined);\n this.existingAccountHint.set(true);\n this.sign.set('in');\n }\n\n public signIn(): void {\n this.existingAccountHint.set(false);\n this.setSigningWith('email');\n this.email.set(this.email().trim());\n this.wrongPassword.set(false);\n this.saveEmailForReuse();\n // const auth = getAuth(getApp());\n const auth = this.getFirebaseAuth();\n signInWithEmailAndPassword(auth, this.email(), this.password())\n .then((userCredential) => {\n this.onLoggedIn(userCredential); // TODO: add analytics event\n })\n .catch(\n this.errorHandler('Failed to sign in with email & password', 'email'),\n );\n }\n\n private saveEmailForReuse(): void {\n localStorage.setItem('emailForSignIn', this.email());\n }\n\n public sendSignInLink(): void {\n this.setSigningWith('emailLink');\n this.email.set(this.email().trim());\n this.saveEmailForReuse();\n const actionURL = new URL('sign-in-from-email-link', document.baseURI);\n const returnTo = safeAuthReturnPath(this.returnTo());\n if (returnTo) actionURL.searchParams.set('returnTo', returnTo);\n sendSignInLinkToEmail(this.afAuth, this.email(), {\n url: actionURL.toString(),\n handleCodeInApp: true,\n })\n .then(() => {\n this.showToast(`Sign-in link has been sent to email: ${this.email()}`);\n this.setSigningWith(undefined);\n })\n .catch(\n this.errorHandler(\n 'Failed to send sign in link to email',\n 'FailedToSendSignInLinkToEmail',\n ),\n );\n }\n\n private showToast(message: string): void {\n this.toastController\n .create({\n message,\n position: 'middle',\n keyboardClose: true,\n duration: 3000,\n color: 'tertiary',\n icon: 'send-outline',\n buttons: [{ icon: 'close', role: 'cancel' }],\n })\n .then((toast) => {\n toast\n .present()\n .catch(\n this.errorLogger.logErrorHandler(\n 'Failed to present toast about password reset email sent success',\n ),\n );\n });\n }\n\n public resetPassword(): void {\n this.setSigningWith('resetPassword');\n sendPasswordResetEmail(this.afAuth, this.email())\n .then(() => {\n this.setSigningWith(undefined);\n this.showToast(\n `Password reset link has been sent to email: ${this.email()}`,\n );\n })\n .catch(\n this.errorHandler(\n 'Failed to send password reset email',\n 'FailedToSendPasswordResetEmail',\n ),\n );\n }\n\n private sendVerificationEmail(userCredential: UserCredential): void {\n setTimeout(async () => {\n try {\n await sendEmailVerification(userCredential.user);\n } catch (e) {\n this.handleError(e, 'Failed to send verification email');\n }\n });\n }\n\n private onLoggedIn(userCredential: UserCredential): void {\n this.setSigningWith(undefined);\n this.loggedIn.emit(userCredential);\n }\n\n private errorHandler(\n m: string,\n eventName?: string,\n eventParams?: Record<string, string>,\n ): (err: unknown) => void {\n return (err) => this.handleError(err, m, eventName, eventParams);\n }\n\n private handleError(\n err: unknown,\n m: string,\n eventName?: string,\n eventParams?: Record<string, string>,\n ): void {\n this.setSigningWith(undefined);\n if (eventName) {\n this.analyticsService.logEvent(eventName, eventParams);\n }\n if ((err as FirebaseError).code === 'auth/wrong-password') {\n this.wrongPassword.set(true);\n return;\n }\n this.errorLogger.logError(err, m, {\n report: !(err as { code: unknown }).code,\n });\n }\n\n private setSigningWith(signingWith?: EmailFormSigningWith): void {\n this.signingWith.set(signingWith);\n this.signingWithChange.emit(signingWith);\n }\n\n signChanged(): void {\n if (this.sign() === 'up') {\n this.existingAccountHint.set(false);\n }\n this.setFocusToEmail();\n }\n\n ionViewDidEnter(): void {\n this.setSigningWith(undefined);\n this.setFocusToEmail();\n }\n\n // Focus is deliberately not moved (the inputs are not referenced from the template, and a programmatic focus\n // opens the on-screen keyboard on mobile). These used to call setFocusToInput(undefined), which only logged\n // \"can not set focus to undefined input\" to the console, three times on every login page.\n private setFocusToEmail(): void {\n // no-op\n }\n\n private setFocusToSpaceTitle(): void {\n // no-op\n }\n}\n","<div class=\"ion-padding-horizontal\"></div>\n<ion-card>\n <ion-item-divider color=\"light\" class=\"ion-no-padding\">\n <ion-segment\n [ngModel]=\"sign()\"\n (ngModelChange)=\"sign.set($event)\"\n (ionChange)=\"signChanged()\"\n >\n <ion-segment-button value=\"up\" layout=\"icon-start\">\n <ion-icon name=\"person-add\"></ion-icon>\n <ion-label>Sign up</ion-label>\n </ion-segment-button>\n <ion-segment-button value=\"in\" layout=\"icon-start\">\n <ion-icon name=\"enter-outline\" />\n <ion-label>Sign in</ion-label>\n </ion-segment-button>\n </ion-segment>\n </ion-item-divider>\n <!--\t<ion-item-divider color=\"light\">-->\n <!--\t\t<ion-label color=\"medium\" style=\"text-align: center; width: 100%\">-->\n <!--\t\t\tOr login with email-->\n <!--\t\t</ion-label>-->\n <!--\t</ion-item-divider>-->\n <ion-card-content class=\"ion-no-padding\">\n <ion-item>\n <ion-label class=\"ion-margin-end\">\n <ion-icon name=\"mail-outline\" />\n </ion-label>\n <ion-input\n [disabled]=\"!!signingWith()\"\n [ngModel]=\"email()\"\n (ngModelChange)=\"email.set($event)\"\n email\n type=\"email\"\n name=\"email\"\n id=\"email\"\n required\n placeholder=\"my@work-or-personal.email\"\n (keyup.enter)=\"keyupEnter()\"\n />\n </ion-item>\n @switch (sign()) {\n @case ('up') {\n <ion-item>\n <ion-label class=\"ion-margin-end\">\n <ion-icon name=\"person-add-outline\" />\n </ion-label>\n <ion-input\n name=\"first_name\"\n placeholder=\"First name\"\n [ngModel]=\"firstName()\"\n (ngModelChange)=\"firstName.set($event)\"\n type=\"text\"\n required\n (keyup.enter)=\"keyupEnter()\"\n [disabled]=\"!!signingWith()\"\n />\n <ion-input\n name=\"last_name\"\n placeholder=\"Last name\"\n [ngModel]=\"lastName()\"\n (ngModelChange)=\"lastName.set($event)\"\n type=\"text\"\n required\n (keyup.enter)=\"keyupEnter()\"\n [disabled]=\"!!signingWith()\"\n />\n </ion-item>\n @if (appInfo.requiredSpaceType === 'company') {\n <ion-item>\n <ion-label position=\"stacked\">Company name</ion-label>\n <ion-input\n #teamTitleInput\n placeholder=\"required\"\n required\n [ngModel]=\"spaceTitle()\"\n (ngModelChange)=\"spaceTitle.set($event)\"\n />\n </ion-item>\n }\n }\n @case ('in') {\n @if (existingAccountHint()) {\n <ion-item class=\"existing-account-hint\" role=\"status\">\n <ion-label color=\"primary\" class=\"ion-text-wrap\">\n This email already has an account. Enter your password to sign in,\n or get a sign-in link by email.\n </ion-label>\n </ion-item>\n }\n <ion-item>\n <ion-label class=\"ion-margin-end\">\n <ion-icon name=\"key-outline\" />\n </ion-label>\n <ion-input\n [ngModel]=\"password()\"\n (ngModelChange)=\"password.set($event)\"\n placeholder=\"Password\"\n type=\"password\"\n required\n (keyup.enter)=\"keyupEnter()\"\n [disabled]=\"!!signingWith()\"\n />\n <ion-buttons slot=\"end\">\n <ion-button\n color=\"danger\"\n [disabled]=\"!validEmail\"\n (click)=\"resetPassword()\"\n title=\"Send email with a link to reset password \"\n >\n <ion-label>Forgot? Reset!</ion-label>\n </ion-button>\n </ion-buttons>\n </ion-item>\n @if (wrongPassword()) {\n <ion-item>\n <ion-label color=\"danger\">Wrong password</ion-label>\n </ion-item>\n }\n }\n }\n </ion-card-content>\n <ion-card-content class=\"email-login-actions\">\n @switch (sign()) {\n @case ('up') {\n <ion-button\n [disabled]=\"\n !!signingWith() || !validEmail || (!firstName() && !lastName())\n \"\n (click)=\"signUp()\"\n >\n <ion-icon name=\"enter-outline\" slot=\"start\" />\n @if (signingWith() === 'email') {\n <ion-label>Signing up...</ion-label>\n <ion-spinner\n class=\"ion-margin-start\"\n slot=\"end\"\n name=\"lines-small\"\n />\n } @else {\n <ion-label>Sign up</ion-label>\n }\n </ion-button>\n }\n @case ('in') {\n <ion-button\n [disabled]=\"!!signingWith() || !validEmail || !password()\"\n (click)=\"signIn()\"\n >\n <ion-icon name=\"enter-outline\" slot=\"start\" />\n @if (signingWith() === 'email') {\n <ion-label>Signing in...</ion-label>\n <ion-spinner\n class=\"ion-margin-start\"\n slot=\"end\"\n name=\"lines-small\"\n />\n } @else {\n <ion-label>\n <b>Sign in</b\n ><ion-text\n class=\"password-button-suffix\"\n color=\"light\"\n style=\"text-transform: none\"\n > with password\n </ion-text>\n </ion-label>\n }\n </ion-button>\n <ion-button disabled=\"disabled\" fill=\"clear\" color=\"medium\">\n or\n </ion-button>\n <ion-button\n size=\"small\"\n [disabled]=\"!validEmail || signingWith()\"\n (click)=\"sendSignInLink()\"\n fill=\"outline\"\n color=\"tertiary\"\n >\n <ion-icon name=\"mail-outline\" slot=\"start\" />\n <ion-label>Get sign-in link</ion-label>\n </ion-button>\n }\n }\n </ion-card-content>\n</ion-card>\n"]}
|
|
1
|
+
{"version":3,"file":"email-login-form.component.js","sourceRoot":"","sources":["../../../../../../../../../libs/auth/ui/src/lib/pages/login-page/email-login-form/email-login-form.component.ts","../../../../../../../../../libs/auth/ui/src/lib/pages/login-page/email-login-form/email-login-form.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,YAAY,EAEZ,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,eAAe,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jFpC,+hMA0LA,qkBDzHI,WAAW,2sBACX,OAAO,yLACP,cAAc,kGACd,UAAU,uJACV,gBAAgB,qIAChB,OAAO,2JACP,QAAQ,6FACR,cAAc,+EACd,OAAO,0NACP,QAAQ,8eACR,UAAU,yGACV,OAAO,gFACP,SAAS,sRACT,UAAU;;2FAGD,uBAAuB;kBAtBnC,SAAS;+BACE,wBAAwB,mBAGjB,uBAAuB,CAAC,MAAM,WACtC;wBACP,WAAW;wBACX,OAAO;wBACP,cAAc;wBACd,UAAU;wBACV,gBAAgB;wBAChB,OAAO;wBACP,QAAQ;wBACR,cAAc;wBACd,OAAO;wBACP,QAAQ;wBACR,UAAU;wBACV,OAAO;wBACP,SAAS;wBACT,UAAU;qBACX;;sBAqCA,MAAM;;sBAGN,MAAM;0DAE6C,YAAY,yEACP,iBAAiB","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n OnInit,\n Output,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\nimport {\n Auth,\n sendSignInLinkToEmail,\n} from 'firebase/auth';\nimport { SNEAT_FIREBASE_AUTH } from '@sneat/core';\nimport { FormsModule } from '@angular/forms';\nimport {\n ToastController,\n IonButton,\n IonButtons,\n IonCard,\n IonCardContent,\n IonIcon,\n IonInput,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonSegment,\n IonSegmentButton,\n IonSpinner,\n IonText,\n} from '@ionic/angular';\nimport { SneatApiService } from '@sneat/api';\nimport {\n IInitUserRecordRequest,\n SneatAuthStateService,\n UserRecordService,\n} from '@sneat/auth-core';\nimport { createSetFocusToInput } from '@sneat/ui';\nimport {\n AnalyticsService,\n APP_INFO,\n IAnalyticsService,\n IAppInfo,\n} from '@sneat/core';\nimport { ErrorLogger, IErrorLogger } from '@sneat/core';\nimport { RandomIdService } from '@sneat/random';\nimport { UserCredential, sendEmailVerification } from 'firebase/auth';\nimport { FirebaseError } from 'firebase/app';\nimport { safeAuthReturnPath } from '../safe-auth-return-path';\n\nexport type EmailFormSigningWith = 'email' | 'emailLink' | 'resetPassword';\nexport type AuthPanelInitialMode = 'sign-in' | 'sign-up';\nimport {\n createUserWithEmailAndPassword,\n signInWithEmailAndPassword,\n} from 'firebase/auth';\n\n@Component({\n selector: 'sneat-email-login-form',\n templateUrl: 'email-login-form.component.html',\n styleUrl: 'email-login-form.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n FormsModule,\n IonCard,\n IonItemDivider,\n IonSegment,\n IonSegmentButton,\n IonIcon,\n IonLabel,\n IonCardContent,\n IonItem,\n IonInput,\n IonSpinner,\n IonText,\n IonButton,\n IonButtons,\n ],\n})\nexport class EmailLoginFormComponent implements OnInit {\n readonly returnTo = input<string | undefined>();\n /**\n * Which tab the form opens on. Defaults to 'sign-in' because most visitors are\n * returning users; pass 'sign-up' to open on the registration tab.\n */\n readonly initialMode = input<AuthPanelInitialMode | undefined>();\n readonly appInfo = inject<IAppInfo>(APP_INFO);\n private readonly analyticsService =\n inject<IAnalyticsService>(AnalyticsService);\n private readonly errorLogger = inject<IErrorLogger>(ErrorLogger);\n private readonly toastController = inject(ToastController);\n private readonly afAuth = inject(SNEAT_FIREBASE_AUTH);\n private readonly randomIdService = inject(RandomIdService);\n private readonly sneatApiService = inject(SneatApiService);\n private readonly userRecordService = inject(UserRecordService);\n private readonly authStateService = inject(SneatAuthStateService, {\n optional: true,\n });\n\n /** The selected tab: 'in' is Sign in (existing account), 'up' is Sign up (new account). */\n protected readonly sign = signal<'in' | 'up'>('in');\n /** Set when a sign-up attempt found the email already registered; shows a hint on the Sign in tab. */\n protected readonly existingAccountHint = signal(false);\n protected readonly email = signal('');\n protected readonly password = signal('');\n protected readonly firstName = signal('');\n protected readonly lastName = signal('');\n protected readonly spaceTitle = signal('');\n protected readonly wrongPassword = signal(false);\n\n protected readonly signingWith = signal<EmailFormSigningWith | undefined>(\n undefined,\n );\n\n @Output() readonly signingWithChange = new EventEmitter<\n EmailFormSigningWith | undefined\n >();\n @Output() readonly loggedIn = new EventEmitter<UserCredential>();\n\n protected readonly emailInput = viewChild<IonInput>('emailInput');\n protected readonly spaceTitleInput = viewChild<IonInput>('spaceTitleInput');\n\n public readonly setFocusToInput = createSetFocusToInput(this.errorLogger);\n\n constructor() {\n const email = localStorage.getItem('emailForSignIn') || '';\n this.email.set(email);\n if (this.authStateService) {\n this.authStateService.authStatus.subscribe((status) => {\n if (status === 'notAuthenticated') {\n this.setSigningWith(undefined);\n }\n });\n }\n }\n\n ngOnInit(): void {\n // Sign in is the default tab. A consumer can explicitly choose the first\n // view without restricting later user toggles.\n const initialMode = this.initialMode();\n if (initialMode) {\n this.sign.set(initialMode === 'sign-in' ? 'in' : 'up');\n }\n }\n\n public get validEmail(): boolean {\n const email = this.email(),\n i = email?.indexOf('@');\n return i > 0 && i < email.length - 1;\n }\n\n public getFirebaseAuth(): Auth {\n // Since 0.27.0 the injected instance IS the firebase modular `Auth`, so the\n // `as unknown as Auth` cast this used to need (angular/angularfire#3402 —\n // @angular/fire's `Auth` was a distinct nominal class) is gone.\n return this.afAuth;\n }\n\n public async signUp(): Promise<void> {\n if (!this.firstName()) {\n // this.toaster.showToast('Full name is required');\n return;\n }\n // this.signingWith = 'email';\n const email = this.email().trim();\n this.email.set(email);\n const firstName = this.firstName().trim();\n const lastName = this.lastName().trim();\n if (!email) {\n alert('Email is a required field');\n return;\n }\n if (!firstName) {\n alert('First name is a required field');\n return;\n }\n if (!lastName) {\n alert('Last name is a required field');\n return;\n }\n const spaceTitle = this.spaceTitle().trim();\n this.spaceTitle.set(spaceTitle);\n if (this.appInfo.requiredSpaceType && !spaceTitle) {\n alert('Company title is a required field');\n this.setFocusToSpaceTitle();\n return;\n }\n localStorage.setItem('emailForSignIn', email);\n const password = this.randomIdService.newRandomId({ len: 9 });\n\n this.setSigningWith('email');\n try {\n // const auth = getAuth(getApp());\n const auth = this.getFirebaseAuth();\n const userCredential = await createUserWithEmailAndPassword(\n auth,\n email,\n password,\n );\n this.sendVerificationEmail(userCredential);\n userCredential.user\n ?.getIdToken()\n .then((token) => {\n this.sneatApiService.setApiAuthToken(token);\n const request: IInitUserRecordRequest = {\n authProvider: 'password',\n email,\n ianaTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,\n names: { firstName, lastName },\n space: this.appInfo.requiredSpaceType\n ? {\n type: this.appInfo.requiredSpaceType,\n title: spaceTitle,\n }\n : undefined,\n };\n this.userRecordService.initUserRecord(request).subscribe({\n next: () => this.onLoggedIn(userCredential),\n error: (err) => {\n this.analyticsService.logEvent('FailedToSetUserTitle');\n this.errorLogger.logError(err, 'Failed to set user title', {\n feedback: false,\n });\n this.onLoggedIn(userCredential);\n },\n });\n })\n .catch(\n this.errorHandler(\n 'Failed to get Firebase ID token',\n 'FirebaseGetIdTokenFailed',\n ),\n );\n } catch (e) {\n if ((e as FirebaseError).code === 'auth/email-already-in-use') {\n this.switchToSignInForExistingAccount();\n return;\n }\n this.handleError(\n e,\n 'Failed to sign up with email',\n 'FailedToSignUpWithEmail',\n );\n }\n }\n\n public keyupEnter(): void {\n switch (this.sign()) {\n case 'in':\n this.signIn();\n break;\n case 'up':\n this.signUp().catch(() => this.errorHandler('Failed to sign up'));\n break;\n }\n }\n\n /**\n * The email already has an account (a returning user landed on Sign up).\n * That is not an error: move to the Sign in tab, keep the typed email and say why.\n */\n private switchToSignInForExistingAccount(): void {\n this.analyticsService.logEvent('SignUpEmailAlreadyInUse');\n this.setSigningWith(undefined);\n this.existingAccountHint.set(true);\n this.sign.set('in');\n }\n\n public signIn(): void {\n this.existingAccountHint.set(false);\n this.setSigningWith('email');\n this.email.set(this.email().trim());\n this.wrongPassword.set(false);\n this.saveEmailForReuse();\n // const auth = getAuth(getApp());\n const auth = this.getFirebaseAuth();\n signInWithEmailAndPassword(auth, this.email(), this.password())\n .then((userCredential) => {\n this.onLoggedIn(userCredential); // TODO: add analytics event\n })\n .catch(\n this.errorHandler('Failed to sign in with email & password', 'email'),\n );\n }\n\n private saveEmailForReuse(): void {\n localStorage.setItem('emailForSignIn', this.email());\n }\n\n public sendSignInLink(): void {\n this.setSigningWith('emailLink');\n this.email.set(this.email().trim());\n this.saveEmailForReuse();\n const actionURL = new URL('sign-in-from-email-link', document.baseURI);\n const returnTo = safeAuthReturnPath(this.returnTo());\n if (returnTo) actionURL.searchParams.set('returnTo', returnTo);\n sendSignInLinkToEmail(this.afAuth, this.email(), {\n url: actionURL.toString(),\n handleCodeInApp: true,\n })\n .then(() => {\n this.showToast(`Sign-in link has been sent to email: ${this.email()}`);\n this.setSigningWith(undefined);\n })\n .catch(\n this.errorHandler(\n 'Failed to send sign in link to email',\n 'FailedToSendSignInLinkToEmail',\n ),\n );\n }\n\n private showToast(message: string): void {\n this.toastController\n .create({\n message,\n position: 'middle',\n keyboardClose: true,\n duration: 3000,\n color: 'tertiary',\n icon: 'send-outline',\n buttons: [{ icon: 'close', role: 'cancel' }],\n })\n .then((toast) => {\n toast\n .present()\n .catch(\n this.errorLogger.logErrorHandler(\n 'Failed to present toast about password reset email sent success',\n ),\n );\n });\n }\n\n public resetPassword(): void {\n if (this.signingWith()) return;\n this.setSigningWith('resetPassword');\n this.sneatApiService\n .postAsAnonymous<void>('auth/request-password-reset', {\n email: this.email(),\n returnUrl: this.passwordResetReturnUrl(),\n })\n .subscribe({\n next: () => {\n this.setSigningWith(undefined);\n this.showToast(\n 'If an account exists for this email, password reset instructions will be sent.',\n );\n },\n error: this.errorHandler(\n 'Failed to send password reset email',\n 'FailedToSendPasswordResetEmail',\n ),\n });\n }\n\n private passwordResetReturnUrl(): string {\n const safeReturnTo = safeAuthReturnPath(this.returnTo());\n return new URL(safeReturnTo ?? '/login', window.location.origin).toString();\n }\n\n private sendVerificationEmail(userCredential: UserCredential): void {\n setTimeout(async () => {\n try {\n await sendEmailVerification(userCredential.user);\n } catch (e) {\n this.handleError(e, 'Failed to send verification email');\n }\n });\n }\n\n private onLoggedIn(userCredential: UserCredential): void {\n this.setSigningWith(undefined);\n this.loggedIn.emit(userCredential);\n }\n\n private errorHandler(\n m: string,\n eventName?: string,\n eventParams?: Record<string, string>,\n ): (err: unknown) => void {\n return (err) => this.handleError(err, m, eventName, eventParams);\n }\n\n private handleError(\n err: unknown,\n m: string,\n eventName?: string,\n eventParams?: Record<string, string>,\n ): void {\n this.setSigningWith(undefined);\n if (eventName) {\n this.analyticsService.logEvent(eventName, eventParams);\n }\n if ((err as FirebaseError).code === 'auth/wrong-password') {\n this.wrongPassword.set(true);\n return;\n }\n this.errorLogger.logError(err, m, {\n report: !(err as { code: unknown }).code,\n });\n }\n\n private setSigningWith(signingWith?: EmailFormSigningWith): void {\n this.signingWith.set(signingWith);\n this.signingWithChange.emit(signingWith);\n }\n\n signChanged(): void {\n if (this.sign() === 'up') {\n this.existingAccountHint.set(false);\n }\n this.setFocusToEmail();\n }\n\n ionViewDidEnter(): void {\n this.setSigningWith(undefined);\n this.setFocusToEmail();\n }\n\n // Focus is deliberately not moved (the inputs are not referenced from the template, and a programmatic focus\n // opens the on-screen keyboard on mobile). These used to call setFocusToInput(undefined), which only logged\n // \"can not set focus to undefined input\" to the console, three times on every login page.\n private setFocusToEmail(): void {\n // no-op\n }\n\n private setFocusToSpaceTitle(): void {\n // no-op\n }\n}\n","<div class=\"ion-padding-horizontal\"></div>\n<ion-card>\n <ion-item-divider color=\"light\" class=\"ion-no-padding\">\n <ion-segment\n [ngModel]=\"sign()\"\n (ngModelChange)=\"sign.set($event)\"\n (ionChange)=\"signChanged()\"\n >\n <ion-segment-button value=\"up\" layout=\"icon-start\">\n <ion-icon name=\"person-add\"></ion-icon>\n <ion-label>Sign up</ion-label>\n </ion-segment-button>\n <ion-segment-button value=\"in\" layout=\"icon-start\">\n <ion-icon name=\"enter-outline\" />\n <ion-label>Sign in</ion-label>\n </ion-segment-button>\n </ion-segment>\n </ion-item-divider>\n <!--\t<ion-item-divider color=\"light\">-->\n <!--\t\t<ion-label color=\"medium\" style=\"text-align: center; width: 100%\">-->\n <!--\t\t\tOr login with email-->\n <!--\t\t</ion-label>-->\n <!--\t</ion-item-divider>-->\n <ion-card-content class=\"ion-no-padding\">\n <ion-item>\n <ion-label class=\"ion-margin-end\">\n <ion-icon name=\"mail-outline\" />\n </ion-label>\n <ion-input\n [disabled]=\"!!signingWith()\"\n [ngModel]=\"email()\"\n (ngModelChange)=\"email.set($event)\"\n email\n type=\"email\"\n name=\"email\"\n id=\"email\"\n required\n placeholder=\"my@work-or-personal.email\"\n (keyup.enter)=\"keyupEnter()\"\n />\n </ion-item>\n @switch (sign()) {\n @case ('up') {\n <ion-item>\n <ion-label class=\"ion-margin-end\">\n <ion-icon name=\"person-add-outline\" />\n </ion-label>\n <ion-input\n name=\"first_name\"\n placeholder=\"First name\"\n [ngModel]=\"firstName()\"\n (ngModelChange)=\"firstName.set($event)\"\n type=\"text\"\n required\n (keyup.enter)=\"keyupEnter()\"\n [disabled]=\"!!signingWith()\"\n />\n <ion-input\n name=\"last_name\"\n placeholder=\"Last name\"\n [ngModel]=\"lastName()\"\n (ngModelChange)=\"lastName.set($event)\"\n type=\"text\"\n required\n (keyup.enter)=\"keyupEnter()\"\n [disabled]=\"!!signingWith()\"\n />\n </ion-item>\n @if (appInfo.requiredSpaceType === 'company') {\n <ion-item>\n <ion-label position=\"stacked\">Company name</ion-label>\n <ion-input\n #teamTitleInput\n placeholder=\"required\"\n required\n [ngModel]=\"spaceTitle()\"\n (ngModelChange)=\"spaceTitle.set($event)\"\n />\n </ion-item>\n }\n }\n @case ('in') {\n @if (existingAccountHint()) {\n <ion-item class=\"existing-account-hint\" role=\"status\">\n <ion-label color=\"primary\" class=\"ion-text-wrap\">\n This email already has an account. Enter your password to sign in,\n or get a sign-in link by email.\n </ion-label>\n </ion-item>\n }\n <ion-item>\n <ion-label class=\"ion-margin-end\">\n <ion-icon name=\"key-outline\" />\n </ion-label>\n <ion-input\n [ngModel]=\"password()\"\n (ngModelChange)=\"password.set($event)\"\n placeholder=\"Password\"\n type=\"password\"\n required\n (keyup.enter)=\"keyupEnter()\"\n [disabled]=\"!!signingWith()\"\n />\n <ion-buttons slot=\"end\">\n <ion-button\n color=\"danger\"\n [disabled]=\"!validEmail\"\n (click)=\"resetPassword()\"\n title=\"Send email with a link to reset password \"\n >\n <ion-label>Forgot? Reset!</ion-label>\n </ion-button>\n </ion-buttons>\n </ion-item>\n @if (wrongPassword()) {\n <ion-item>\n <ion-label color=\"danger\">Wrong password</ion-label>\n </ion-item>\n }\n }\n }\n </ion-card-content>\n <ion-card-content class=\"email-login-actions\">\n @switch (sign()) {\n @case ('up') {\n <ion-button\n [disabled]=\"\n !!signingWith() || !validEmail || (!firstName() && !lastName())\n \"\n (click)=\"signUp()\"\n >\n <ion-icon name=\"enter-outline\" slot=\"start\" />\n @if (signingWith() === 'email') {\n <ion-label>Signing up...</ion-label>\n <ion-spinner\n class=\"ion-margin-start\"\n slot=\"end\"\n name=\"lines-small\"\n />\n } @else {\n <ion-label>Sign up</ion-label>\n }\n </ion-button>\n }\n @case ('in') {\n <ion-button\n [disabled]=\"!!signingWith() || !validEmail || !password()\"\n (click)=\"signIn()\"\n >\n <ion-icon name=\"enter-outline\" slot=\"start\" />\n @if (signingWith() === 'email') {\n <ion-label>Signing in...</ion-label>\n <ion-spinner\n class=\"ion-margin-start\"\n slot=\"end\"\n name=\"lines-small\"\n />\n } @else {\n <ion-label>\n <b>Sign in</b\n ><ion-text\n class=\"password-button-suffix\"\n color=\"light\"\n style=\"text-transform: none\"\n > with password\n </ion-text>\n </ion-label>\n }\n </ion-button>\n <ion-button disabled=\"disabled\" fill=\"clear\" color=\"medium\">\n or\n </ion-button>\n <ion-button\n size=\"small\"\n [disabled]=\"!validEmail || signingWith()\"\n (click)=\"sendSignInLink()\"\n fill=\"outline\"\n color=\"tertiary\"\n >\n <ion-icon name=\"mail-outline\" slot=\"start\" />\n <ion-label>Get sign-in link</ion-label>\n </ion-button>\n }\n }\n </ion-card-content>\n</ion-card>\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, computed, inject, ChangeDetectionStrategy } from '@angular/core';
|
|
1
|
+
import { Component, computed, inject, ChangeDetectionStrategy, signal } from '@angular/core';
|
|
2
2
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
3
3
|
import { ActivatedRoute } from '@angular/router';
|
|
4
4
|
import { NavController, IonBackButton, IonButton, IonButtons, IonCard, IonCardContent, IonContent, IonHeader, IonSpinner, IonText, IonTitle, IonToolbar, } from '@ionic/angular';
|
|
@@ -6,9 +6,10 @@ import { LoginEventsHandler, SneatAuthStateService, SneatUserService, isSneatAcc
|
|
|
6
6
|
import { AnalyticsService, APP_INFO, clearCurrentSpace, currentSpacePath, readCurrentSpace, SpaceTypeFamily, } from '@sneat/core';
|
|
7
7
|
import { RandomIdService } from '@sneat/random';
|
|
8
8
|
import { ClassName, SneatBaseComponent } from '@sneat/ui';
|
|
9
|
-
import { combineLatest
|
|
9
|
+
import { combineLatest } from 'rxjs';
|
|
10
10
|
import { AuthPanelComponent } from './auth-panel.component';
|
|
11
11
|
import { safeAuthReturnPath } from './safe-auth-return-path';
|
|
12
|
+
import { clearLoginRedirectIntent, consumeLoginRedirectIntent, } from './login-redirect-intent';
|
|
12
13
|
import * as i0 from "@angular/core";
|
|
13
14
|
export class LoginPageComponent extends SneatBaseComponent {
|
|
14
15
|
constructor() {
|
|
@@ -29,12 +30,30 @@ export class LoginPageComponent extends SneatBaseComponent {
|
|
|
29
30
|
!!this.authState()?.user?.uid &&
|
|
30
31
|
!this.authState()?.user?.isAnonymous, /* @ts-ignore */
|
|
31
32
|
...(ngDevMode ? [{ debugName: "isAuthenticated" }] : /* istanbul ignore next */ []));
|
|
33
|
+
this.loginEntry = signal('resolving', /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "loginEntry" }] : /* istanbul ignore next */ []));
|
|
35
|
+
this.pageActive = true;
|
|
36
|
+
this.loginEntryResolved = false;
|
|
37
|
+
this.redirectStarted = false;
|
|
38
|
+
this.loginRedirectIntent = consumeLoginRedirectIntent();
|
|
39
|
+
this.showAccountChoice = computed(() => this.loginEntry() === 'existing-session' && this.isAuthenticated(), /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "showAccountChoice" }] : /* istanbul ignore next */ []));
|
|
32
41
|
// While Firebase is still resolving the session — the initial state, and the
|
|
33
42
|
// brief window right after a signInWithRedirect return — show a "signing you
|
|
34
43
|
// in" spinner instead of flashing the sign-in form before we navigate onward.
|
|
35
44
|
this.isAuthenticating = computed(() => this.authState()?.status === 'authenticating' &&
|
|
36
45
|
this.authState()?.loadingPhase !== 'failed', /* @ts-ignore */
|
|
37
46
|
...(ngDevMode ? [{ debugName: "isAuthenticating" }] : /* istanbul ignore next */ []));
|
|
47
|
+
this.isPreparingFreshAccount = computed(() => this.loginEntry() === 'fresh-sign-in' &&
|
|
48
|
+
this.isAuthenticated() &&
|
|
49
|
+
!this.isAccountReady() &&
|
|
50
|
+
this.authState()?.loadingPhase !== 'failed' &&
|
|
51
|
+
this.userState()?.userRecordStatus !== 'failed', /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "isPreparingFreshAccount" }] : /* istanbul ignore next */ []));
|
|
53
|
+
this.isRedirectingAfterFreshSignIn = computed(() => this.loginEntry() === 'fresh-sign-in' &&
|
|
54
|
+
this.isAuthenticated() &&
|
|
55
|
+
this.isAccountReady(), /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "isRedirectingAfterFreshSignIn" }] : /* istanbul ignore next */ []));
|
|
38
57
|
this.authState = toSignal(this.authStateService.authState);
|
|
39
58
|
this.userState = toSignal(this.userService.userState);
|
|
40
59
|
this.isAccountReady = computed(() => {
|
|
@@ -48,11 +67,27 @@ export class LoginPageComponent extends SneatBaseComponent {
|
|
|
48
67
|
return u?.displayName || u?.email || u?.uid || '';
|
|
49
68
|
}, /* @ts-ignore */
|
|
50
69
|
...(ngDevMode ? [{ debugName: "signedInAs" }] : /* istanbul ignore next */ []));
|
|
70
|
+
this.signedInWith = computed(() => {
|
|
71
|
+
const user = this.authState()?.user;
|
|
72
|
+
// providerId is the current provider only when Firebase has a single
|
|
73
|
+
// provider identity. Linked accounts expose a generic "firebase" value;
|
|
74
|
+
// do not mistake one of their linked providers for the active session.
|
|
75
|
+
const providerID = user?.providerId;
|
|
76
|
+
switch (providerID) {
|
|
77
|
+
case 'google.com': return 'Google';
|
|
78
|
+
case 'microsoft.com': return 'Microsoft';
|
|
79
|
+
case 'github.com': return 'GitHub';
|
|
80
|
+
case 'apple.com': return 'Apple';
|
|
81
|
+
case 'facebook.com': return 'Facebook';
|
|
82
|
+
case 'password': return 'email and password';
|
|
83
|
+
case 'phone': return 'phone';
|
|
84
|
+
default: return undefined;
|
|
85
|
+
}
|
|
86
|
+
}, /* @ts-ignore */
|
|
87
|
+
...(ngDevMode ? [{ debugName: "signedInWith" }] : /* istanbul ignore next */ []));
|
|
51
88
|
const appInfo = this.appInfo;
|
|
52
89
|
this.appTitle = appInfo.appTitle || 'Sneat.app';
|
|
53
|
-
|
|
54
|
-
this.redirectTo = safeAuthReturnPath(location.hash.substring(1));
|
|
55
|
-
}
|
|
90
|
+
this.refreshRedirectTarget();
|
|
56
91
|
this.to = this.route.snapshot.queryParams['to']; // should we subscribe? I believe no.
|
|
57
92
|
this.reason = this.route.snapshot.queryParams['reason'];
|
|
58
93
|
this.reasonDetail = this.route.snapshot.queryParams['reasonDetail'];
|
|
@@ -61,41 +96,107 @@ export class LoginPageComponent extends SneatBaseComponent {
|
|
|
61
96
|
mode === 'sign-up' || mode === 'sign-in' ? mode : undefined;
|
|
62
97
|
const action = location.hash.match(/[#&]action=(\w+)/);
|
|
63
98
|
this.action = action?.[1];
|
|
64
|
-
const userRecordLoaded = new Subject();
|
|
65
99
|
combineLatest([this.authStateService.authState, this.userService.userState])
|
|
66
|
-
.pipe(
|
|
100
|
+
.pipe(this.takeUntilDestroyed())
|
|
67
101
|
.subscribe({
|
|
68
|
-
next: ([authState, userState]) =>
|
|
69
|
-
const userRecord = userState.record;
|
|
70
|
-
if (!userRecord || !isSneatAccountReady(authState, userState))
|
|
71
|
-
return;
|
|
72
|
-
userRecordLoaded.next();
|
|
73
|
-
// Fall back to the persisted current space so it is restored after login,
|
|
74
|
-
// but only if the user actually has access to it.
|
|
75
|
-
const space = readCurrentSpace();
|
|
76
|
-
const hasAccess = !!space && (userRecord.spaceIDs?.includes(space.id) ||
|
|
77
|
-
(!!userRecord.spaces && space.id in userRecord.spaces));
|
|
78
|
-
if (space && !hasAccess) {
|
|
79
|
-
clearCurrentSpace();
|
|
80
|
-
}
|
|
81
|
-
const activePath = hasAccess ? currentSpacePath() : undefined;
|
|
82
|
-
const family = Object.entries(userRecord.spaces || {}).find(([, brief]) => brief.type === SpaceTypeFamily);
|
|
83
|
-
const familyPath = family
|
|
84
|
-
? `/space/${SpaceTypeFamily}/${family[0]}`
|
|
85
|
-
: undefined;
|
|
86
|
-
const redirectTo = this.redirectTo || activePath || familyPath || '/';
|
|
87
|
-
this.navController
|
|
88
|
-
.navigateRoot(redirectTo)
|
|
89
|
-
.catch((err) => {
|
|
90
|
-
this.errorLogger.logError(err, 'Failed to navigate back to ' + redirectTo);
|
|
91
|
-
});
|
|
92
|
-
},
|
|
102
|
+
next: ([authState, userState]) => this.handleAuthAndUserState(authState, userState),
|
|
93
103
|
error: this.errorHandler('Failed to get user state after login'),
|
|
94
104
|
});
|
|
95
105
|
}
|
|
106
|
+
// Ionic caches routed pages in its navigation stack. Refresh the target and
|
|
107
|
+
// auth-entry decision on each return to this page, and ignore auth updates
|
|
108
|
+
// while the page is covered by another view.
|
|
109
|
+
ionViewWillEnter() {
|
|
110
|
+
this.pageActive = true;
|
|
111
|
+
this.loginEntry.set('resolving');
|
|
112
|
+
this.loginEntryResolved = false;
|
|
113
|
+
this.redirectStarted = false;
|
|
114
|
+
this.refreshRedirectTarget();
|
|
115
|
+
const authState = this.authState();
|
|
116
|
+
if (authState && !this.loginEntryResolved) {
|
|
117
|
+
this.resolveLoginEntry(authState);
|
|
118
|
+
}
|
|
119
|
+
const userState = this.userState();
|
|
120
|
+
if (authState && userState) {
|
|
121
|
+
this.handleAuthAndUserState(authState, userState);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
ionViewWillLeave() {
|
|
125
|
+
this.pageActive = false;
|
|
126
|
+
}
|
|
127
|
+
refreshRedirectTarget() {
|
|
128
|
+
const hashTarget = location.hash.startsWith('#/')
|
|
129
|
+
? safeAuthReturnPath(location.hash.substring(1))
|
|
130
|
+
: undefined;
|
|
131
|
+
this.redirectTo =
|
|
132
|
+
hashTarget ||
|
|
133
|
+
safeAuthReturnPath(this.route.snapshot.queryParams['returnTo']) ||
|
|
134
|
+
this.loginRedirectIntent?.returnTo;
|
|
135
|
+
}
|
|
136
|
+
resolveLoginEntry(authState) {
|
|
137
|
+
// A session-check placeholder is not evidence that this visit began with
|
|
138
|
+
// an existing account or with a completed sign-in.
|
|
139
|
+
if (authState.status === 'authenticating' &&
|
|
140
|
+
authState.loadingPhase === 'checking-session' &&
|
|
141
|
+
!authState.user)
|
|
142
|
+
return;
|
|
143
|
+
this.loginEntryResolved = true;
|
|
144
|
+
const hasSignedInIdentity = (authState.status === 'authenticated' || !!authState.user?.uid) &&
|
|
145
|
+
authState.loadingPhase !== 'failed' &&
|
|
146
|
+
authState.user?.isAnonymous !== true;
|
|
147
|
+
this.loginEntry.set(hasSignedInIdentity
|
|
148
|
+
? this.loginRedirectIntent
|
|
149
|
+
? 'fresh-sign-in'
|
|
150
|
+
: 'existing-session'
|
|
151
|
+
: 'signed-out');
|
|
152
|
+
}
|
|
153
|
+
handleAuthAndUserState(authState, userState) {
|
|
154
|
+
if (!this.pageActive)
|
|
155
|
+
return;
|
|
156
|
+
if (!this.loginEntryResolved) {
|
|
157
|
+
this.resolveLoginEntry(authState);
|
|
158
|
+
if (!this.loginEntryResolved)
|
|
159
|
+
return;
|
|
160
|
+
if (this.loginEntry() === 'existing-session')
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
else if (this.loginEntry() === 'signed-out' &&
|
|
164
|
+
(authState.status === 'authenticated' || !!authState.user?.uid)) {
|
|
165
|
+
this.loginEntry.set('fresh-sign-in');
|
|
166
|
+
}
|
|
167
|
+
const userRecord = userState.record;
|
|
168
|
+
if (this.loginEntry() !== 'fresh-sign-in' ||
|
|
169
|
+
!userRecord ||
|
|
170
|
+
!isSneatAccountReady(authState, userState) ||
|
|
171
|
+
this.redirectStarted)
|
|
172
|
+
return;
|
|
173
|
+
clearLoginRedirectIntent();
|
|
174
|
+
this.loginRedirectIntent = undefined;
|
|
175
|
+
this.redirectStarted = true;
|
|
176
|
+
// Fall back to the persisted current space so it is restored after login,
|
|
177
|
+
// but only if the user actually has access to it.
|
|
178
|
+
const space = readCurrentSpace();
|
|
179
|
+
const hasAccess = !!space && (userRecord.spaceIDs?.includes(space.id) ||
|
|
180
|
+
(!!userRecord.spaces && space.id in userRecord.spaces));
|
|
181
|
+
if (space && !hasAccess) {
|
|
182
|
+
clearCurrentSpace();
|
|
183
|
+
}
|
|
184
|
+
const activePath = hasAccess ? currentSpacePath() : undefined;
|
|
185
|
+
const family = Object.entries(userRecord.spaces || {}).find(([, brief]) => brief.type === SpaceTypeFamily);
|
|
186
|
+
const familyPath = family
|
|
187
|
+
? `/space/${SpaceTypeFamily}/${family[0]}`
|
|
188
|
+
: undefined;
|
|
189
|
+
const redirectTo = this.redirectTo || activePath || familyPath || '/';
|
|
190
|
+
this.navController
|
|
191
|
+
.navigateRoot(redirectTo)
|
|
192
|
+
.catch((err) => {
|
|
193
|
+
this.redirectStarted = false;
|
|
194
|
+
this.errorLogger.logError(err, 'Failed to navigate back to ' + redirectTo);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
96
197
|
// Proceed into the app from the "already signed in" panel.
|
|
97
198
|
continueToApp() {
|
|
98
|
-
if (!this.isAccountReady())
|
|
199
|
+
if (!this.showAccountChoice() || !this.isAccountReady())
|
|
99
200
|
return;
|
|
100
201
|
const space = readCurrentSpace();
|
|
101
202
|
const userState = this.userState();
|
|
@@ -119,6 +220,8 @@ export class LoginPageComponent extends SneatBaseComponent {
|
|
|
119
220
|
// Sign out so the sign-in form is shown again (e.g. to log in as someone else).
|
|
120
221
|
reLogin() {
|
|
121
222
|
clearCurrentSpace();
|
|
223
|
+
this.loginEntry.set('signed-out');
|
|
224
|
+
this.loginEntryResolved = true;
|
|
122
225
|
this.authStateService
|
|
123
226
|
.signOut()
|
|
124
227
|
.catch(this.errorLogger.logErrorHandler('Failed to sign out for re-login'));
|
|
@@ -141,7 +244,7 @@ export class LoginPageComponent extends SneatBaseComponent {
|
|
|
141
244
|
useValue: 'LoginPageComponent',
|
|
142
245
|
},
|
|
143
246
|
RandomIdService,
|
|
144
|
-
], usesInheritance: true, ngImport: i0, template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button defaultHref=\"/\" />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n
|
|
247
|
+
], usesInheritance: true, ngImport: i0, template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button defaultHref=\"/\" />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n @if (!showAccountChoice()) {\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">Sign in with your Sneat account.</ion-text>\n </p>\n }\n\n @if (\n isAuthenticating() ||\n isPreparingFreshAccount() ||\n isRedirectingAfterFreshSignIn()\n ) {\n <ion-card>\n <ion-card-content class=\"ion-text-center ion-padding\">\n <ion-spinner name=\"lines\" />\n <p class=\"ion-no-margin ion-padding-top\">Signing you in\u2026</p>\n </ion-card-content>\n </ion-card>\n } @else if (showAccountChoice()) {\n <ion-card class=\"account-choice-card\">\n <ion-card-content class=\"ion-text-center ion-padding\">\n <h2 class=\"ion-no-margin\">\n @if (signedInAs()) {\n You\u2019re signed in as <strong>{{ signedInAs() }}</strong>\n } @else {\n You\u2019re already signed in\n }\n </h2>\n @if (signedInWith(); as provider) {\n <p class=\"ion-margin-top ion-margin-bottom\">Signed in with {{ provider }}</p>\n }\n @if (isAccountReady()) {\n <ion-button expand=\"block\" (click)=\"continueToApp()\">Continue to {{ appTitle }}</ion-button>\n }\n <ion-button\n expand=\"block\"\n fill=\"outline\"\n color=\"medium\"\n (click)=\"reLogin()\"\n >\n Use another account\n </ion-button>\n </ion-card-content>\n </ion-card>\n @if (!isAccountReady()) {\n <sneat-auth-panel\n [returnTo]=\"redirectTo\"\n [showIntro]=\"false\"\n [showCredentials]=\"false\"\n />\n }\n } @else {\n <sneat-auth-panel\n [returnTo]=\"redirectTo\"\n [initialMode]=\"initialMode\"\n [showIntro]=\"false\"\n />\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n If any issues get\n <a href=\"mailto:help@sneat.app?subject=Problem+with+login+at+Sneat.app\"\n >help@sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n", styles: [".account-choice-card{width:min(100% - 2rem,28rem);margin-inline:auto}\n"], dependencies: [{ kind: "component", type: AuthPanelComponent, selector: "sneat-auth-panel", inputs: ["returnTo", "initialMode", "showIntro", "showCredentials"], outputs: ["accountReadyChange"] }, { kind: "component", type: IonHeader, selector: "ion-header", inputs: ["collapse", "mode", "translucent"] }, { kind: "component", type: IonToolbar, selector: "ion-toolbar", inputs: ["color", "mode"] }, { kind: "component", type: IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"], outputs: ["ionFocus", "ionBlur"] }, { kind: "component", type: IonButtons, selector: "ion-buttons", inputs: ["collapse"] }, { kind: "component", type: IonBackButton, selector: "ion-back-button" }, { kind: "component", type: IonTitle, selector: "ion-title", inputs: ["color", "size"] }, { kind: "component", type: IonContent, selector: "ion-content", inputs: ["color", "fixedSlotPlacement", "forceOverscroll", "fullscreen", "scrollEvents", "scrollX", "scrollY"], outputs: ["ionScrollStart", "ionScroll", "ionScrollEnd"] }, { kind: "component", type: IonCardContent, selector: "ion-card-content", inputs: ["mode"] }, { kind: "component", type: IonText, selector: "ion-text", inputs: ["color", "mode"] }, { kind: "component", type: IonCard, selector: "ion-card", inputs: ["button", "color", "disabled", "download", "href", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
145
248
|
}
|
|
146
249
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: LoginPageComponent, decorators: [{
|
|
147
250
|
type: Component,
|
|
@@ -164,6 +267,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
164
267
|
useValue: 'LoginPageComponent',
|
|
165
268
|
},
|
|
166
269
|
RandomIdService,
|
|
167
|
-
], template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button defaultHref=\"/\" />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n
|
|
270
|
+
], template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button defaultHref=\"/\" />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n @if (!showAccountChoice()) {\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">Sign in with your Sneat account.</ion-text>\n </p>\n }\n\n @if (\n isAuthenticating() ||\n isPreparingFreshAccount() ||\n isRedirectingAfterFreshSignIn()\n ) {\n <ion-card>\n <ion-card-content class=\"ion-text-center ion-padding\">\n <ion-spinner name=\"lines\" />\n <p class=\"ion-no-margin ion-padding-top\">Signing you in\u2026</p>\n </ion-card-content>\n </ion-card>\n } @else if (showAccountChoice()) {\n <ion-card class=\"account-choice-card\">\n <ion-card-content class=\"ion-text-center ion-padding\">\n <h2 class=\"ion-no-margin\">\n @if (signedInAs()) {\n You\u2019re signed in as <strong>{{ signedInAs() }}</strong>\n } @else {\n You\u2019re already signed in\n }\n </h2>\n @if (signedInWith(); as provider) {\n <p class=\"ion-margin-top ion-margin-bottom\">Signed in with {{ provider }}</p>\n }\n @if (isAccountReady()) {\n <ion-button expand=\"block\" (click)=\"continueToApp()\">Continue to {{ appTitle }}</ion-button>\n }\n <ion-button\n expand=\"block\"\n fill=\"outline\"\n color=\"medium\"\n (click)=\"reLogin()\"\n >\n Use another account\n </ion-button>\n </ion-card-content>\n </ion-card>\n @if (!isAccountReady()) {\n <sneat-auth-panel\n [returnTo]=\"redirectTo\"\n [showIntro]=\"false\"\n [showCredentials]=\"false\"\n />\n }\n } @else {\n <sneat-auth-panel\n [returnTo]=\"redirectTo\"\n [initialMode]=\"initialMode\"\n [showIntro]=\"false\"\n />\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n If any issues get\n <a href=\"mailto:help@sneat.app?subject=Problem+with+login+at+Sneat.app\"\n >help@sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n", styles: [".account-choice-card{width:min(100% - 2rem,28rem);margin-inline:auto}\n"] }]
|
|
168
271
|
}], ctorParameters: () => [] });
|
|
169
272
|
//# sourceMappingURL=login-page.component.js.map
|