@sneat/auth-ui 0.27.37 → 0.27.39

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.
@@ -1,5 +1,5 @@
1
1
  import { ChangeDetectionStrategy, Component, EventEmitter, Output, inject, input, signal, viewChild, } from '@angular/core';
2
- import { sendPasswordResetEmail, sendSignInLinkToEmail, } from 'firebase/auth';
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';
@@ -18,6 +18,10 @@ export class EmailLoginFormComponent {
18
18
  constructor() {
19
19
  this.returnTo = input(/* @ts-ignore */
20
20
  ...(ngDevMode ? [undefined, { debugName: "returnTo" }] : /* istanbul ignore next */ []));
21
+ /**
22
+ * Which tab the form opens on. Defaults to 'sign-in' because most visitors are
23
+ * returning users; pass 'sign-up' to open on the registration tab.
24
+ */
21
25
  this.initialMode = input(/* @ts-ignore */
22
26
  ...(ngDevMode ? [undefined, { debugName: "initialMode" }] : /* istanbul ignore next */ []));
23
27
  this.appInfo = inject(APP_INFO);
@@ -31,8 +35,12 @@ export class EmailLoginFormComponent {
31
35
  this.authStateService = inject(SneatAuthStateService, {
32
36
  optional: true,
33
37
  });
34
- this.sign = signal('up', /* @ts-ignore */
35
- ...(ngDevMode ? [{ debugName: "sign" }] : /* istanbul ignore next */ [])); // TODO: document here what 'in' & 'up' means
38
+ /** The selected tab: 'in' is Sign in (existing account), 'up' is Sign up (new account). */
39
+ this.sign = signal('in', /* @ts-ignore */
40
+ ...(ngDevMode ? [{ debugName: "sign" }] : /* istanbul ignore next */ []));
41
+ /** Set when a sign-up attempt found the email already registered; shows a hint on the Sign in tab. */
42
+ this.existingAccountHint = signal(false, /* @ts-ignore */
43
+ ...(ngDevMode ? [{ debugName: "existingAccountHint" }] : /* istanbul ignore next */ []));
36
44
  this.email = signal('', /* @ts-ignore */
37
45
  ...(ngDevMode ? [{ debugName: "email" }] : /* istanbul ignore next */ []));
38
46
  this.password = signal('', /* @ts-ignore */
@@ -56,9 +64,6 @@ export class EmailLoginFormComponent {
56
64
  this.setFocusToInput = createSetFocusToInput(this.errorLogger);
57
65
  const email = localStorage.getItem('emailForSignIn') || '';
58
66
  this.email.set(email);
59
- if (email) {
60
- this.sign.set('in');
61
- }
62
67
  if (this.authStateService) {
63
68
  this.authStateService.authStatus.subscribe((status) => {
64
69
  if (status === 'notAuthenticated') {
@@ -68,8 +73,8 @@ export class EmailLoginFormComponent {
68
73
  }
69
74
  }
70
75
  ngOnInit() {
71
- // Keep the remembered-email heuristic for existing callers. A consumer can
72
- // explicitly choose the first view without restricting later user toggles.
76
+ // Sign in is the default tab. A consumer can explicitly choose the first
77
+ // view without restricting later user toggles.
73
78
  const initialMode = this.initialMode();
74
79
  if (initialMode) {
75
80
  this.sign.set(initialMode === 'sign-in' ? 'in' : 'up');
@@ -152,6 +157,10 @@ export class EmailLoginFormComponent {
152
157
  .catch(this.errorHandler('Failed to get Firebase ID token', 'FirebaseGetIdTokenFailed'));
153
158
  }
154
159
  catch (e) {
160
+ if (e.code === 'auth/email-already-in-use') {
161
+ this.switchToSignInForExistingAccount();
162
+ return;
163
+ }
155
164
  this.handleError(e, 'Failed to sign up with email', 'FailedToSignUpWithEmail');
156
165
  }
157
166
  }
@@ -165,7 +174,18 @@ export class EmailLoginFormComponent {
165
174
  break;
166
175
  }
167
176
  }
177
+ /**
178
+ * The email already has an account (a returning user landed on Sign up).
179
+ * That is not an error: move to the Sign in tab, keep the typed email and say why.
180
+ */
181
+ switchToSignInForExistingAccount() {
182
+ this.analyticsService.logEvent('SignUpEmailAlreadyInUse');
183
+ this.setSigningWith(undefined);
184
+ this.existingAccountHint.set(true);
185
+ this.sign.set('in');
186
+ }
168
187
  signIn() {
188
+ this.existingAccountHint.set(false);
169
189
  this.setSigningWith('email');
170
190
  this.email.set(this.email().trim());
171
191
  this.wrongPassword.set(false);
@@ -217,13 +237,25 @@ export class EmailLoginFormComponent {
217
237
  });
218
238
  }
219
239
  resetPassword() {
240
+ if (this.signingWith())
241
+ return;
220
242
  this.setSigningWith('resetPassword');
221
- sendPasswordResetEmail(this.afAuth, this.email())
222
- .then(() => {
223
- this.setSigningWith(undefined);
224
- this.showToast(`Password reset link has been sent to email: ${this.email()}`);
243
+ this.sneatApiService
244
+ .postAsAnonymous('auth/request-password-reset', {
245
+ email: this.email(),
246
+ returnUrl: this.passwordResetReturnUrl(),
225
247
  })
226
- .catch(this.errorHandler('Failed to send password reset email', 'FailedToSendPasswordResetEmail'));
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();
227
259
  }
228
260
  sendVerificationEmail(userCredential) {
229
261
  setTimeout(async () => {
@@ -260,6 +292,9 @@ export class EmailLoginFormComponent {
260
292
  this.signingWithChange.emit(signingWith);
261
293
  }
262
294
  signChanged() {
295
+ if (this.sign() === 'up') {
296
+ this.existingAccountHint.set(false);
297
+ }
263
298
  this.setFocusToEmail();
264
299
  }
265
300
  ionViewDidEnter() {
@@ -276,7 +311,7 @@ export class EmailLoginFormComponent {
276
311
  // no-op
277
312
  }
278
313
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EmailLoginFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
279
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EmailLoginFormComponent, isStandalone: true, selector: "sneat-email-login-form", inputs: { returnTo: { classPropertyName: "returnTo", publicName: "returnTo", isSignal: true, isRequired: false, transformFunction: null }, initialMode: { classPropertyName: "initialMode", publicName: "initialMode", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { signingWithChange: "signingWithChange", loggedIn: "loggedIn" }, viewQueries: [{ propertyName: "emailInput", first: true, predicate: ["emailInput"], descendants: true, isSignal: true }, { propertyName: "spaceTitleInput", first: true, predicate: ["spaceTitleInput"], descendants: true, isSignal: true }], ngImport: i0, template: "<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 <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 >&nbsp;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", styles: ["ion-segment-button{--padding-start: 8px;--padding-end: 8px}.email-login-actions{display:flex;align-items:center;flex-wrap:nowrap;gap:4px}.email-login-actions ion-button{margin-inline:0;white-space:nowrap}.email-login-actions ion-button[disabled][fill=clear]{flex:0 0 auto;--padding-start: 2px;--padding-end: 2px}@media(max-width:575px){.password-button-suffix{display:none}.email-login-actions{padding-inline:10px;gap:3px}.email-login-actions ion-button{min-width:0;--padding-start: 8px;--padding-end: 8px;font-size:12px}}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.EmailValidator, selector: "[email][formControlName],[email][formControl],[email][ngModel]", inputs: ["email"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: IonCard, selector: "ion-card", inputs: ["button", "color", "disabled", "download", "href", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonItemDivider, selector: "ion-item-divider", inputs: ["color", "mode", "sticky"] }, { kind: "component", type: IonSegment, selector: "ion-segment", inputs: ["color", "disabled", "mode", "scrollable", "selectOnFocus", "swipeGesture", "value"] }, { kind: "component", type: IonSegmentButton, selector: "ion-segment-button", inputs: ["contentId", "disabled", "layout", "mode", "type", "value"] }, { kind: "component", type: IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: IonCardContent, selector: "ion-card-content", inputs: ["mode"] }, { kind: "component", type: IonItem, selector: "ion-item", inputs: ["button", "color", "detail", "detailIcon", "disabled", "download", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }, { kind: "component", type: IonText, selector: "ion-text", 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
314
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EmailLoginFormComponent, isStandalone: true, selector: "sneat-email-login-form", inputs: { returnTo: { classPropertyName: "returnTo", publicName: "returnTo", isSignal: true, isRequired: false, transformFunction: null }, initialMode: { classPropertyName: "initialMode", publicName: "initialMode", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { signingWithChange: "signingWithChange", loggedIn: "loggedIn" }, viewQueries: [{ propertyName: "emailInput", first: true, predicate: ["emailInput"], descendants: true, isSignal: true }, { propertyName: "spaceTitleInput", first: true, predicate: ["spaceTitleInput"], descendants: true, isSignal: true }], ngImport: i0, template: "<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 >&nbsp;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", styles: ["ion-segment-button{--padding-start: 8px;--padding-end: 8px}.email-login-actions{display:flex;align-items:center;flex-wrap:nowrap;gap:4px}.email-login-actions ion-button{margin-inline:0;white-space:nowrap}.email-login-actions ion-button[disabled][fill=clear]{flex:0 0 auto;--padding-start: 2px;--padding-end: 2px}@media(max-width:575px){.password-button-suffix{display:none}.email-login-actions{padding-inline:10px;gap:3px}.email-login-actions ion-button{min-width:0;--padding-start: 8px;--padding-end: 8px;font-size:12px}}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.EmailValidator, selector: "[email][formControlName],[email][formControl],[email][ngModel]", inputs: ["email"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: IonCard, selector: "ion-card", inputs: ["button", "color", "disabled", "download", "href", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonItemDivider, selector: "ion-item-divider", inputs: ["color", "mode", "sticky"] }, { kind: "component", type: IonSegment, selector: "ion-segment", inputs: ["color", "disabled", "mode", "scrollable", "selectOnFocus", "swipeGesture", "value"] }, { kind: "component", type: IonSegmentButton, selector: "ion-segment-button", inputs: ["contentId", "disabled", "layout", "mode", "type", "value"] }, { kind: "component", type: IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: IonCardContent, selector: "ion-card-content", inputs: ["mode"] }, { kind: "component", type: IonItem, selector: "ion-item", inputs: ["button", "color", "detail", "detailIcon", "disabled", "download", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }, { kind: "component", type: IonText, selector: "ion-text", 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
280
315
  }
281
316
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EmailLoginFormComponent, decorators: [{
282
317
  type: Component,
@@ -295,7 +330,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
295
330
  IonText,
296
331
  IonButton,
297
332
  IonButtons,
298
- ], template: "<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 <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 >&nbsp;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", styles: ["ion-segment-button{--padding-start: 8px;--padding-end: 8px}.email-login-actions{display:flex;align-items:center;flex-wrap:nowrap;gap:4px}.email-login-actions ion-button{margin-inline:0;white-space:nowrap}.email-login-actions ion-button[disabled][fill=clear]{flex:0 0 auto;--padding-start: 2px;--padding-end: 2px}@media(max-width:575px){.password-button-suffix{display:none}.email-login-actions{padding-inline:10px;gap:3px}.email-login-actions ion-button{min-width:0;--padding-start: 8px;--padding-end: 8px;font-size:12px}}\n"] }]
333
+ ], template: "<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 >&nbsp;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", styles: ["ion-segment-button{--padding-start: 8px;--padding-end: 8px}.email-login-actions{display:flex;align-items:center;flex-wrap:nowrap;gap:4px}.email-login-actions ion-button{margin-inline:0;white-space:nowrap}.email-login-actions ion-button[disabled][fill=clear]{flex:0 0 auto;--padding-start: 2px;--padding-end: 2px}@media(max-width:575px){.password-button-suffix{display:none}.email-login-actions{padding-inline:10px;gap:3px}.email-login-actions ion-button{min-width:0;--padding-start: 8px;--padding-end: 8px;font-size:12px}}\n"] }]
299
334
  }], ctorParameters: () => [], propDecorators: { returnTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "returnTo", required: false }] }], initialMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "initialMode", required: false }] }], signingWithChange: [{
300
335
  type: Output
301
336
  }], loggedIn: [{
@@ -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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AC,GAAG,CAAC,WAAW,CAAC,CAAC;QAClC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW;QACT,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,eAAe;QACb,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAC/B,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,6GAA6G;IAC7G,4GAA4G;IAC5G,0FAA0F;IAClF,eAAe;QACrB,QAAQ;IACV,CAAC;IAEO,oBAAoB;QAC1B,QAAQ;IACV,CAAC;8GA7TU,uBAAuB;kGAAvB,uBAAuB,mqBClFpC,krLAkLA,qkBDhHI,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;;sBA8BA,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 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 protected readonly sign = signal<'in' | 'up'>('up'); // TODO: document here what 'in' & 'up' means\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 (email) {\n this.sign.set('in');\n }\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 // Keep the remembered-email heuristic for existing callers. A consumer can\n // explicitly choose the first 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 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 public signIn(): void {\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 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 <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 >&nbsp;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,m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Ae;QACrB,QAAQ;IACV,CAAC;IAEO,oBAAoB;QAC1B,QAAQ;IACV,CAAC;8GA9VU,uBAAuB;kGAAvB,uBAAuB,mqBCjFpC,+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 >&nbsp;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"]}
@@ -56,6 +56,9 @@ export class LoginPageComponent extends SneatBaseComponent {
56
56
  this.to = this.route.snapshot.queryParams['to']; // should we subscribe? I believe no.
57
57
  this.reason = this.route.snapshot.queryParams['reason'];
58
58
  this.reasonDetail = this.route.snapshot.queryParams['reasonDetail'];
59
+ const mode = this.route.snapshot.queryParams['mode'];
60
+ this.initialMode =
61
+ mode === 'sign-up' || mode === 'sign-in' ? mode : undefined;
59
62
  const action = location.hash.match(/[#&]action=(\w+)/);
60
63
  this.action = action?.[1];
61
64
  const userRecordLoaded = new Subject();
@@ -138,7 +141,7 @@ export class LoginPageComponent extends SneatBaseComponent {
138
141
  useValue: 'LoginPageComponent',
139
142
  },
140
143
  RandomIdService,
141
- ], 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 &#64; {{ 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\u2026</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 [returnTo]=\"redirectTo\" [showIntro]=\"false\" />\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&#64;sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\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 }); }
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 &#64; {{ 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\u2026</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&#64;sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\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 }); }
142
145
  }
143
146
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: LoginPageComponent, decorators: [{
144
147
  type: Component,
@@ -161,6 +164,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
161
164
  useValue: 'LoginPageComponent',
162
165
  },
163
166
  RandomIdService,
164
- ], 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 &#64; {{ 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\u2026</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 [returnTo]=\"redirectTo\" [showIntro]=\"false\" />\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&#64;sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n" }]
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 &#64; {{ 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\u2026</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&#64;sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n" }]
165
168
  }], ctorParameters: () => [] });
166
169
  //# 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,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACzD,O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AAC;IACL,CAAC;8GAtKU,kBAAkB;kGAAlB,kBAAkB,0DARlB;YACT;gBACE,OAAO,EAAE,SAAS;gBAClB,QAAQ,EAAE,oBAAoB;aAC/B;YACD,eAAe;SAChB,iDClEH,m1EAgFA,4CDlCI,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';\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\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 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 &#64; {{ 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 [returnTo]=\"redirectTo\" [showIntro]=\"false\" />\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&#64;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,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAi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Aa;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 &#64; {{ 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&#64;sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n"]}
@@ -8,6 +8,10 @@ export type EmailFormSigningWith = 'email' | 'emailLink' | 'resetPassword';
8
8
  export type AuthPanelInitialMode = 'sign-in' | 'sign-up';
9
9
  export declare class EmailLoginFormComponent implements OnInit {
10
10
  readonly returnTo: import("@angular/core").InputSignal<string | undefined>;
11
+ /**
12
+ * Which tab the form opens on. Defaults to 'sign-in' because most visitors are
13
+ * returning users; pass 'sign-up' to open on the registration tab.
14
+ */
11
15
  readonly initialMode: import("@angular/core").InputSignal<AuthPanelInitialMode | undefined>;
12
16
  readonly appInfo: IAppInfo;
13
17
  private readonly analyticsService;
@@ -18,7 +22,10 @@ export declare class EmailLoginFormComponent implements OnInit {
18
22
  private readonly sneatApiService;
19
23
  private readonly userRecordService;
20
24
  private readonly authStateService;
25
+ /** The selected tab: 'in' is Sign in (existing account), 'up' is Sign up (new account). */
21
26
  protected readonly sign: import("@angular/core").WritableSignal<"in" | "up">;
27
+ /** Set when a sign-up attempt found the email already registered; shows a hint on the Sign in tab. */
28
+ protected readonly existingAccountHint: import("@angular/core").WritableSignal<boolean>;
22
29
  protected readonly email: import("@angular/core").WritableSignal<string>;
23
30
  protected readonly password: import("@angular/core").WritableSignal<string>;
24
31
  protected readonly firstName: import("@angular/core").WritableSignal<string>;
@@ -37,11 +44,17 @@ export declare class EmailLoginFormComponent implements OnInit {
37
44
  getFirebaseAuth(): Auth;
38
45
  signUp(): Promise<void>;
39
46
  keyupEnter(): void;
47
+ /**
48
+ * The email already has an account (a returning user landed on Sign up).
49
+ * That is not an error: move to the Sign in tab, keep the typed email and say why.
50
+ */
51
+ private switchToSignInForExistingAccount;
40
52
  signIn(): void;
41
53
  private saveEmailForReuse;
42
54
  sendSignInLink(): void;
43
55
  private showToast;
44
56
  resetPassword(): void;
57
+ private passwordResetReturnUrl;
45
58
  private sendVerificationEmail;
46
59
  private onLoggedIn;
47
60
  private errorHandler;
@@ -1,4 +1,5 @@
1
1
  import { SneatBaseComponent } from '@sneat/ui';
2
+ import type { AuthPanelInitialMode } from './email-login-form/email-login-form.component';
2
3
  import * as i0 from "@angular/core";
3
4
  type Action = 'join' | 'refuse';
4
5
  export declare class LoginPageComponent extends SneatBaseComponent {
@@ -14,6 +15,7 @@ export declare class LoginPageComponent extends SneatBaseComponent {
14
15
  protected readonly reason?: string;
15
16
  protected readonly reasonDetail?: string;
16
17
  protected readonly action?: Action;
18
+ protected readonly initialMode?: AuthPanelInitialMode;
17
19
  protected readonly appTitle: string;
18
20
  protected readonly isAuthenticated: import("@angular/core").Signal<boolean>;
19
21
  protected readonly isAuthenticating: import("@angular/core").Signal<boolean>;