@sneat/auth-ui 0.27.39 → 0.27.41
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/components/user-auth-providers/user-auth-accounts.component.js +11 -5
- package/esm2022/lib/components/user-auth-providers/user-auth-accounts.component.js.map +1 -1
- package/esm2022/lib/components/user-auth-providers/user-auth-provider-status.js +7 -0
- package/esm2022/lib/components/user-auth-providers/user-auth-provider-status.js.map +1 -1
- package/esm2022/lib/pages/login-page/auth-panel.component.js +38 -3
- package/esm2022/lib/pages/login-page/auth-panel.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/components/user-auth-providers/user-auth-accounts.component.d.ts +6 -1
- package/lib/pages/login-page/auth-panel.component.d.ts +10 -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
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-page.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/pages/login-page/login-page.component.ts","../../../../../../../../libs/auth/ui/src/lib/pages/login-page/login-page.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,EACd,UAAU,EACV,SAAS,EACT,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,EAGhB,gBAAgB,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAA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IAEO,WAAW,CACjB,GAAY,EACZ,CAAS,EACT,SAAkB,EAClB,WAAoC;QAEpC,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE;YAChC,MAAM,EAAE,CAAE,GAAyB,CAAC,IAAI;SACzC,CAAC,CAAC;IACL,CAAC;8GA5KU,kBAAkB;kGAAlB,kBAAkB,0DARlB;YACT;gBACE,OAAO,EAAE,SAAS;gBAClB,QAAQ,EAAE,oBAAoB;aAC/B;YACD,eAAe;SAChB,iDCnEH,24EAoFA,4CDrCI,kBAAkB,mKAClB,SAAS,oGACT,UAAU,mFACV,SAAS,sRACT,UAAU,8EACV,aAAa,4DACb,QAAQ,iFACR,UAAU,kOACV,cAAc,+EACd,OAAO,gFACP,OAAO,yLACP,UAAU;;2FAWD,kBAAkB;kBA1B9B,SAAS;+BACE,aAAa,WAEd;wBACP,kBAAkB;wBAClB,SAAS;wBACT,UAAU;wBACV,SAAS;wBACT,UAAU;wBACV,aAAa;wBACb,QAAQ;wBACR,UAAU;wBACV,cAAc;wBACd,OAAO;wBACP,OAAO;wBACP,UAAU;qBACX,mBACgB,uBAAuB,CAAC,MAAM,aACpC;wBACT;4BACE,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,oBAAoB;yBAC/B;wBACD,eAAe;qBAChB","sourcesContent":["import { Component, computed, inject, ChangeDetectionStrategy } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute } from '@angular/router';\nimport {\n NavController,\n IonBackButton,\n IonButton,\n IonButtons,\n IonCard,\n IonCardContent,\n IonContent,\n IonHeader,\n IonSpinner,\n IonText,\n IonTitle,\n IonToolbar,\n} from '@ionic/angular';\nimport {\n ILoginEventsHandler,\n LoginEventsHandler,\n SneatAuthStateService,\n SneatUserService,\n isSneatAccountReady,\n} from '@sneat/auth-core';\nimport {\n AnalyticsService,\n APP_INFO,\n clearCurrentSpace,\n currentSpacePath,\n IAnalyticsService,\n IAppInfo,\n readCurrentSpace,\n SpaceTypeFamily,\n} from '@sneat/core';\nimport { RandomIdService } from '@sneat/random';\nimport { ClassName, SneatBaseComponent } from '@sneat/ui';\nimport { combineLatest, Subject, takeUntil } from 'rxjs';\nimport { AuthPanelComponent } from './auth-panel.component';\nimport { safeAuthReturnPath } from './safe-auth-return-path';\nimport type { AuthPanelInitialMode } from './email-login-form/email-login-form.component';\n\ntype Action = 'join' | 'refuse'; // TODO: inject provider for action descriptions/messages.\n\n@Component({\n selector: 'sneat-login',\n templateUrl: './login-page.component.html',\n imports: [\n AuthPanelComponent,\n IonHeader,\n IonToolbar,\n IonButton,\n IonButtons,\n IonBackButton,\n IonTitle,\n IonContent,\n IonCardContent,\n IonText,\n IonCard,\n IonSpinner,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: ClassName,\n useValue: 'LoginPageComponent',\n },\n RandomIdService,\n ],\n})\nexport class LoginPageComponent extends SneatBaseComponent {\n private readonly analyticsService =\n inject<IAnalyticsService>(AnalyticsService);\n private readonly route = inject(ActivatedRoute);\n private readonly navController = inject(NavController);\n private readonly userService = inject(SneatUserService);\n private readonly authStateService = inject(SneatAuthStateService);\n private appInfo = inject<IAppInfo>(APP_INFO);\n private readonly loginEventsHandler = inject<ILoginEventsHandler>(\n LoginEventsHandler,\n { optional: true },\n );\n\n protected readonly redirectTo?: string;\n protected readonly to?: string;\n // Free-text explanation of WHY sign-in is needed, passed by the calling page\n // as query params (rendered as escaped text — never as HTML):\n // reason — short heading, e.g. \"Sign in to create a new game\"\n // reasonDetail — optional sub-heading / one-line elaboration\n protected readonly reason?: string;\n protected readonly reasonDetail?: string;\n protected readonly action?: Action; // TODO: document possible values?\n // Optional `?mode=sign-up` or `?mode=sign-in` picks the tab the email form opens on.\n // Absent or unknown values leave the form on its default (Sign in).\n protected readonly initialMode?: AuthPanelInitialMode;\n\n protected readonly appTitle: string;\n\n // Surfaces the Firebase auth state on the login page itself: if the user is\n // already signed in (e.g. the app failed to navigate them onward) we show a\n // \"you are already signed in as X\" panel instead of the sign-in form, so an\n // authenticated-but-stuck state is obvious rather than looking like sign-in\n // is broken.\n protected readonly isAuthenticated = computed(\n () =>\n this.authState()?.status === 'authenticated' &&\n !!this.authState()?.user?.uid &&\n !this.authState()?.user?.isAnonymous,\n );\n // While Firebase is still resolving the session — the initial state, and the\n // brief window right after a signInWithRedirect return — show a \"signing you\n // in\" spinner instead of flashing the sign-in form before we navigate onward.\n protected readonly isAuthenticating = computed(\n () =>\n this.authState()?.status === 'authenticating' &&\n this.authState()?.loadingPhase !== 'failed',\n );\n private readonly authState = toSignal(this.authStateService.authState);\n private readonly userState = toSignal(this.userService.userState);\n protected readonly isAccountReady = computed(() => {\n const userState = this.userState();\n const authState = this.authState();\n return isSneatAccountReady(authState, userState);\n });\n protected readonly signedInAs = computed(() => {\n const u = this.authState()?.user;\n return u?.displayName || u?.email || u?.uid || '';\n });\n\n constructor() {\n super();\n const appInfo = this.appInfo;\n this.appTitle = appInfo.appTitle || 'Sneat.app';\n if (location.hash.startsWith('#/')) {\n this.redirectTo = safeAuthReturnPath(location.hash.substring(1));\n }\n this.to = this.route.snapshot.queryParams['to']; // should we subscribe? I believe no.\n this.reason = this.route.snapshot.queryParams['reason'];\n this.reasonDetail = this.route.snapshot.queryParams['reasonDetail'];\n const mode = this.route.snapshot.queryParams['mode'];\n this.initialMode =\n mode === 'sign-up' || mode === 'sign-in' ? mode : undefined;\n const action = location.hash.match(/[#&]action=(\\w+)/);\n this.action = action?.[1] as Action;\n\n const userRecordLoaded = new Subject<void>();\n combineLatest([this.authStateService.authState, this.userService.userState])\n .pipe(takeUntil(userRecordLoaded), this.takeUntilDestroyed())\n .subscribe({\n next: ([authState, userState]) => {\n const userRecord = userState.record;\n if (!userRecord || !isSneatAccountReady(authState, userState)) return;\n userRecordLoaded.next();\n // Fall back to the persisted current space so it is restored after login,\n // but only if the user actually has access to it.\n const space = readCurrentSpace();\n const hasAccess = !!space && (\n userRecord.spaceIDs?.includes(space.id) ||\n (!!userRecord.spaces && space.id in userRecord.spaces)\n );\n if (space && !hasAccess) {\n clearCurrentSpace();\n }\n const activePath = hasAccess ? currentSpacePath() : undefined;\n const family = Object.entries(userRecord.spaces || {}).find(\n ([, brief]) => brief.type === SpaceTypeFamily,\n );\n const familyPath = family\n ? `/space/${SpaceTypeFamily}/${family[0]}`\n : undefined;\n const redirectTo = this.redirectTo || activePath || familyPath || '/';\n this.navController\n .navigateRoot(redirectTo)\n .catch((err) => {\n this.errorLogger.logError(\n err,\n 'Failed to navigate back to ' + redirectTo,\n );\n });\n },\n error: this.errorHandler('Failed to get user state after login'),\n });\n }\n\n // Proceed into the app from the \"already signed in\" panel.\n protected continueToApp(): void {\n if (!this.isAccountReady()) return;\n const space = readCurrentSpace();\n const userState = this.userState();\n const hasAccess = !!space && !!userState?.record && (\n userState.record.spaceIDs?.includes(space.id) ||\n (!!userState.record.spaces && space.id in userState.record.spaces)\n );\n if (space && !hasAccess) {\n clearCurrentSpace();\n }\n const activePath = hasAccess ? currentSpacePath() : undefined;\n const family = Object.entries(userState?.record?.spaces || {}).find(\n ([, brief]) => brief.type === SpaceTypeFamily,\n );\n const familyPath = family\n ? `/space/${SpaceTypeFamily}/${family[0]}`\n : undefined;\n const redirectTo = this.redirectTo || activePath || familyPath || '/';\n this.navController\n .navigateRoot(redirectTo)\n .catch((err) => {\n this.errorLogger.logError(\n err,\n 'Failed to navigate to ' + redirectTo,\n );\n });\n }\n\n // Sign out so the sign-in form is shown again (e.g. to log in as someone else).\n protected reLogin(): void {\n clearCurrentSpace();\n this.authStateService\n .signOut()\n .catch(this.errorLogger.logErrorHandler('Failed to sign out for re-login'));\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 if (eventName) {\n this.analyticsService.logEvent(eventName, eventParams);\n }\n this.errorLogger.logError(err, m, {\n report: !(err as { code: unknown }).code,\n });\n }\n}\n","<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 <ion-text color=\"medium\">Sign in with your Sneat account.</ion-text>\n </p>\n\n @if (isAuthenticating()) {\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…</p>\n </ion-card-content>\n </ion-card>\n } @else if (isAuthenticated()) {\n <ion-card color=\"success\">\n <ion-card-content>\n <p>\n @if (signedInAs()) {\n You are already signed in as <strong>{{ signedInAs() }}</strong>.\n } @else {\n You are already signed in.\n }\n </p>\n @if (isAccountReady()) {\n <ion-button expand=\"block\" (click)=\"continueToApp()\">Continue</ion-button>\n } @else {\n <sneat-auth-panel\n [returnTo]=\"redirectTo\"\n [showIntro]=\"false\"\n [showCredentials]=\"false\"\n />\n }\n <ion-button\n expand=\"block\"\n fill=\"outline\"\n color=\"medium\"\n (click)=\"reLogin()\"\n >\n Re-login as someone else\n </ion-button>\n </ion-card-content>\n </ion-card>\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"]}
|
|
1
|
+
{"version":3,"file":"login-page.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/pages/login-page/login-page.component.ts","../../../../../../../../libs/auth/ui/src/lib/pages/login-page/login-page.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,EACd,UAAU,EACV,SAAS,EACT,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGL,kBAAkB,EAClB,qBAAqB,EAErB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,EAGhB,gBAAgB,EAChB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC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,CAAC;IACnE,CAAC;IAEO,WAAW,CACjB,GAAY,EACZ,CAAS,EACT,SAAkB,EAClB,WAAoC;QAEpC,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE;YAChC,MAAM,EAAE,CAAE,GAAyB,CAAC,IAAI;SACzC,CAAC,CAAC;IACL,CAAC;8GAlSU,kBAAkB;kGAAlB,kBAAkB,0DARlB;YACT;gBACE,OAAO,EAAE,SAAS;gBAClB,QAAQ,EAAE,oBAAoB;aAC/B;YACD,eAAe;SAChB,iDC1EH,qvFA8FA,iIDxCI,kBAAkB,mKAClB,SAAS,oGACT,UAAU,mFACV,SAAS,sRACT,UAAU,8EACV,aAAa,4DACb,QAAQ,iFACR,UAAU,kOACV,cAAc,+EACd,OAAO,gFACP,OAAO,yLACP,UAAU;;2FAWD,kBAAkB;kBA3B9B,SAAS;+BACE,aAAa,WAGd;wBACP,kBAAkB;wBAClB,SAAS;wBACT,UAAU;wBACV,SAAS;wBACT,UAAU;wBACV,aAAa;wBACb,QAAQ;wBACR,UAAU;wBACV,cAAc;wBACd,OAAO;wBACP,OAAO;wBACP,UAAU;qBACX,mBACgB,uBAAuB,CAAC,MAAM,aACpC;wBACT;4BACE,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,oBAAoB;yBAC/B;wBACD,eAAe;qBAChB","sourcesContent":["import { Component, computed, inject, ChangeDetectionStrategy, signal } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute } from '@angular/router';\nimport {\n NavController,\n IonBackButton,\n IonButton,\n IonButtons,\n IonCard,\n IonCardContent,\n IonContent,\n IonHeader,\n IonSpinner,\n IonText,\n IonTitle,\n IonToolbar,\n} from '@ionic/angular';\nimport {\n ILoginEventsHandler,\n ISneatAuthState,\n LoginEventsHandler,\n SneatAuthStateService,\n ISneatUserState,\n SneatUserService,\n isSneatAccountReady,\n} from '@sneat/auth-core';\nimport {\n AnalyticsService,\n APP_INFO,\n clearCurrentSpace,\n currentSpacePath,\n IAnalyticsService,\n IAppInfo,\n readCurrentSpace,\n SpaceTypeFamily,\n} from '@sneat/core';\nimport { RandomIdService } from '@sneat/random';\nimport { ClassName, SneatBaseComponent } from '@sneat/ui';\nimport { combineLatest } from 'rxjs';\nimport { AuthPanelComponent } from './auth-panel.component';\nimport { safeAuthReturnPath } from './safe-auth-return-path';\nimport {\n clearLoginRedirectIntent,\n consumeLoginRedirectIntent,\n} from './login-redirect-intent';\nimport type { AuthPanelInitialMode } from './email-login-form/email-login-form.component';\n\ntype Action = 'join' | 'refuse'; // TODO: inject provider for action descriptions/messages.\n\n@Component({\n selector: 'sneat-login',\n templateUrl: './login-page.component.html',\n styleUrl: './login-page.component.scss',\n imports: [\n AuthPanelComponent,\n IonHeader,\n IonToolbar,\n IonButton,\n IonButtons,\n IonBackButton,\n IonTitle,\n IonContent,\n IonCardContent,\n IonText,\n IonCard,\n IonSpinner,\n ],\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: ClassName,\n useValue: 'LoginPageComponent',\n },\n RandomIdService,\n ],\n})\nexport class LoginPageComponent extends SneatBaseComponent {\n private readonly analyticsService =\n inject<IAnalyticsService>(AnalyticsService);\n private readonly route = inject(ActivatedRoute);\n private readonly navController = inject(NavController);\n private readonly userService = inject(SneatUserService);\n private readonly authStateService = inject(SneatAuthStateService);\n private appInfo = inject<IAppInfo>(APP_INFO);\n private readonly loginEventsHandler = inject<ILoginEventsHandler>(\n LoginEventsHandler,\n { optional: true },\n );\n\n protected redirectTo?: string;\n protected readonly to?: string;\n // Free-text explanation of WHY sign-in is needed, passed by the calling page\n // as query params (rendered as escaped text — never as HTML):\n // reason — short heading, e.g. \"Sign in to create a new game\"\n // reasonDetail — optional sub-heading / one-line elaboration\n protected readonly reason?: string;\n protected readonly reasonDetail?: string;\n protected readonly action?: Action; // TODO: document possible values?\n // Optional `?mode=sign-up` or `?mode=sign-in` picks the tab the email form opens on.\n // Absent or unknown values leave the form on its default (Sign in).\n protected readonly initialMode?: AuthPanelInitialMode;\n\n protected readonly appTitle: string;\n\n // Surfaces the Firebase auth state on the login page itself: if the user is\n // already signed in (e.g. the app failed to navigate them onward) we show a\n // \"you are already signed in as X\" panel instead of the sign-in form, so an\n // authenticated-but-stuck state is obvious rather than looking like sign-in\n // is broken.\n protected readonly isAuthenticated = computed(\n () =>\n this.authState()?.status === 'authenticated' &&\n !!this.authState()?.user?.uid &&\n !this.authState()?.user?.isAnonymous,\n );\n private readonly loginEntry = signal<'resolving' | 'signed-out' | 'existing-session' | 'fresh-sign-in'>('resolving');\n private pageActive = true;\n private loginEntryResolved = false;\n private redirectStarted = false;\n private loginRedirectIntent = consumeLoginRedirectIntent();\n protected readonly showAccountChoice = computed(\n () => this.loginEntry() === 'existing-session' && this.isAuthenticated(),\n );\n // While Firebase is still resolving the session — the initial state, and the\n // brief window right after a signInWithRedirect return — show a \"signing you\n // in\" spinner instead of flashing the sign-in form before we navigate onward.\n protected readonly isAuthenticating = computed(\n () =>\n this.authState()?.status === 'authenticating' &&\n this.authState()?.loadingPhase !== 'failed',\n );\n protected readonly isPreparingFreshAccount = computed(\n () =>\n this.loginEntry() === 'fresh-sign-in' &&\n this.isAuthenticated() &&\n !this.isAccountReady() &&\n this.authState()?.loadingPhase !== 'failed' &&\n this.userState()?.userRecordStatus !== 'failed',\n );\n protected readonly isRedirectingAfterFreshSignIn = computed(\n () =>\n this.loginEntry() === 'fresh-sign-in' &&\n this.isAuthenticated() &&\n this.isAccountReady(),\n );\n private readonly authState = toSignal(this.authStateService.authState);\n private readonly userState = toSignal(this.userService.userState);\n protected readonly isAccountReady = computed(() => {\n const userState = this.userState();\n const authState = this.authState();\n return isSneatAccountReady(authState, userState);\n });\n protected readonly signedInAs = computed(() => {\n const u = this.authState()?.user;\n return u?.displayName || u?.email || u?.uid || '';\n });\n protected readonly signedInWith = computed(() => {\n const user = this.authState()?.user;\n // providerId is the current provider only when Firebase has a single\n // provider identity. Linked accounts expose a generic \"firebase\" value;\n // do not mistake one of their linked providers for the active session.\n const providerID = user?.providerId;\n switch (providerID) {\n case 'google.com': return 'Google';\n case 'microsoft.com': return 'Microsoft';\n case 'github.com': return 'GitHub';\n case 'apple.com': return 'Apple';\n case 'facebook.com': return 'Facebook';\n case 'password': return 'email and password';\n case 'phone': return 'phone';\n default: return undefined;\n }\n });\n\n constructor() {\n super();\n const appInfo = this.appInfo;\n this.appTitle = appInfo.appTitle || 'Sneat.app';\n this.refreshRedirectTarget();\n this.to = this.route.snapshot.queryParams['to']; // should we subscribe? I believe no.\n this.reason = this.route.snapshot.queryParams['reason'];\n this.reasonDetail = this.route.snapshot.queryParams['reasonDetail'];\n const mode = this.route.snapshot.queryParams['mode'];\n this.initialMode =\n mode === 'sign-up' || mode === 'sign-in' ? mode : undefined;\n const action = location.hash.match(/[#&]action=(\\w+)/);\n this.action = action?.[1] as Action;\n\n combineLatest([this.authStateService.authState, this.userService.userState])\n .pipe(this.takeUntilDestroyed())\n .subscribe({\n next: ([authState, userState]) => this.handleAuthAndUserState(authState, userState),\n error: this.errorHandler('Failed to get user state after login'),\n });\n }\n\n // Ionic caches routed pages in its navigation stack. Refresh the target and\n // auth-entry decision on each return to this page, and ignore auth updates\n // while the page is covered by another view.\n ionViewWillEnter(): void {\n this.pageActive = true;\n this.loginEntry.set('resolving');\n this.loginEntryResolved = false;\n this.redirectStarted = false;\n this.refreshRedirectTarget();\n const authState = this.authState();\n if (authState && !this.loginEntryResolved) {\n this.resolveLoginEntry(authState);\n }\n const userState = this.userState();\n if (authState && userState) {\n this.handleAuthAndUserState(authState, userState);\n }\n }\n\n ionViewWillLeave(): void {\n this.pageActive = false;\n }\n\n private refreshRedirectTarget(): void {\n const hashTarget = location.hash.startsWith('#/')\n ? safeAuthReturnPath(location.hash.substring(1))\n : undefined;\n this.redirectTo =\n hashTarget ||\n safeAuthReturnPath(this.route.snapshot.queryParams['returnTo']) ||\n this.loginRedirectIntent?.returnTo;\n }\n\n private resolveLoginEntry(authState: ISneatAuthState): void {\n // A session-check placeholder is not evidence that this visit began with\n // an existing account or with a completed sign-in.\n if (\n authState.status === 'authenticating' &&\n authState.loadingPhase === 'checking-session' &&\n !authState.user\n ) return;\n this.loginEntryResolved = true;\n const hasSignedInIdentity =\n (authState.status === 'authenticated' || !!authState.user?.uid) &&\n authState.loadingPhase !== 'failed' &&\n authState.user?.isAnonymous !== true;\n this.loginEntry.set(\n hasSignedInIdentity\n ? this.loginRedirectIntent\n ? 'fresh-sign-in'\n : 'existing-session'\n : 'signed-out',\n );\n }\n\n private handleAuthAndUserState(\n authState: ISneatAuthState,\n userState: ISneatUserState,\n ): void {\n if (!this.pageActive) return;\n if (!this.loginEntryResolved) {\n this.resolveLoginEntry(authState);\n if (!this.loginEntryResolved) return;\n if (this.loginEntry() === 'existing-session') return;\n } else if (\n this.loginEntry() === 'signed-out' &&\n (authState.status === 'authenticated' || !!authState.user?.uid)\n ) {\n this.loginEntry.set('fresh-sign-in');\n }\n\n const userRecord = userState.record;\n if (\n this.loginEntry() !== 'fresh-sign-in' ||\n !userRecord ||\n !isSneatAccountReady(authState, userState) ||\n this.redirectStarted\n ) return;\n clearLoginRedirectIntent();\n this.loginRedirectIntent = undefined;\n this.redirectStarted = true;\n // Fall back to the persisted current space so it is restored after login,\n // but only if the user actually has access to it.\n const space = readCurrentSpace();\n const hasAccess = !!space && (\n userRecord.spaceIDs?.includes(space.id) ||\n (!!userRecord.spaces && space.id in userRecord.spaces)\n );\n if (space && !hasAccess) {\n clearCurrentSpace();\n }\n const activePath = hasAccess ? currentSpacePath() : undefined;\n const family = Object.entries(userRecord.spaces || {}).find(\n ([, brief]) => brief.type === SpaceTypeFamily,\n );\n const familyPath = family\n ? `/space/${SpaceTypeFamily}/${family[0]}`\n : undefined;\n const redirectTo = this.redirectTo || activePath || familyPath || '/';\n this.navController\n .navigateRoot(redirectTo)\n .catch((err) => {\n this.redirectStarted = false;\n this.errorLogger.logError(\n err,\n 'Failed to navigate back to ' + redirectTo,\n );\n });\n }\n\n // Proceed into the app from the \"already signed in\" panel.\n protected continueToApp(): void {\n if (!this.showAccountChoice() || !this.isAccountReady()) return;\n const space = readCurrentSpace();\n const userState = this.userState();\n const hasAccess = !!space && !!userState?.record && (\n userState.record.spaceIDs?.includes(space.id) ||\n (!!userState.record.spaces && space.id in userState.record.spaces)\n );\n if (space && !hasAccess) {\n clearCurrentSpace();\n }\n const activePath = hasAccess ? currentSpacePath() : undefined;\n const family = Object.entries(userState?.record?.spaces || {}).find(\n ([, brief]) => brief.type === SpaceTypeFamily,\n );\n const familyPath = family\n ? `/space/${SpaceTypeFamily}/${family[0]}`\n : undefined;\n const redirectTo = this.redirectTo || activePath || familyPath || '/';\n this.navController\n .navigateRoot(redirectTo)\n .catch((err) => {\n this.errorLogger.logError(\n err,\n 'Failed to navigate to ' + redirectTo,\n );\n });\n }\n\n // Sign out so the sign-in form is shown again (e.g. to log in as someone else).\n protected reLogin(): void {\n clearCurrentSpace();\n this.loginEntry.set('signed-out');\n this.loginEntryResolved = true;\n this.authStateService\n .signOut()\n .catch(this.errorLogger.logErrorHandler('Failed to sign out for re-login'));\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 if (eventName) {\n this.analyticsService.logEvent(eventName, eventParams);\n }\n this.errorLogger.logError(err, m, {\n report: !(err as { code: unknown }).code,\n });\n }\n}\n","<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…</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’re signed in as <strong>{{ signedInAs() }}</strong>\n } @else {\n You’re 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"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { safeAuthReturnPath } from './safe-auth-return-path';
|
|
2
|
+
const storageKey = 'sneat.auth.login-redirect-intent';
|
|
3
|
+
const maxAgeMs = 10 * 60 * 1000;
|
|
4
|
+
export function markLoginRedirectIntent(returnTo) {
|
|
5
|
+
try {
|
|
6
|
+
if (typeof sessionStorage === 'undefined')
|
|
7
|
+
return;
|
|
8
|
+
sessionStorage.setItem(storageKey, JSON.stringify({ createdAt: Date.now(), returnTo: safeAuthReturnPath(returnTo) }));
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
// Storage may be unavailable in private browsing; auth still works.
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function consumeLoginRedirectIntent() {
|
|
15
|
+
try {
|
|
16
|
+
if (typeof sessionStorage === 'undefined')
|
|
17
|
+
return undefined;
|
|
18
|
+
const value = sessionStorage.getItem(storageKey);
|
|
19
|
+
sessionStorage.removeItem(storageKey);
|
|
20
|
+
if (!value)
|
|
21
|
+
return undefined;
|
|
22
|
+
const intent = JSON.parse(value);
|
|
23
|
+
const age = Date.now() - Number(intent.createdAt);
|
|
24
|
+
if (!Number.isFinite(age) || age < 0 || age > maxAgeMs)
|
|
25
|
+
return undefined;
|
|
26
|
+
return { returnTo: safeAuthReturnPath(intent.returnTo) };
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function clearLoginRedirectIntent() {
|
|
33
|
+
try {
|
|
34
|
+
if (typeof sessionStorage !== 'undefined') {
|
|
35
|
+
sessionStorage.removeItem(storageKey);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Storage may be unavailable in private browsing; auth still works.
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=login-redirect-intent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-redirect-intent.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/pages/login-page/login-redirect-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,UAAU,GAAG,kCAAkC,CAAC;AACtD,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAMhC,MAAM,UAAU,uBAAuB,CAAC,QAAiB;IACvD,IAAI,CAAC;QACH,IAAI,OAAO,cAAc,KAAK,WAAW;YAAE,OAAO;QAClD,cAAc,CAAC,OAAO,CACpB,UAAU,EACV,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAClF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;IACtE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,IAAI,CAAC;QACH,IAAI,OAAO,cAAc,KAAK,WAAW;YAAE,OAAO,SAAS,CAAC;QAC5D,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACjD,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAE7B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAG9B,CAAC;QACF,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ;YAAE,OAAO,SAAS,CAAC;QACzE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,CAAC,MAAM,CAAC,QAA8B,CAAC,EAAE,CAAC;IACjF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB;IACtC,IAAI,CAAC;QACH,IAAI,OAAO,cAAc,KAAK,WAAW,EAAE,CAAC;YAC1C,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;IACtE,CAAC;AACH,CAAC","sourcesContent":["import { safeAuthReturnPath } from './safe-auth-return-path';\n\nconst storageKey = 'sneat.auth.login-redirect-intent';\nconst maxAgeMs = 10 * 60 * 1000;\n\nexport interface LoginRedirectIntent {\n readonly returnTo?: string;\n}\n\nexport function markLoginRedirectIntent(returnTo?: string): void {\n try {\n if (typeof sessionStorage === 'undefined') return;\n sessionStorage.setItem(\n storageKey,\n JSON.stringify({ createdAt: Date.now(), returnTo: safeAuthReturnPath(returnTo) }),\n );\n } catch {\n // Storage may be unavailable in private browsing; auth still works.\n }\n}\n\nexport function consumeLoginRedirectIntent(): LoginRedirectIntent | undefined {\n try {\n if (typeof sessionStorage === 'undefined') return undefined;\n const value = sessionStorage.getItem(storageKey);\n sessionStorage.removeItem(storageKey);\n if (!value) return undefined;\n\n const intent = JSON.parse(value) as {\n createdAt?: unknown;\n returnTo?: unknown;\n };\n const age = Date.now() - Number(intent.createdAt);\n if (!Number.isFinite(age) || age < 0 || age > maxAgeMs) return undefined;\n return { returnTo: safeAuthReturnPath(intent.returnTo as string | undefined) };\n } catch {\n return undefined;\n }\n}\n\nexport function clearLoginRedirectIntent(): void {\n try {\n if (typeof sessionStorage !== 'undefined') {\n sessionStorage.removeItem(storageKey);\n }\n } catch {\n // Storage may be unavailable in private browsing; auth still works.\n }\n}\n"]}
|
|
@@ -5,6 +5,11 @@ import * as i0 from "@angular/core";
|
|
|
5
5
|
export declare class UserAuthAccountsComponent extends SneatBaseComponent {
|
|
6
6
|
private readonly sneatUserService;
|
|
7
7
|
private readonly sneatApiService;
|
|
8
|
+
/**
|
|
9
|
+
* The messaging-apps section (Telegram, WhatsApp, Viber) and its Sneat.app
|
|
10
|
+
* copy. Apps that only need sign-in methods turn it off.
|
|
11
|
+
*/
|
|
12
|
+
readonly showMessagingApps: import("@angular/core").InputSignal<boolean>;
|
|
8
13
|
protected readonly $userRecord: import("@angular/core").WritableSignal<IUserRecord | undefined>;
|
|
9
14
|
protected readonly signingInWith: import("@angular/core").WritableSignal<AuthProviderID | undefined>;
|
|
10
15
|
constructor();
|
|
@@ -13,5 +18,5 @@ export declare class UserAuthAccountsComponent extends SneatBaseComponent {
|
|
|
13
18
|
protected readonly disconnecting: import("@angular/core").WritableSignal<"telegram" | "viber" | "whatsapp" | undefined>;
|
|
14
19
|
protected disconnect(provider: 'telegram'): void;
|
|
15
20
|
static ɵfac: i0.ɵɵFactoryDeclaration<UserAuthAccountsComponent, never>;
|
|
16
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<UserAuthAccountsComponent, "sneat-user-auth-accounts", never, {}, {}, never, never, true, never>;
|
|
21
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<UserAuthAccountsComponent, "sneat-user-auth-accounts", never, { "showMessagingApps": { "alias": "showMessagingApps"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
17
22
|
}
|
|
@@ -18,6 +18,16 @@ export declare class AuthPanelComponent implements OnInit {
|
|
|
18
18
|
readonly accountReadyChange: EventEmitter<AuthPanelAccountReadyChange>;
|
|
19
19
|
protected readonly signingWith: import("@angular/core").WritableSignal<EmailFormSigningWith | AuthProviderID | undefined>;
|
|
20
20
|
protected readonly authRecoveryNeeded: import("@angular/core").WritableSignal<boolean>;
|
|
21
|
+
/**
|
|
22
|
+
* Set when sign-in hit an email that already has an account: names the
|
|
23
|
+
* provider that will be connected once the user signs in the usual way.
|
|
24
|
+
*/
|
|
25
|
+
protected readonly pendingLink: import("@angular/core").WritableSignal<{
|
|
26
|
+
readonly provider: string;
|
|
27
|
+
readonly email?: string;
|
|
28
|
+
/** False when no credential could be kept to link later. */
|
|
29
|
+
readonly autoLink: boolean;
|
|
30
|
+
} | undefined>;
|
|
21
31
|
protected readonly recordState: import("@angular/core").WritableSignal<"signed-out" | "loading" | "ready" | "failed">;
|
|
22
32
|
protected readonly isNativePlatform: boolean;
|
|
23
33
|
protected readonly safeReturnTo: import("@angular/core").Signal<string | undefined>;
|
|
@@ -10,7 +10,7 @@ export declare class LoginPageComponent extends SneatBaseComponent {
|
|
|
10
10
|
private readonly authStateService;
|
|
11
11
|
private appInfo;
|
|
12
12
|
private readonly loginEventsHandler;
|
|
13
|
-
protected
|
|
13
|
+
protected redirectTo?: string;
|
|
14
14
|
protected readonly to?: string;
|
|
15
15
|
protected readonly reason?: string;
|
|
16
16
|
protected readonly reasonDetail?: string;
|
|
@@ -18,12 +18,26 @@ export declare class LoginPageComponent extends SneatBaseComponent {
|
|
|
18
18
|
protected readonly initialMode?: AuthPanelInitialMode;
|
|
19
19
|
protected readonly appTitle: string;
|
|
20
20
|
protected readonly isAuthenticated: import("@angular/core").Signal<boolean>;
|
|
21
|
+
private readonly loginEntry;
|
|
22
|
+
private pageActive;
|
|
23
|
+
private loginEntryResolved;
|
|
24
|
+
private redirectStarted;
|
|
25
|
+
private loginRedirectIntent;
|
|
26
|
+
protected readonly showAccountChoice: import("@angular/core").Signal<boolean>;
|
|
21
27
|
protected readonly isAuthenticating: import("@angular/core").Signal<boolean>;
|
|
28
|
+
protected readonly isPreparingFreshAccount: import("@angular/core").Signal<boolean>;
|
|
29
|
+
protected readonly isRedirectingAfterFreshSignIn: import("@angular/core").Signal<boolean>;
|
|
22
30
|
private readonly authState;
|
|
23
31
|
private readonly userState;
|
|
24
32
|
protected readonly isAccountReady: import("@angular/core").Signal<boolean>;
|
|
25
33
|
protected readonly signedInAs: import("@angular/core").Signal<string>;
|
|
34
|
+
protected readonly signedInWith: import("@angular/core").Signal<"phone" | "Google" | "Microsoft" | "GitHub" | "Apple" | "Facebook" | "email and password" | undefined>;
|
|
26
35
|
constructor();
|
|
36
|
+
ionViewWillEnter(): void;
|
|
37
|
+
ionViewWillLeave(): void;
|
|
38
|
+
private refreshRedirectTarget;
|
|
39
|
+
private resolveLoginEntry;
|
|
40
|
+
private handleAuthAndUserState;
|
|
27
41
|
protected continueToApp(): void;
|
|
28
42
|
protected reLogin(): void;
|
|
29
43
|
private errorHandler;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface LoginRedirectIntent {
|
|
2
|
+
readonly returnTo?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function markLoginRedirectIntent(returnTo?: string): void;
|
|
5
|
+
export declare function consumeLoginRedirectIntent(): LoginRedirectIntent | undefined;
|
|
6
|
+
export declare function clearLoginRedirectIntent(): void;
|