@sneat/auth-ui 0.25.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/components/auth-menu-item/auth-menu-item.component.js +14 -9
- package/esm2022/lib/components/auth-menu-item/auth-menu-item.component.js.map +1 -1
- package/esm2022/lib/components/user-auth-providers/user-auth-accounts.component.js +11 -8
- package/esm2022/lib/components/user-auth-providers/user-auth-accounts.component.js.map +1 -1
- package/esm2022/lib/components/user-auth-providers/user-auth-provider-status.js +22 -14
- package/esm2022/lib/components/user-auth-providers/user-auth-provider-status.js.map +1 -1
- package/esm2022/lib/components/user-required-fields/user-required-fields-modal.component.js +10 -12
- package/esm2022/lib/components/user-required-fields/user-required-fields-modal.component.js.map +1 -1
- package/esm2022/lib/components/user-required-fields/user-required-fields.service.js +4 -4
- package/esm2022/lib/components/user-required-fields/user-required-fields.service.js.map +1 -1
- package/esm2022/lib/pages/login-page/email-login-form/email-login-form.component.js +24 -14
- package/esm2022/lib/pages/login-page/email-login-form/email-login-form.component.js.map +1 -1
- package/esm2022/lib/pages/login-page/login-page.component.js +19 -11
- package/esm2022/lib/pages/login-page/login-page.component.js.map +1 -1
- package/esm2022/lib/pages/login-page/login-with-telegram.component.js +22 -26
- package/esm2022/lib/pages/login-page/login-with-telegram.component.js.map +1 -1
- package/esm2022/lib/pages/login-page/sneat-auth-with-telegram.service.js +3 -3
- package/esm2022/lib/pages/sign-in-from-email-link/sign-in-from-email-link-page.component.js +10 -7
- package/esm2022/lib/pages/sign-in-from-email-link/sign-in-from-email-link-page.component.js.map +1 -1
- package/esm2022/lib/pages/sneat-auth-routing.module.js +4 -4
- package/esm2022/lib/pipes/person-names.pipe.js +3 -3
- package/lib/components/user-required-fields/user-required-fields-modal.component.d.ts +2 -2
- package/lib/pages/login-page/email-login-form/email-login-form.component.d.ts +2 -2
- package/lib/pages/login-page/login-page.component.d.ts +1 -0
- package/lib/pages/login-page/login-with-telegram.component.d.ts +6 -6
- package/package.json +4 -4
- package/tsconfig.lib.prod.tsbuildinfo +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-required-fields.service.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/components/user-required-fields/user-required-fields.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"user-required-fields.service.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/components/user-required-fields/user-required-fields.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;;AAE1F,4EAA4E;AAC5E,oEAAoE;AACpE,4EAA4E;AAC5E,uEAAuE;AAEvE,MAAM,OAAO,yBAAyB;IADtC;QAEmB,oBAAe,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;KAgB5D;IAdQ,KAAK,CAAC,IAAI;QACf,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;YAC9C,SAAS,EAAE,gCAAgC;SAC5C,CAAC,CAAC;QACH,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,KAAK;iBACF,YAAY,EAAE;iBACd,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBACd,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACnB,CAAC,CAAC;iBACD,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;8GAhBU,yBAAyB;kHAAzB,yBAAyB,cADZ,MAAM;;2FACnB,yBAAyB;kBADrC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { Injectable, inject } from '@angular/core';\nimport { ModalController } from '@ionic/angular';\nimport { UserRequiredFieldsModalComponent } from './user-required-fields-modal.component';\n\n// providedIn:'root' so every consumer resolves it without a local provider.\n// SpacesListComponent injects it, and that component is embedded in\n// SpacesCardComponent (used on app landing pages) — without root provision,\n// rendering the card on a route that doesn't provide it throws NG0201.\n@Injectable({ providedIn: 'root' })\nexport class UserRequiredFieldsService {\n private readonly modalController = inject(ModalController);\n\n public async open(): Promise<boolean> {\n const modal = await this.modalController.create({\n component: UserRequiredFieldsModalComponent,\n });\n await modal.present();\n return new Promise((resolve, reject) => {\n modal\n .onDidDismiss()\n .then((value) => {\n resolve(!!value);\n })\n .catch(reject);\n });\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Output, inject, signa
|
|
|
3
3
|
// import { getAuth } from '@angular/fire/auth';
|
|
4
4
|
import { Auth, sendPasswordResetEmail, sendSignInLinkToEmail, } from '@angular/fire/auth';
|
|
5
5
|
import { FormsModule } from '@angular/forms';
|
|
6
|
-
import { ToastController, IonButton, IonButtons, IonCard, IonCardContent, IonIcon, IonInput, IonItem, IonItemDivider, IonLabel, IonSegment, IonSegmentButton, IonSpinner, IonText, } from '@ionic/angular
|
|
6
|
+
import { ToastController, IonButton, IonButtons, IonCard, IonCardContent, IonIcon, IonInput, IonItem, IonItemDivider, IonLabel, IonSegment, IonSegmentButton, IonSpinner, IonText, } from '@ionic/angular';
|
|
7
7
|
import { SneatApiService } from '@sneat/api';
|
|
8
8
|
import { UserRecordService } from '@sneat/auth-core';
|
|
9
9
|
import { createSetFocusToInput } from '@sneat/ui';
|
|
@@ -24,18 +24,28 @@ export class EmailLoginFormComponent {
|
|
|
24
24
|
this.randomIdService = inject(RandomIdService);
|
|
25
25
|
this.sneatApiService = inject(SneatApiService);
|
|
26
26
|
this.userRecordService = inject(UserRecordService);
|
|
27
|
-
this.sign = signal('up',
|
|
28
|
-
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
27
|
+
this.sign = signal('up', /* @ts-ignore */
|
|
28
|
+
...(ngDevMode ? [{ debugName: "sign" }] : /* istanbul ignore next */ [])); // TODO: document here what 'in' & 'up' means
|
|
29
|
+
this.email = signal('', /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "email" }] : /* istanbul ignore next */ []));
|
|
31
|
+
this.password = signal('', /* @ts-ignore */
|
|
32
|
+
...(ngDevMode ? [{ debugName: "password" }] : /* istanbul ignore next */ []));
|
|
33
|
+
this.firstName = signal('', /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "firstName" }] : /* istanbul ignore next */ []));
|
|
35
|
+
this.lastName = signal('', /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "lastName" }] : /* istanbul ignore next */ []));
|
|
37
|
+
this.spaceTitle = signal('', /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "spaceTitle" }] : /* istanbul ignore next */ []));
|
|
39
|
+
this.wrongPassword = signal(false, /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "wrongPassword" }] : /* istanbul ignore next */ []));
|
|
41
|
+
this.signingWith = signal(undefined, /* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [{ debugName: "signingWith" }] : /* istanbul ignore next */ []));
|
|
35
43
|
this.signingWithChange = new EventEmitter();
|
|
36
44
|
this.loggedIn = new EventEmitter();
|
|
37
|
-
this.emailInput = viewChild('emailInput',
|
|
38
|
-
|
|
45
|
+
this.emailInput = viewChild('emailInput', /* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [{ debugName: "emailInput" }] : /* istanbul ignore next */ []));
|
|
47
|
+
this.spaceTitleInput = viewChild('spaceTitleInput', /* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [{ debugName: "spaceTitleInput" }] : /* istanbul ignore next */ []));
|
|
39
49
|
this.setFocusToInput = createSetFocusToInput(this.errorLogger);
|
|
40
50
|
const email = localStorage.getItem('emailForSignIn') || '';
|
|
41
51
|
this.email.set(email);
|
|
@@ -232,10 +242,10 @@ export class EmailLoginFormComponent {
|
|
|
232
242
|
setFocusToSpaceTitle() {
|
|
233
243
|
this.setFocusToInput(undefined /*this.spaceTitleInput*/);
|
|
234
244
|
}
|
|
235
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
236
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
245
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EmailLoginFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
246
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: EmailLoginFormComponent, isStandalone: true, selector: "sneat-email-login-form", 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 [ngModel]=\"sign()\" (ngModelChange)=\"sign.set($event)\" (ionChange)=\"signChanged()\">\n <ion-segment-button value=\"up\">\n <ion-icon name=\"person-add\" class=\"ion-margin-end\"></ion-icon>\n <ion-label>Sign up</ion-label>\n </ion-segment-button>\n <ion-segment-button value=\"in\">\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()\" (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()\" (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()\" (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()\" (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()\" (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>\n @switch (sign()) {\n @case (\"up\") {\n <ion-button\n [disabled]=\"!!signingWith() || !validEmail || (!firstName() && !lastName())\"\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> <ion-text\n color=\"light\"\n style=\"text-transform: none\"\n >with password\n </ion-text>\n </ion-label>\n }\n </ion-button>\n <ion-button disabled=\"disabled\" fill=\"clear\" color=\"medium\">\n or\n </ion-button>\n <ion-button\n size=\"small\"\n [disabled]=\"!validEmail || signingWith()\"\n (click)=\"sendSignInLink()\"\n fill=\"outline\"\n color=\"tertiary\"\n >\n <ion-icon name=\"mail-outline\" slot=\"start\" />\n <ion-label>Get sign-in link</ion-label>\n </ion-button>\n }\n }\n </ion-card-content>\n</ion-card>\n", 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 }); }
|
|
237
247
|
}
|
|
238
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
248
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EmailLoginFormComponent, decorators: [{
|
|
239
249
|
type: Component,
|
|
240
250
|
args: [{ selector: 'sneat-email-login-form', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
|
|
241
251
|
FormsModule,
|
|
@@ -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,EACZ,MAAM,EACN,MAAM,EACN,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,8CAA8C;AAC9C,gDAAgD;AAChD,OAAO,EACL,IAAI,EACJ,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,EACd,OAAO,EACP,QAAQ,EACR,OAAO,EACP,cAAc,EACd,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,OAAO,GACR,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAA0B,i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IACzB,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IACtD,CAAC;IAEO,oBAAoB;QAC1B,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAC3D,CAAC;8GA9RU,uBAAuB;kGAAvB,uBAAuB,4YC1EpC,y9KAqKA,2CD3GI,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,oPACT,UAAU;;2FAGD,uBAAuB;kBArBnC,SAAS;+BACE,wBAAwB,mBAEjB,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;;sBAyBA,MAAM;;sBAGN,MAAM;0DAE6C,YAAY,yEACP,iBAAiB","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n Output,\n inject,\n signal,\n viewChild,\n} from '@angular/core';\n// import { getApp } from '@angular/fire/app';\n// import { getAuth } from '@angular/fire/auth';\nimport {\n Auth,\n sendPasswordResetEmail,\n sendSignInLinkToEmail,\n} from '@angular/fire/auth';\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/standalone';\nimport { SneatApiService } from '@sneat/api';\nimport { IInitUserRecordRequest, UserRecordService } 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';\n\nexport type EmailFormSigningWith = 'email' | 'emailLink' | 'resetPassword';\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 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 {\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(Auth);\n private readonly randomIdService = inject(RandomIdService);\n private readonly sneatApiService = inject(SneatApiService);\n private readonly userRecordService = inject(UserRecordService);\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 }\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 return this.afAuth as unknown as Auth; // TODO: pending https://github.com/angular/angularfire/pull/3402\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 sendSignInLinkToEmail(this.afAuth, this.email(), {\n // url: 'https://dailyscrum.app/pwa/sign-in',\n url: document.baseURI + 'sign-in-from-email-link',\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.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.setFocusToEmail();\n }\n\n private setFocusToEmail(): void {\n this.setFocusToInput(undefined /*this.emailInput*/);\n }\n\n private setFocusToSpaceTitle(): void {\n this.setFocusToInput(undefined /*this.spaceTitleInput*/);\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 [ngModel]=\"sign()\" (ngModelChange)=\"sign.set($event)\" (ionChange)=\"signChanged()\">\n <ion-segment-button value=\"up\">\n <ion-icon name=\"person-add\" class=\"ion-margin-end\"></ion-icon>\n <ion-label>Sign up</ion-label>\n </ion-segment-button>\n <ion-segment-button value=\"in\">\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()\" (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()\" (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()\" (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()\" (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()\" (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>\n @switch (sign()) {\n @case (\"up\") {\n <ion-button\n [disabled]=\"!!signingWith() || !validEmail || (!firstName() && !lastName())\"\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> <ion-text\n color=\"light\"\n style=\"text-transform: none\"\n >with password\n </ion-text>\n </ion-label>\n }\n </ion-button>\n <ion-button disabled=\"disabled\" fill=\"clear\" color=\"medium\">\n or\n </ion-button>\n <ion-button\n size=\"small\"\n [disabled]=\"!validEmail || signingWith()\"\n (click)=\"sendSignInLink()\"\n fill=\"outline\"\n color=\"tertiary\"\n >\n <ion-icon name=\"mail-outline\" slot=\"start\" />\n <ion-label>Get sign-in link</ion-label>\n </ion-button>\n }\n }\n </ion-card-content>\n</ion-card>\n"]}
|
|
1
|
+
{"version":3,"file":"email-login-form.component.js","sourceRoot":"","sources":["../../../../../../../../../libs/auth/ui/src/lib/pages/login-page/email-login-form/email-login-form.component.ts","../../../../../../../../../libs/auth/ui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BACV,OAAO;wBACP,SAAS;wBACT,UAAU;qBACX;;sBAyBA,MAAM;;sBAGN,MAAM;0DAE6C,YAAY,yEACP,iBAAiB","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n Output,\n inject,\n signal,\n viewChild,\n} from '@angular/core';\n// import { getApp } from '@angular/fire/app';\n// import { getAuth } from '@angular/fire/auth';\nimport {\n Auth,\n sendPasswordResetEmail,\n sendSignInLinkToEmail,\n} from '@angular/fire/auth';\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 { IInitUserRecordRequest, UserRecordService } 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';\n\nexport type EmailFormSigningWith = 'email' | 'emailLink' | 'resetPassword';\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 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 {\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(Auth);\n private readonly randomIdService = inject(RandomIdService);\n private readonly sneatApiService = inject(SneatApiService);\n private readonly userRecordService = inject(UserRecordService);\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 }\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 return this.afAuth as unknown as Auth; // TODO: pending https://github.com/angular/angularfire/pull/3402\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 sendSignInLinkToEmail(this.afAuth, this.email(), {\n // url: 'https://dailyscrum.app/pwa/sign-in',\n url: document.baseURI + 'sign-in-from-email-link',\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.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.setFocusToEmail();\n }\n\n private setFocusToEmail(): void {\n this.setFocusToInput(undefined /*this.emailInput*/);\n }\n\n private setFocusToSpaceTitle(): void {\n this.setFocusToInput(undefined /*this.spaceTitleInput*/);\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 [ngModel]=\"sign()\" (ngModelChange)=\"sign.set($event)\" (ionChange)=\"signChanged()\">\n <ion-segment-button value=\"up\">\n <ion-icon name=\"person-add\" class=\"ion-margin-end\"></ion-icon>\n <ion-label>Sign up</ion-label>\n </ion-segment-button>\n <ion-segment-button value=\"in\">\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()\" (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()\" (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()\" (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()\" (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()\" (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>\n @switch (sign()) {\n @case (\"up\") {\n <ion-button\n [disabled]=\"!!signingWith() || !validEmail || (!firstName() && !lastName())\"\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> <ion-text\n color=\"light\"\n style=\"text-transform: none\"\n >with password\n </ion-text>\n </ion-label>\n }\n </ion-button>\n <ion-button disabled=\"disabled\" fill=\"clear\" color=\"medium\">\n or\n </ion-button>\n <ion-button\n size=\"small\"\n [disabled]=\"!validEmail || signingWith()\"\n (click)=\"sendSignInLink()\"\n fill=\"outline\"\n color=\"tertiary\"\n >\n <ion-icon name=\"mail-outline\" slot=\"start\" />\n <ion-label>Get sign-in link</ion-label>\n </ion-button>\n }\n }\n </ion-card-content>\n</ion-card>\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Component, computed, signal, inject } from '@angular/core';
|
|
1
|
+
import { Component, computed, signal, inject, ChangeDetectionStrategy } from '@angular/core';
|
|
2
2
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
3
3
|
import { FormsModule } from '@angular/forms';
|
|
4
4
|
import { ActivatedRoute } from '@angular/router';
|
|
5
5
|
import { Capacitor } from '@capacitor/core';
|
|
6
|
-
import { NavController, IonBackButton, IonButton, IonButtons, IonCard, IonCardContent, IonCol, IonContent, IonGrid, IonHeader, IonIcon, IonItem, IonItemDivider, IonLabel, IonList, IonRow, IonSpinner, IonText, IonTitle, IonToolbar, } from '@ionic/angular
|
|
6
|
+
import { NavController, IonBackButton, IonButton, IonButtons, IonCard, IonCardContent, IonCol, IonContent, IonGrid, IonHeader, IonIcon, IonItem, IonItemDivider, IonLabel, IonList, IonRow, IonSpinner, IonText, IonTitle, IonToolbar, } from '@ionic/angular';
|
|
7
7
|
import { AuthStatuses, LoginEventsHandler, SneatAuthStateService, } from '@sneat/auth-core';
|
|
8
8
|
import { SneatUserService } from '@sneat/auth-core';
|
|
9
9
|
import { AnalyticsService, APP_INFO, currentSpacePath, } from '@sneat/core';
|
|
@@ -23,20 +23,28 @@ export class LoginPageComponent extends SneatBaseComponent {
|
|
|
23
23
|
this.authStateService = inject(SneatAuthStateService);
|
|
24
24
|
this.appInfo = inject(APP_INFO);
|
|
25
25
|
this.loginEventsHandler = inject(LoginEventsHandler, { optional: true });
|
|
26
|
-
this.signingWith = signal(undefined,
|
|
26
|
+
this.signingWith = signal(undefined, /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "signingWith" }] : /* istanbul ignore next */ []));
|
|
27
28
|
this.isNativePlatform = Capacitor.isNativePlatform();
|
|
28
29
|
// Surfaces the Firebase auth state on the login page itself: if the user is
|
|
29
30
|
// already signed in (e.g. the app failed to navigate them onward) we show a
|
|
30
31
|
// "you are already signed in as X" panel instead of the sign-in form, so an
|
|
31
32
|
// authenticated-but-stuck state is obvious rather than looking like sign-in
|
|
32
33
|
// is broken.
|
|
33
|
-
this.isAuthenticated = computed(() => this.authStatus() === 'authenticated',
|
|
34
|
+
this.isAuthenticated = computed(() => this.authStatus() === 'authenticated', /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "isAuthenticated" }] : /* istanbul ignore next */ []));
|
|
36
|
+
// While Firebase is still resolving the session — the initial state, and the
|
|
37
|
+
// brief window right after a signInWithRedirect return — show a "signing you
|
|
38
|
+
// in" spinner instead of flashing the sign-in form before we navigate onward.
|
|
39
|
+
this.isAuthenticating = computed(() => this.authStatus() === 'authenticating', /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "isAuthenticating" }] : /* istanbul ignore next */ []));
|
|
34
41
|
this.authStatus = toSignal(this.authStateService.authStatus);
|
|
35
42
|
this.authUser = toSignal(this.authStateService.authUser);
|
|
36
43
|
this.signedInAs = computed(() => {
|
|
37
44
|
const u = this.authUser();
|
|
38
45
|
return u?.displayName || u?.email || u?.uid || '';
|
|
39
|
-
},
|
|
46
|
+
}, /* @ts-ignore */
|
|
47
|
+
...(ngDevMode ? [{ debugName: "signedInAs" }] : /* istanbul ignore next */ []));
|
|
40
48
|
const appInfo = this.appInfo;
|
|
41
49
|
this.appTitle = appInfo.appTitle || 'Sneat.app';
|
|
42
50
|
if (location.hash.startsWith('#/')) {
|
|
@@ -128,16 +136,16 @@ export class LoginPageComponent extends SneatBaseComponent {
|
|
|
128
136
|
});
|
|
129
137
|
this.signingWith.set(undefined);
|
|
130
138
|
}
|
|
131
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
132
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
139
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: LoginPageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
140
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: LoginPageComponent, isStandalone: true, selector: "sneat-login", providers: [
|
|
133
141
|
{
|
|
134
142
|
provide: ClassName,
|
|
135
143
|
useValue: 'LoginPageComponent',
|
|
136
144
|
},
|
|
137
145
|
RandomIdService,
|
|
138
|
-
], usesInheritance: true, ngImport: i0, template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n This app is free to use &\n <a target=\"_blank\" href=\"https://github.com/sneat-co\">open source</a>.\n </ion-text>\n </p>\n\n @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 <ion-button expand=\"block\" (click)=\"continueToApp()\">Continue</ion-button>\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-email-login-form\n (signingWithChange)=\"onEmailFormStatusChanged()\"\n (loggedIn)=\"onLoggedIn($event)\"\n />\n\n <ion-card>\n <ion-item-divider color=\"light\">\n <ion-label\n color=\"medium\"\n style=\"text-align: center; width: 100%; font-weight: bold\"\n >\n Quick login\n </ion-label>\n </ion-item-divider>\n <ion-grid class=\"ion-grid-layout\">\n @if (!isNativePlatform) {\n <ion-row>\n <ion-col>\n <div class=\"ion-padding\" style=\"text-align: center\">\n <sneat-login-with-telegram />\n </div>\n </ion-col>\n </ion-row>\n }\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('google.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"google.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"danger\" name=\"logo-google\" slot=\"start\" />\n }\n <ion-label color=\"danger\"> Login with Google</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('apple.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"apple.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"dark\" name=\"logo-apple\" slot=\"start\" />\n }\n\n <ion-label color=\"dark\"> Login with Apple</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('microsoft.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"microsoft.com\") {\n <ion-spinner\n slot=\"start\"\n color=\"secondary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon slot=\"start\" color=\"secondary\" name=\"logo-windows\" />\n }\n <ion-label color=\"secondary\">Login with Microsoft</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('facebook.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"facebook.com\") {\n <ion-spinner slot=\"start\" color=\"primary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"primary\" name=\"logo-facebook\" />\n }\n <ion-label color=\"primary\">Login with Facebook</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('github.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"github.com\") {\n <ion-spinner slot=\"start\" color=\"tertiary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"tertiary\" name=\"logo-github\" />\n }\n <ion-label color=\"tertiary\">Login with GitHub</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n If any issues get\n <a href=\"mailto:help@sneat.app?subject=Problem+with+login+at+Sneat.app\"\n >help@sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "component", type: LoginWithTelegramComponent, selector: "sneat-login-with-telegram", inputs: ["isUserAuthenticated", "botID", "size", "requestAccess", "userPic"] }, { kind: "component", type: EmailLoginFormComponent, selector: "sneat-email-login-form", outputs: ["signingWithChange", "loggedIn"] }, { 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"] }, { 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"] }, { 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: IonItemDivider, selector: "ion-item-divider", inputs: ["color", "mode", "sticky"] }, { kind: "component", type: IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: IonRow, selector: "ion-row" }, { kind: "component", type: IonCol, selector: "ion-col", inputs: ["offset", "offsetLg", "offsetMd", "offsetSm", "offsetXl", "offsetXs", "pull", "pullLg", "pullMd", "pullSm", "pullXl", "pullXs", "push", "pushLg", "pushMd", "pushSm", "pushXl", "pushXs", "size", "sizeLg", "sizeMd", "sizeSm", "sizeXl", "sizeXs"] }, { 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: IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }, { kind: "component", type: IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: IonList, selector: "ion-list", inputs: ["inset", "lines", "mode"] }, { kind: "component", type: IonGrid, selector: "ion-grid", inputs: ["fixed"] }] }); }
|
|
146
|
+
], usesInheritance: true, ngImport: i0, template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n This app is free to use &\n <a target=\"_blank\" href=\"https://github.com/sneat-co\">open source</a>.\n </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 <ion-button expand=\"block\" (click)=\"continueToApp()\">Continue</ion-button>\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-email-login-form\n (signingWithChange)=\"onEmailFormStatusChanged()\"\n (loggedIn)=\"onLoggedIn($event)\"\n />\n\n <ion-card>\n <ion-item-divider color=\"light\">\n <ion-label\n color=\"medium\"\n style=\"text-align: center; width: 100%; font-weight: bold\"\n >\n Quick login\n </ion-label>\n </ion-item-divider>\n <ion-grid class=\"ion-grid-layout\">\n @if (!isNativePlatform) {\n <ion-row>\n <ion-col>\n <div class=\"ion-padding\" style=\"text-align: center\">\n <sneat-login-with-telegram />\n </div>\n </ion-col>\n </ion-row>\n }\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('google.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"google.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"danger\" name=\"logo-google\" slot=\"start\" />\n }\n <ion-label color=\"danger\"> Login with Google</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('apple.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"apple.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"dark\" name=\"logo-apple\" slot=\"start\" />\n }\n\n <ion-label color=\"dark\"> Login with Apple</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('microsoft.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"microsoft.com\") {\n <ion-spinner\n slot=\"start\"\n color=\"secondary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon slot=\"start\" color=\"secondary\" name=\"logo-windows\" />\n }\n <ion-label color=\"secondary\">Login with Microsoft</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('facebook.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"facebook.com\") {\n <ion-spinner slot=\"start\" color=\"primary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"primary\" name=\"logo-facebook\" />\n }\n <ion-label color=\"primary\">Login with Facebook</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('github.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"github.com\") {\n <ion-spinner slot=\"start\" color=\"tertiary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"tertiary\" name=\"logo-github\" />\n }\n <ion-label color=\"tertiary\">Login with GitHub</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n If any issues get\n <a href=\"mailto:help@sneat.app?subject=Problem+with+login+at+Sneat.app\"\n >help@sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "component", type: LoginWithTelegramComponent, selector: "sneat-login-with-telegram", inputs: ["isUserAuthenticated", "botID", "size", "requestAccess", "userPic"] }, { kind: "component", type: EmailLoginFormComponent, selector: "sneat-email-login-form", outputs: ["signingWithChange", "loggedIn"] }, { 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: IonItemDivider, selector: "ion-item-divider", inputs: ["color", "mode", "sticky"] }, { kind: "component", type: IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: IonRow, selector: "ion-row" }, { kind: "component", type: IonCol, selector: "ion-col", inputs: ["offset", "offsetLg", "offsetMd", "offsetSm", "offsetXl", "offsetXs", "pull", "pullLg", "pullMd", "pullSm", "pullXl", "pullXs", "push", "pushLg", "pushMd", "pushSm", "pushXl", "pushXs", "size", "sizeLg", "sizeMd", "sizeSm", "sizeXl", "sizeXs"] }, { 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: IonSpinner, selector: "ion-spinner", inputs: ["color", "duration", "name", "paused"] }, { kind: "component", type: IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "component", type: IonList, selector: "ion-list", inputs: ["inset", "lines", "mode"] }, { kind: "component", type: IonGrid, selector: "ion-grid", inputs: ["fixed"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
139
147
|
}
|
|
140
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
148
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: LoginPageComponent, decorators: [{
|
|
141
149
|
type: Component,
|
|
142
150
|
args: [{ selector: 'sneat-login', imports: [
|
|
143
151
|
FormsModule,
|
|
@@ -162,12 +170,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.0", ngImpor
|
|
|
162
170
|
IonIcon,
|
|
163
171
|
IonList,
|
|
164
172
|
IonGrid,
|
|
165
|
-
], providers: [
|
|
173
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
166
174
|
{
|
|
167
175
|
provide: ClassName,
|
|
168
176
|
useValue: 'LoginPageComponent',
|
|
169
177
|
},
|
|
170
178
|
RandomIdService,
|
|
171
|
-
], template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n This app is free to use &\n <a target=\"_blank\" href=\"https://github.com/sneat-co\">open source</a>.\n </ion-text>\n </p>\n\n @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 <ion-button expand=\"block\" (click)=\"continueToApp()\">Continue</ion-button>\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-email-login-form\n (signingWithChange)=\"onEmailFormStatusChanged()\"\n (loggedIn)=\"onLoggedIn($event)\"\n />\n\n <ion-card>\n <ion-item-divider color=\"light\">\n <ion-label\n color=\"medium\"\n style=\"text-align: center; width: 100%; font-weight: bold\"\n >\n Quick login\n </ion-label>\n </ion-item-divider>\n <ion-grid class=\"ion-grid-layout\">\n @if (!isNativePlatform) {\n <ion-row>\n <ion-col>\n <div class=\"ion-padding\" style=\"text-align: center\">\n <sneat-login-with-telegram />\n </div>\n </ion-col>\n </ion-row>\n }\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('google.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"google.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"danger\" name=\"logo-google\" slot=\"start\" />\n }\n <ion-label color=\"danger\"> Login with Google</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('apple.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"apple.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"dark\" name=\"logo-apple\" slot=\"start\" />\n }\n\n <ion-label color=\"dark\"> Login with Apple</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('microsoft.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"microsoft.com\") {\n <ion-spinner\n slot=\"start\"\n color=\"secondary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon slot=\"start\" color=\"secondary\" name=\"logo-windows\" />\n }\n <ion-label color=\"secondary\">Login with Microsoft</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('facebook.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"facebook.com\") {\n <ion-spinner slot=\"start\" color=\"primary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"primary\" name=\"logo-facebook\" />\n }\n <ion-label color=\"primary\">Login with Facebook</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('github.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"github.com\") {\n <ion-spinner slot=\"start\" color=\"tertiary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"tertiary\" name=\"logo-github\" />\n }\n <ion-label color=\"tertiary\">Login with GitHub</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n If any issues get\n <a href=\"mailto:help@sneat.app?subject=Problem+with+login+at+Sneat.app\"\n >help@sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n" }]
|
|
179
|
+
], template: "<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n This app is free to use &\n <a target=\"_blank\" href=\"https://github.com/sneat-co\">open source</a>.\n </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 <ion-button expand=\"block\" (click)=\"continueToApp()\">Continue</ion-button>\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-email-login-form\n (signingWithChange)=\"onEmailFormStatusChanged()\"\n (loggedIn)=\"onLoggedIn($event)\"\n />\n\n <ion-card>\n <ion-item-divider color=\"light\">\n <ion-label\n color=\"medium\"\n style=\"text-align: center; width: 100%; font-weight: bold\"\n >\n Quick login\n </ion-label>\n </ion-item-divider>\n <ion-grid class=\"ion-grid-layout\">\n @if (!isNativePlatform) {\n <ion-row>\n <ion-col>\n <div class=\"ion-padding\" style=\"text-align: center\">\n <sneat-login-with-telegram />\n </div>\n </ion-col>\n </ion-row>\n }\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('google.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"google.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"danger\" name=\"logo-google\" slot=\"start\" />\n }\n <ion-label color=\"danger\"> Login with Google</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('apple.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"apple.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"dark\" name=\"logo-apple\" slot=\"start\" />\n }\n\n <ion-label color=\"dark\"> Login with Apple</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('microsoft.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"microsoft.com\") {\n <ion-spinner\n slot=\"start\"\n color=\"secondary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon slot=\"start\" color=\"secondary\" name=\"logo-windows\" />\n }\n <ion-label color=\"secondary\">Login with Microsoft</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('facebook.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"facebook.com\") {\n <ion-spinner slot=\"start\" color=\"primary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"primary\" name=\"logo-facebook\" />\n }\n <ion-label color=\"primary\">Login with Facebook</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('github.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"github.com\") {\n <ion-spinner slot=\"start\" color=\"tertiary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"tertiary\" name=\"logo-github\" />\n }\n <ion-label color=\"tertiary\">Login with GitHub</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n If any issues get\n <a href=\"mailto:help@sneat.app?subject=Problem+with+login+at+Sneat.app\"\n >help@sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n" }]
|
|
172
180
|
}], ctorParameters: () => [] });
|
|
173
181
|
//# 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,MAAM,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,EACd,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,cAAc,EACd,QAAQ,EACR,OAAO,EACP,MAAM,EACN,UAAU,EACV,OAAO,EACP,QAAQ,EACR,UAAU,GACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,YAAY,EAGZ,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,gBAAgB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,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE;YAChC,MAAM,EAAE,CAAE,GAAyB,CAAC,IAAI;SACzC,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;8GAhKU,kBAAkB;kGAAlB,kBAAkB,0DARlB;YACT;gBACE,OAAO,EAAE,SAAS;gBAClB,QAAQ,EAAE,oBAAoB;aAC/B;YACD,eAAe;SAChB,iDCxFH,k4LAwLA,2CD7HI,WAAW,+BACX,0BAA0B,oJAC1B,uBAAuB,+GACvB,SAAS,oGACT,UAAU,mFACV,SAAS,oPACT,UAAU,8EACV,aAAa,4DACb,QAAQ,iFACR,UAAU,wKACV,cAAc,+EACd,OAAO,gFACP,OAAO,yLACP,cAAc,kGACd,QAAQ,6FACR,MAAM,oDACN,MAAM,kTACN,OAAO,0NACP,UAAU,yGACV,OAAO,2JACP,OAAO,yFACP,OAAO;;2FAUE,kBAAkB;kBAnC9B,SAAS;+BACE,aAAa,WAEd;wBACP,WAAW;wBACX,0BAA0B;wBAC1B,uBAAuB;wBACvB,SAAS;wBACT,UAAU;wBACV,SAAS;wBACT,UAAU;wBACV,aAAa;wBACb,QAAQ;wBACR,UAAU;wBACV,cAAc;wBACd,OAAO;wBACP,OAAO;wBACP,cAAc;wBACd,QAAQ;wBACR,MAAM;wBACN,MAAM;wBACN,OAAO;wBACP,UAAU;wBACV,OAAO;wBACP,OAAO;wBACP,OAAO;qBACR,aACU;wBACT;4BACE,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,oBAAoB;yBAC/B;wBACD,eAAe;qBAChB","sourcesContent":["import { Component, computed, signal, inject } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { FormsModule } from '@angular/forms';\nimport { ActivatedRoute } from '@angular/router';\nimport { Capacitor } from '@capacitor/core';\nimport {\n NavController,\n IonBackButton,\n IonButton,\n IonButtons,\n IonCard,\n IonCardContent,\n IonCol,\n IonContent,\n IonGrid,\n IonHeader,\n IonIcon,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonList,\n IonRow,\n IonSpinner,\n IonText,\n IonTitle,\n IonToolbar,\n} from '@ionic/angular/standalone';\nimport {\n AuthProviderID,\n AuthStatuses,\n ILoginEventsHandler,\n ISneatAuthState,\n LoginEventsHandler,\n SneatAuthStateService,\n} from '@sneat/auth-core';\nimport { SneatUserService } from '@sneat/auth-core';\nimport {\n AnalyticsService,\n APP_INFO,\n currentSpacePath,\n IAnalyticsService,\n IAppInfo,\n} from '@sneat/core';\nimport { RandomIdService } from '@sneat/random';\nimport { ClassName, SneatBaseComponent } from '@sneat/ui';\nimport { Subject, takeUntil } from 'rxjs';\nimport {\n EmailFormSigningWith,\n EmailLoginFormComponent,\n} from './email-login-form/email-login-form.component';\nimport { UserCredential } from 'firebase/auth';\nimport { LoginWithTelegramComponent } from './login-with-telegram.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 FormsModule,\n LoginWithTelegramComponent,\n EmailLoginFormComponent,\n IonHeader,\n IonToolbar,\n IonButton,\n IonButtons,\n IonBackButton,\n IonTitle,\n IonContent,\n IonCardContent,\n IonText,\n IonCard,\n IonItemDivider,\n IonLabel,\n IonRow,\n IonCol,\n IonItem,\n IonSpinner,\n IonIcon,\n IonList,\n IonGrid,\n ],\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 signingWith = signal<AuthProviderID | undefined>(\n undefined,\n );\n private 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 isNativePlatform = Capacitor.isNativePlatform();\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 () => this.authStatus() === 'authenticated',\n );\n private readonly authStatus = toSignal(this.authStateService.authStatus);\n private readonly authUser = toSignal(this.authStateService.authUser);\n protected readonly signedInAs = computed(() => {\n const u = this.authUser();\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 = 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 this.userService.userState\n .pipe(takeUntil(userRecordLoaded), this.takeUntilDestroyed())\n .subscribe({\n next: (userState) => {\n if (userState.record) {\n userRecordLoaded.next();\n } else {\n return;\n }\n // Fall back to the persisted current space so it is restored after login.\n const redirectTo = this.redirectTo || currentSpacePath() || '/';\n this.navController\n .navigateRoot(redirectTo)\n .catch(\n this.errorLogger.logErrorHandler(\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 protected onEmailFormStatusChanged(signingWith?: EmailFormSigningWith): void {\n this.signingWith.set(signingWith as AuthProviderID);\n }\n\n // Proceed into the app from the \"already signed in\" panel.\n protected continueToApp(): void {\n const redirectTo = this.redirectTo || currentSpacePath() || '/';\n this.navController\n .navigateRoot(redirectTo)\n .catch(this.errorLogger.logErrorHandler('Failed to navigate to ' + redirectTo));\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 this.authStateService\n .signOut()\n .catch(this.errorLogger.logErrorHandler('Failed to sign out for re-login'));\n }\n\n protected async loginWith(provider: AuthProviderID) {\n this.signingWith.set(provider);\n try {\n await this.authStateService.signInWith(provider);\n // We do not reset this.signingWith in case of succesful sign in as we should redirect from login page\n // and not to allow user to do a double sign-in.\n } catch (e) {\n const errMsg = (e as { errorMessage?: string }).errorMessage;\n if (\n errMsg !== 'The user canceled the sign-in flow.' &&\n !errMsg?.includes(\n 'com.apple.AuthenticationServices.AuthorizationError error 1001.',\n )\n ) {\n this.errorLogger.logError(e, `Failed to sign-in with ${provider}`);\n }\n this.signingWith.set(undefined);\n }\n }\n\n protected onLoggedIn(userCredential: UserCredential): void {\n this.signingWith.set(undefined);\n if (!userCredential.user) {\n return;\n }\n if (userCredential.user.email) {\n const prevEmail = localStorage.getItem('emailForSignIn') || '';\n if (!prevEmail) {\n localStorage.setItem('emailForSignIn', userCredential.user.email);\n }\n }\n const authState: ISneatAuthState = {\n status: AuthStatuses.authenticated,\n user: userCredential.user,\n };\n this.userService.onUserSignedIn(authState);\n }\n\n 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 this.signingWith.set(undefined);\n }\n}\n","<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n This app is free to use &\n <a target=\"_blank\" href=\"https://github.com/sneat-co\">open source</a>.\n </ion-text>\n </p>\n\n @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 <ion-button expand=\"block\" (click)=\"continueToApp()\">Continue</ion-button>\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-email-login-form\n (signingWithChange)=\"onEmailFormStatusChanged()\"\n (loggedIn)=\"onLoggedIn($event)\"\n />\n\n <ion-card>\n <ion-item-divider color=\"light\">\n <ion-label\n color=\"medium\"\n style=\"text-align: center; width: 100%; font-weight: bold\"\n >\n Quick login\n </ion-label>\n </ion-item-divider>\n <ion-grid class=\"ion-grid-layout\">\n @if (!isNativePlatform) {\n <ion-row>\n <ion-col>\n <div class=\"ion-padding\" style=\"text-align: center\">\n <sneat-login-with-telegram />\n </div>\n </ion-col>\n </ion-row>\n }\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('google.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"google.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"danger\" name=\"logo-google\" slot=\"start\" />\n }\n <ion-label color=\"danger\"> Login with Google</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('apple.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"apple.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"dark\" name=\"logo-apple\" slot=\"start\" />\n }\n\n <ion-label color=\"dark\"> Login with Apple</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('microsoft.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"microsoft.com\") {\n <ion-spinner\n slot=\"start\"\n color=\"secondary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon slot=\"start\" color=\"secondary\" name=\"logo-windows\" />\n }\n <ion-label color=\"secondary\">Login with Microsoft</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('facebook.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"facebook.com\") {\n <ion-spinner slot=\"start\" color=\"primary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"primary\" name=\"logo-facebook\" />\n }\n <ion-label color=\"primary\">Login with Facebook</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('github.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"github.com\") {\n <ion-spinner slot=\"start\" color=\"tertiary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"tertiary\" name=\"logo-github\" />\n }\n <ion-label color=\"tertiary\">Login with GitHub</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n If any issues get\n <a href=\"mailto:help@sneat.app?subject=Problem+with+login+at+Sneat.app\"\n >help@sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n"]}
|
|
1
|
+
{"version":3,"file":"login-page.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/pages/login-page/login-page.component.ts","../../../../../../../../libs/auth/ui/src/lib/pages/login-page/login-page.component.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,aAAa,EACb,aAAa,EACb,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,EACd,MAAM,EACN,UAAU,EACV,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,cAAc,EACd,QAAQ,EACR,OAAO,EACP,MAAM,EACN,UAAU,EACV,OAAO,EACP,QAAQ,EACR,U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BACd,OAAO;wBACP,OAAO;wBACP,cAAc;wBACd,QAAQ;wBACR,MAAM;wBACN,MAAM;wBACN,OAAO;wBACP,UAAU;wBACV,OAAO;wBACP,OAAO;wBACP,OAAO;qBACR,mBACgB,uBAAuB,CAAC,MAAM,aACpC;wBACT;4BACE,OAAO,EAAE,SAAS;4BAClB,QAAQ,EAAE,oBAAoB;yBAC/B;wBACD,eAAe;qBAChB","sourcesContent":["import { Component, computed, signal, inject, ChangeDetectionStrategy } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { FormsModule } from '@angular/forms';\nimport { ActivatedRoute } from '@angular/router';\nimport { Capacitor } from '@capacitor/core';\nimport {\n NavController,\n IonBackButton,\n IonButton,\n IonButtons,\n IonCard,\n IonCardContent,\n IonCol,\n IonContent,\n IonGrid,\n IonHeader,\n IonIcon,\n IonItem,\n IonItemDivider,\n IonLabel,\n IonList,\n IonRow,\n IonSpinner,\n IonText,\n IonTitle,\n IonToolbar,\n} from '@ionic/angular';\nimport {\n AuthProviderID,\n AuthStatuses,\n ILoginEventsHandler,\n ISneatAuthState,\n LoginEventsHandler,\n SneatAuthStateService,\n} from '@sneat/auth-core';\nimport { SneatUserService } from '@sneat/auth-core';\nimport {\n AnalyticsService,\n APP_INFO,\n currentSpacePath,\n IAnalyticsService,\n IAppInfo,\n} from '@sneat/core';\nimport { RandomIdService } from '@sneat/random';\nimport { ClassName, SneatBaseComponent } from '@sneat/ui';\nimport { Subject, takeUntil } from 'rxjs';\nimport {\n EmailFormSigningWith,\n EmailLoginFormComponent,\n} from './email-login-form/email-login-form.component';\nimport { UserCredential } from 'firebase/auth';\nimport { LoginWithTelegramComponent } from './login-with-telegram.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 FormsModule,\n LoginWithTelegramComponent,\n EmailLoginFormComponent,\n IonHeader,\n IonToolbar,\n IonButton,\n IonButtons,\n IonBackButton,\n IonTitle,\n IonContent,\n IonCardContent,\n IonText,\n IonCard,\n IonItemDivider,\n IonLabel,\n IonRow,\n IonCol,\n IonItem,\n IonSpinner,\n IonIcon,\n IonList,\n IonGrid,\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 signingWith = signal<AuthProviderID | undefined>(\n undefined,\n );\n private 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 isNativePlatform = Capacitor.isNativePlatform();\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 () => this.authStatus() === 'authenticated',\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 () => this.authStatus() === 'authenticating',\n );\n private readonly authStatus = toSignal(this.authStateService.authStatus);\n private readonly authUser = toSignal(this.authStateService.authUser);\n protected readonly signedInAs = computed(() => {\n const u = this.authUser();\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 = 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 this.userService.userState\n .pipe(takeUntil(userRecordLoaded), this.takeUntilDestroyed())\n .subscribe({\n next: (userState) => {\n if (userState.record) {\n userRecordLoaded.next();\n } else {\n return;\n }\n // Fall back to the persisted current space so it is restored after login.\n const redirectTo = this.redirectTo || currentSpacePath() || '/';\n this.navController\n .navigateRoot(redirectTo)\n .catch(\n this.errorLogger.logErrorHandler(\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 protected onEmailFormStatusChanged(signingWith?: EmailFormSigningWith): void {\n this.signingWith.set(signingWith as AuthProviderID);\n }\n\n // Proceed into the app from the \"already signed in\" panel.\n protected continueToApp(): void {\n const redirectTo = this.redirectTo || currentSpacePath() || '/';\n this.navController\n .navigateRoot(redirectTo)\n .catch(this.errorLogger.logErrorHandler('Failed to navigate to ' + redirectTo));\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 this.authStateService\n .signOut()\n .catch(this.errorLogger.logErrorHandler('Failed to sign out for re-login'));\n }\n\n protected async loginWith(provider: AuthProviderID) {\n this.signingWith.set(provider);\n try {\n await this.authStateService.signInWith(provider);\n // We do not reset this.signingWith in case of succesful sign in as we should redirect from login page\n // and not to allow user to do a double sign-in.\n } catch (e) {\n const errMsg = (e as { errorMessage?: string }).errorMessage;\n if (\n errMsg !== 'The user canceled the sign-in flow.' &&\n !errMsg?.includes(\n 'com.apple.AuthenticationServices.AuthorizationError error 1001.',\n )\n ) {\n this.errorLogger.logError(e, `Failed to sign-in with ${provider}`);\n }\n this.signingWith.set(undefined);\n }\n }\n\n protected onLoggedIn(userCredential: UserCredential): void {\n this.signingWith.set(undefined);\n if (!userCredential.user) {\n return;\n }\n if (userCredential.user.email) {\n const prevEmail = localStorage.getItem('emailForSignIn') || '';\n if (!prevEmail) {\n localStorage.setItem('emailForSignIn', userCredential.user.email);\n }\n }\n const authState: ISneatAuthState = {\n status: AuthStatuses.authenticated,\n user: userCredential.user,\n };\n this.userService.onUserSignedIn(authState);\n }\n\n 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 this.signingWith.set(undefined);\n }\n}\n","<ion-header>\n <ion-toolbar color=\"light\">\n <ion-buttons slot=\"start\">\n <ion-back-button />\n </ion-buttons>\n <ion-title>Login @ {{ appTitle }}</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content id=\"main-content\">\n @if (reason) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <h2 class=\"reason-title\">{{ reason }}</h2>\n @if (reasonDetail) {\n <p class=\"reason-detail\">{{ reasonDetail }}</p>\n }\n </ion-card-content>\n </ion-card>\n } @else if (to) {\n <ion-card color=\"tertiary\">\n <ion-card-content>\n <p>Please sign in to join a team</p>\n </ion-card-content>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n This app is free to use &\n <a target=\"_blank\" href=\"https://github.com/sneat-co\">open source</a>.\n </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 <ion-button expand=\"block\" (click)=\"continueToApp()\">Continue</ion-button>\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-email-login-form\n (signingWithChange)=\"onEmailFormStatusChanged()\"\n (loggedIn)=\"onLoggedIn($event)\"\n />\n\n <ion-card>\n <ion-item-divider color=\"light\">\n <ion-label\n color=\"medium\"\n style=\"text-align: center; width: 100%; font-weight: bold\"\n >\n Quick login\n </ion-label>\n </ion-item-divider>\n <ion-grid class=\"ion-grid-layout\">\n @if (!isNativePlatform) {\n <ion-row>\n <ion-col>\n <div class=\"ion-padding\" style=\"text-align: center\">\n <sneat-login-with-telegram />\n </div>\n </ion-col>\n </ion-row>\n }\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('google.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"google.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"danger\" name=\"logo-google\" slot=\"start\" />\n }\n <ion-label color=\"danger\"> Login with Google</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('apple.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"apple.com\") {\n <ion-spinner slot=\"start\" name=\"lines-small\" />\n } @else {\n <ion-icon color=\"dark\" name=\"logo-apple\" slot=\"start\" />\n }\n\n <ion-label color=\"dark\"> Login with Apple</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('microsoft.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"microsoft.com\") {\n <ion-spinner\n slot=\"start\"\n color=\"secondary\"\n name=\"lines-small\"\n />\n } @else {\n <ion-icon slot=\"start\" color=\"secondary\" name=\"logo-windows\" />\n }\n <ion-label color=\"secondary\">Login with Microsoft</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('facebook.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"facebook.com\") {\n <ion-spinner slot=\"start\" color=\"primary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"primary\" name=\"logo-facebook\" />\n }\n <ion-label color=\"primary\">Login with Facebook</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n <ion-row>\n <ion-col size=\"12\" size-md=\"6\">\n <ion-list lines=\"none\">\n <ion-item\n (click)=\"loginWith('github.com')\"\n tappable\n [disabled]=\"!!signingWith()\"\n >\n @if (signingWith() === \"github.com\") {\n <ion-spinner slot=\"start\" color=\"tertiary\" name=\"lines-small\" />\n } @else {\n <ion-icon slot=\"start\" color=\"tertiary\" name=\"logo-github\" />\n }\n <ion-label color=\"tertiary\">Login with GitHub</ion-label>\n </ion-item>\n </ion-list>\n </ion-col>\n </ion-row>\n </ion-grid>\n </ion-card>\n }\n\n <p style=\"text-align: center; font-size: smaller\">\n <ion-text color=\"medium\">\n If any issues get\n <a href=\"mailto:help@sneat.app?subject=Problem+with+login+at+Sneat.app\"\n >help@sneat.app</a\n >\n </ion-text>\n </p>\n</ion-content>\n"]}
|