@flusys/ng-auth 9.1.0-rc.1 → 9.1.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/README.md +2 -0
- package/fesm2022/flusys-ng-auth-administration-page.component-DmN4KqiR.mjs +146 -0
- package/fesm2022/flusys-ng-auth-administration-page.component-DmN4KqiR.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-branch-form.component-Df_sMC2G.mjs +743 -0
- package/fesm2022/flusys-ng-auth-branch-form.component-Df_sMC2G.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-branch-list.component-CWat6QWN.mjs +775 -0
- package/fesm2022/flusys-ng-auth-branch-list.component-CWat6QWN.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-company-form.component-BvZ4Pn8j.mjs +198 -0
- package/fesm2022/flusys-ng-auth-company-form.component-BvZ4Pn8j.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-company-list.component-Corh9AIh.mjs +241 -0
- package/fesm2022/flusys-ng-auth-company-list.component-Corh9AIh.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-extension-order.util-2XWSLqii.mjs +6 -0
- package/fesm2022/flusys-ng-auth-extension-order.util-2XWSLqii.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-forgot-password-page.component-BRTVZPX6.mjs +384 -0
- package/fesm2022/flusys-ng-auth-forgot-password-page.component-BRTVZPX6.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-login-page.component-DQl52Qau.mjs +1074 -0
- package/fesm2022/flusys-ng-auth-login-page.component-DQl52Qau.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-profile-page.component-b-8rPEXQ.mjs +1792 -0
- package/fesm2022/flusys-ng-auth-profile-page.component-b-8rPEXQ.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-register-page.component-D99y1jiA.mjs +1513 -0
- package/fesm2022/flusys-ng-auth-register-page.component-D99y1jiA.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-reset-password-page.component-C0tN_AW1.mjs +538 -0
- package/fesm2022/flusys-ng-auth-reset-password-page.component-C0tN_AW1.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-social-callback-page.component-gTD7_LJY.mjs +217 -0
- package/fesm2022/flusys-ng-auth-social-callback-page.component-gTD7_LJY.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-social-config-page.component-DpGmcb9n.mjs +541 -0
- package/fesm2022/flusys-ng-auth-social-config-page.component-DpGmcb9n.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-user-form.component-CM9UYc0q.mjs +1171 -0
- package/fesm2022/flusys-ng-auth-user-form.component-CM9UYc0q.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-user-list.component-Bew7gz-H.mjs +1046 -0
- package/fesm2022/flusys-ng-auth-user-list.component-Bew7gz-H.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth-verify-email-page.component-DB9iKvt3.mjs +545 -0
- package/fesm2022/flusys-ng-auth-verify-email-page.component-DB9iKvt3.mjs.map +1 -0
- package/fesm2022/flusys-ng-auth.mjs +3030 -10735
- package/fesm2022/flusys-ng-auth.mjs.map +1 -1
- package/package.json +5 -5
- package/types/flusys-ng-auth.d.ts +978 -1558
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flusys-ng-auth-reset-password-page.component-C0tN_AW1.mjs","names":[],"sources":["../../../projects/ng-auth/pages/reset-password/reset-password-page.component.ts"],"sourcesContent":["import {\n Component,\n computed,\n DestroyRef,\n effect,\n inject,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\nimport { form, FormField, required } from '@angular/forms/signals';\nimport { ActivatedRoute, RouterLink } from '@angular/router';\nimport { AppFloatingConfigurator } from '@flusys/ng-layout';\nimport { FButtonDirective, MessageService, PasswordComponent, UiIconComponent } from '@flusys/ng-ui';\nimport {\n TranslatePipe,\n TranslateService,\n} from '@flusys/ng-shared';\nimport { finalize } from 'rxjs';\nimport { AuthApiService } from '../../services/auth-api.service';\nimport { PasswordPolicyService } from '../../services/password-policy.service';\n\ninterface IResetPasswordFormModel {\n newPassword: string;\n confirmPassword: string;\n}\n\ntype PageState = 'form' | 'success' | 'invalid-token';\n\n@Component({\n selector: 'lib-reset-password-page',\n imports: [\n RouterLink,\n FButtonDirective,\n PasswordComponent,\n UiIconComponent,\n FormField,\n AppFloatingConfigurator,\n TranslatePipe,\n ],\n template: `\n <app-floating-configurator />\n <div\n class=\"bg-surface-ground flex items-center justify-center min-h-screen\"\n >\n <div\n class=\"flex flex-col items-center justify-center w-full max-w-[32rem] px-4\"\n >\n <div\n class=\"w-full\"\n style=\"border-radius: var(--f-content-border-radius); padding: 0.3rem; background: linear-gradient(180deg, var(--primary-color) 10%, rgba(33, 150, 243, 0) 30%)\"\n >\n <div\n class=\"w-full py-8 px-4 sm:py-12 sm:px-8 md:py-16 md:px-12\"\n style=\"border-radius: var(--f-content-border-radius); background: var(--f-content-background)\"\n >\n @switch (pageState()) {\n @case ('form') {\n <div class=\"text-center mb-8\">\n <div class=\"text-3xl font-medium mb-4 text-color\">\n {{ 'auth.reset.password.title' | translate }}\n </div>\n <span class=\"text-muted-color font-medium\">\n {{ 'auth.reset.password.subtitle' | translate }}\n </span>\n </div>\n\n <form (submit)=\"onSubmit($event)\">\n <label\n for=\"newPassword\"\n class=\"block text-lg font-medium mb-2 text-color\"\n >\n {{ 'auth.reset.password.new.password' | translate }}\n </label>\n <div class=\"mb-4\">\n <f-password\n [inputId]=\"'newPassword'\"\n [placeholder]=\"\n 'auth.reset.password.new.password.placeholder' | translate\n \"\n class=\"w-full\"\n [formField]=\"resetForm.newPassword\"\n autocomplete=\"new-password\"\n />\n @if (passwordValidationError()) {\n <small class=\"text-danger block mt-1\">{{\n passwordValidationError()\n }}</small>\n }\n </div>\n\n <label\n for=\"confirmPassword\"\n class=\"block text-lg font-medium mb-2 text-color\"\n >\n {{ 'auth.reset.password.confirm.password' | translate }}\n </label>\n <f-password\n [inputId]=\"'confirmPassword'\"\n [placeholder]=\"\n 'auth.reset.password.confirm.password.placeholder'\n | translate\n \"\n class=\"w-full mb-2\"\n [formField]=\"resetForm.confirmPassword\"\n autocomplete=\"new-password\"\n />\n\n @if (passwordMismatch()) {\n <small class=\"text-danger block mb-4\">{{\n 'auth.register.passwords.do.not.match' | translate\n }}</small>\n }\n\n <button\n fButton\n class=\"w-full mt-4 mb-4\"\n type=\"submit\"\n [disabled]=\"!canSubmit() || isLoading()\"\n >\n @if (isLoading()) {\n <ui-icon pButtonIcon name=\"spinner\" [spin]=\"true\"></ui-icon>\n }\n <span pButtonLabel>{{ 'auth.reset.password.reset.password' | translate }}</span>\n </button>\n\n <div class=\"flex items-center justify-center gap-2\">\n <a\n routerLink=\"/auth/login\"\n class=\"font-semibold text-primary cursor-pointer\"\n >\n {{ 'auth.login.back.to.sign.in' | translate }}\n </a>\n </div>\n </form>\n }\n\n @case ('success') {\n <div class=\"text-center\">\n <div class=\"flex justify-center mb-6\">\n <ui-icon name=\"check-circle\" class=\"text-6xl text-success\"></ui-icon>\n </div>\n <div class=\"text-3xl font-medium mb-4 text-color\">\n {{ 'auth.reset.password.success' | translate }}\n </div>\n <p class=\"text-muted-color font-medium mb-6\">\n {{ 'auth.reset.password.success.message' | translate }}\n </p>\n <a routerLink=\"/auth/login\">\n <button\n fButton\n class=\"w-full\"\n >\n <span pButtonLabel>{{ 'auth.login.sign.in' | translate }}</span>\n </button>\n </a>\n </div>\n }\n\n @case ('invalid-token') {\n <div class=\"text-center\">\n <div class=\"flex justify-center mb-6\">\n <ui-icon name=\"times-circle\" class=\"text-6xl text-danger\"></ui-icon>\n </div>\n <div class=\"text-3xl font-medium mb-4 text-color\">\n {{ 'auth.reset.password.invalid.link' | translate }}\n </div>\n <p class=\"text-muted-color font-medium mb-6\">\n {{ 'auth.reset.password.invalid.link.message' | translate }}\n </p>\n <a routerLink=\"/auth/forgot-password\">\n <button\n fButton\n class=\"w-full mb-4\"\n >\n <span pButtonLabel>{{\n 'auth.reset.password.request.new.link' | translate\n }}</span>\n </button>\n </a>\n <div class=\"mt-4\">\n <a\n routerLink=\"/auth/login\"\n class=\"font-semibold text-primary cursor-pointer\"\n >\n {{ 'auth.login.back.to.sign.in' | translate }}\n </a>\n </div>\n </div>\n }\n }\n </div>\n </div>\n </div>\n </div>\n `,\n})\nexport class ResetPasswordPageComponent {\n private readonly destroyRef = inject(DestroyRef);\n private readonly route = inject(ActivatedRoute);\n private readonly messageService = inject(MessageService);\n private readonly authApi = inject(AuthApiService);\n private readonly passwordPolicy = inject(PasswordPolicyService);\n private readonly translateAdapter = inject(TranslateService, {\n optional: true,\n });\n\n private translate(\n key: string,\n vars?: Record<string, unknown>,\n ): string {\n return this.translateAdapter?.translate(key, vars) ?? key;\n }\n\n private readonly queryParams = toSignal(this.route.queryParams);\n private tokenInitialized = false;\n\n private token = '';\n readonly isLoading = signal(false);\n readonly pageState = signal<PageState>('form');\n readonly formModel = signal<IResetPasswordFormModel>({\n newPassword: '',\n confirmPassword: '',\n });\n readonly resetForm = form(this.formModel, (f) => {\n required(f.newPassword, {\n message: this.translate('auth.validation.password.required'),\n });\n required(f.confirmPassword, {\n message: this.translate('auth.validation.confirm.password.required'),\n });\n });\n readonly passwordMismatch = computed(() => {\n const model = this.formModel();\n return (\n model.confirmPassword.length > 0 &&\n model.newPassword !== model.confirmPassword\n );\n });\n readonly passwordValidationError = computed(() =>\n this.passwordPolicy.validate(this.formModel().newPassword),\n );\n readonly canSubmit = computed(\n () =>\n this.resetForm().valid() &&\n !this.passwordValidationError() &&\n !this.passwordMismatch(),\n );\n\n constructor() {\n effect(() => {\n const params = this.queryParams();\n if (!params || this.tokenInitialized) return;\n\n this.tokenInitialized = true;\n this.token = params['token'] || '';\n if (!this.token) {\n this.pageState.set('invalid-token');\n }\n });\n }\n\n onSubmit(event: Event): void {\n event.preventDefault();\n\n if (!this.canSubmit()) {\n this.messageService.add({\n severity: 'error',\n summary: this.translate('shared.validation.error'),\n detail: this.translate('shared.fill.required.fields'),\n });\n return;\n }\n\n this.isLoading.set(true);\n const newPassword = this.formModel().newPassword;\n\n this.authApi\n .resetPassword(this.token, newPassword)\n .pipe(\n takeUntilDestroyed(this.destroyRef),\n finalize(() => this.isLoading.set(false)),\n )\n .subscribe({\n next: (response) => {\n this.messageService.add({\n severity: 'success',\n summary: this.translate('shared.success'),\n detail: response?.messageKey\n ? this.translate(response.messageKey, response.messageVariables)\n : response?.message,\n });\n this.pageState.set('success');\n },\n error: (error) => {\n const messageKey: string = error.error?.messageKey || '';\n const invalidTokenKeys = [\n 'auth.password.reset.token.expired',\n 'auth.password.reset.token.used',\n 'email.verification.token.invalid',\n ];\n if (invalidTokenKeys.includes(messageKey)) {\n this.pageState.set('invalid-token');\n }\n // Other errors handled by global interceptor\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;AAoMA,IAAa,6BAAb,MAAa,2BAA0B;CACpB,aAAa,OAAO,UAAU;CAC9B,QAAQ,OAAO,cAAc;CAC7B,iBAAiB,OAAO,cAAc;CACtC,UAAU,OAAO,cAAc;CAC/B,iBAAiB,OAAO,qBAAqB;CAC7C,mBAAmB,OAAO,kBAAkB,EAC3D,UAAU,KACX,CAAA;CAEO,UACN,KACA,MAA8B;EAE9B,OAAO,KAAK,kBAAkB,UAAU,KAAK,IAAI,KAAK;CACxD;CAEiB,cAAc,SAAS,KAAK,MAAM,WAAW;CACtD,mBAAmB;CAEnB,QAAQ;CACP,YAAY,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CACzB,YAAY,OAAkB,QAAO,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CACrC,YAAY,OAAgC;EACnD,aAAa;EACb,iBAAiB;CAClB,GAAC,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CACO,YAAY,KAAK,KAAK,YAAY,MAAK;EAC9C,SA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A,QAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,SAAA,CAAA,UAAA,SAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MACjB;IAAe,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MACf;IAAS,UAAA;IAAA,QAAA,CAAA,WAAA;IAAA,UAAA,CAAA,WAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MACT;IAAuB,UAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MACvB;IAAa,MAAA;GAAA;EAAA;CAAA,CAAA;;AA+JJ,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAA0B,YAAA,CAAA;EAxKtC,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,SAAS;IACP;IACA;IACA;IACA;IACA;IACA;IACA;GACD;GACD,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4JX,CAAA"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { AuthStateService, SocialAuthApiService, isCompanySelectionResponse, isLoginResponse } from "./flusys-ng-auth.mjs";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { Component, DestroyRef, computed, inject, signal } from "@angular/core";
|
|
4
|
+
import { ActivatedRoute, Router } from "@angular/router";
|
|
5
|
+
import { PlatformService, TranslatePipe, TranslateService } from "@flusys/ng-shared";
|
|
6
|
+
import { FButtonDirective, MessageService, UiIconComponent } from "@flusys/ng-ui";
|
|
7
|
+
import { AppFloatingConfigurator } from "@flusys/ng-layout";
|
|
8
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
9
|
+
var SocialCallbackPageComponent = class SocialCallbackPageComponent {
|
|
10
|
+
destroyRef = inject(DestroyRef);
|
|
11
|
+
route = inject(ActivatedRoute);
|
|
12
|
+
router = inject(Router);
|
|
13
|
+
platform = inject(PlatformService);
|
|
14
|
+
socialApi = inject(SocialAuthApiService);
|
|
15
|
+
authState = inject(AuthStateService);
|
|
16
|
+
messageService = inject(MessageService);
|
|
17
|
+
translateAdapter = inject(TranslateService, { optional: true });
|
|
18
|
+
_error = signal(null, ...ngDevMode ? [{ debugName: "_error" }] : /* istanbul ignore next */ []);
|
|
19
|
+
errorDetail = computed(() => {
|
|
20
|
+
const error = this._error();
|
|
21
|
+
if (!error) return null;
|
|
22
|
+
return "key" in error ? this.translate(error.key, error.vars) : error.raw;
|
|
23
|
+
}, ...ngDevMode ? [{ debugName: "errorDetail" }] : /* istanbul ignore next */ []);
|
|
24
|
+
constructor() {
|
|
25
|
+
if (this.platform.isServer) return;
|
|
26
|
+
this.exchangeCode();
|
|
27
|
+
}
|
|
28
|
+
backToLogin() {
|
|
29
|
+
this.router.navigate(["/auth/login"]);
|
|
30
|
+
}
|
|
31
|
+
exchangeCode() {
|
|
32
|
+
const params = this.route.snapshot.queryParamMap;
|
|
33
|
+
const providerError = params.get("error_description") ?? params.get("error");
|
|
34
|
+
if (providerError) {
|
|
35
|
+
this._error.set({ raw: providerError });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const code = params.get("code");
|
|
39
|
+
const state = params.get("state");
|
|
40
|
+
if (!code || !state) {
|
|
41
|
+
this._error.set({ key: "auth.social.state.invalid" });
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.socialApi.callback({
|
|
45
|
+
code,
|
|
46
|
+
state,
|
|
47
|
+
redirectUri: this.socialApi.redirectUri
|
|
48
|
+
}).pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
|
|
49
|
+
next: (response) => {
|
|
50
|
+
if (!response.data) {
|
|
51
|
+
this._error.set({ key: "auth.social.failed" });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (isCompanySelectionResponse(response)) {
|
|
55
|
+
this.authState.setSelectionState(response.data);
|
|
56
|
+
this.router.navigate(["/auth/login"]);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (isLoginResponse(response)) {
|
|
60
|
+
this.authState.setLoginState(response.data);
|
|
61
|
+
this.messageService.add({
|
|
62
|
+
severity: "success",
|
|
63
|
+
summary: this.translate("shared.success"),
|
|
64
|
+
detail: response.messageKey ? this.translate(response.messageKey, response.messageVariables) : response.message ?? this.translate("auth.login.success")
|
|
65
|
+
});
|
|
66
|
+
this.authState.navigateAfterLogin(this.returnUrl());
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
error: (error) => {
|
|
70
|
+
const messageKey = error?.error?.messageKey;
|
|
71
|
+
if (messageKey) this._error.set({
|
|
72
|
+
key: messageKey,
|
|
73
|
+
vars: error?.error?.messageVariables
|
|
74
|
+
});
|
|
75
|
+
else if (error?.error?.message) this._error.set({ raw: error.error.message });
|
|
76
|
+
else this._error.set({ key: "auth.social.failed" });
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
returnUrl() {
|
|
81
|
+
return this.socialApi.consumeReturnUrl();
|
|
82
|
+
}
|
|
83
|
+
translate(key, vars) {
|
|
84
|
+
return this.translateAdapter?.translate(key, vars) ?? key;
|
|
85
|
+
}
|
|
86
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
87
|
+
minVersion: "12.0.0",
|
|
88
|
+
version: "22.2.1",
|
|
89
|
+
ngImport: i0,
|
|
90
|
+
type: SocialCallbackPageComponent,
|
|
91
|
+
deps: [],
|
|
92
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
93
|
+
});
|
|
94
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
95
|
+
minVersion: "17.0.0",
|
|
96
|
+
version: "22.2.1",
|
|
97
|
+
type: SocialCallbackPageComponent,
|
|
98
|
+
isStandalone: true,
|
|
99
|
+
selector: "lib-social-callback-page",
|
|
100
|
+
ngImport: i0,
|
|
101
|
+
template: `
|
|
102
|
+
<app-floating-configurator />
|
|
103
|
+
<div class="bg-surface-ground flex items-center justify-center min-h-screen">
|
|
104
|
+
<div class="flex flex-col items-center gap-4 text-center px-4">
|
|
105
|
+
@if (errorDetail()) {
|
|
106
|
+
<ui-icon name="exclamation-circle" class="text-6xl text-danger"></ui-icon>
|
|
107
|
+
<div class="text-2xl font-medium text-color">
|
|
108
|
+
{{ 'auth.social.failed' | translate }}
|
|
109
|
+
</div>
|
|
110
|
+
<p class="text-muted-color font-medium">{{ errorDetail() }}</p>
|
|
111
|
+
<button fButton severity="secondary" [outlined]="true" (click)="backToLogin()">
|
|
112
|
+
<span>{{ 'auth.login.back.to.sign.in' | translate }}</span>
|
|
113
|
+
</button>
|
|
114
|
+
} @else {
|
|
115
|
+
<ui-icon name="spinner" [spin]="true" class="text-5xl text-primary"></ui-icon>
|
|
116
|
+
<div class="text-2xl font-medium text-color">
|
|
117
|
+
{{ 'auth.social.signing.in' | translate }}
|
|
118
|
+
</div>
|
|
119
|
+
}
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
`,
|
|
123
|
+
isInline: true,
|
|
124
|
+
dependencies: [
|
|
125
|
+
{
|
|
126
|
+
kind: "directive",
|
|
127
|
+
type: FButtonDirective,
|
|
128
|
+
selector: "[fButton]",
|
|
129
|
+
inputs: [
|
|
130
|
+
"severity",
|
|
131
|
+
"text",
|
|
132
|
+
"outlined",
|
|
133
|
+
"link",
|
|
134
|
+
"variant",
|
|
135
|
+
"rounded",
|
|
136
|
+
"raised",
|
|
137
|
+
"fluid",
|
|
138
|
+
"disabled",
|
|
139
|
+
"loading",
|
|
140
|
+
"loadingIcon",
|
|
141
|
+
"size",
|
|
142
|
+
"label",
|
|
143
|
+
"icon",
|
|
144
|
+
"iconPos",
|
|
145
|
+
"ariaLabel",
|
|
146
|
+
"plain"
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
kind: "component",
|
|
151
|
+
type: UiIconComponent,
|
|
152
|
+
selector: "ui-icon",
|
|
153
|
+
inputs: [
|
|
154
|
+
"name",
|
|
155
|
+
"size",
|
|
156
|
+
"spin",
|
|
157
|
+
"fill",
|
|
158
|
+
"severity"
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
kind: "component",
|
|
163
|
+
type: AppFloatingConfigurator,
|
|
164
|
+
selector: "app-floating-configurator"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
kind: "pipe",
|
|
168
|
+
type: TranslatePipe,
|
|
169
|
+
name: "translate"
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
175
|
+
minVersion: "12.0.0",
|
|
176
|
+
version: "22.2.1",
|
|
177
|
+
ngImport: i0,
|
|
178
|
+
type: SocialCallbackPageComponent,
|
|
179
|
+
decorators: [{
|
|
180
|
+
type: Component,
|
|
181
|
+
args: [{
|
|
182
|
+
selector: "lib-social-callback-page",
|
|
183
|
+
imports: [
|
|
184
|
+
FButtonDirective,
|
|
185
|
+
UiIconComponent,
|
|
186
|
+
TranslatePipe,
|
|
187
|
+
AppFloatingConfigurator
|
|
188
|
+
],
|
|
189
|
+
template: `
|
|
190
|
+
<app-floating-configurator />
|
|
191
|
+
<div class="bg-surface-ground flex items-center justify-center min-h-screen">
|
|
192
|
+
<div class="flex flex-col items-center gap-4 text-center px-4">
|
|
193
|
+
@if (errorDetail()) {
|
|
194
|
+
<ui-icon name="exclamation-circle" class="text-6xl text-danger"></ui-icon>
|
|
195
|
+
<div class="text-2xl font-medium text-color">
|
|
196
|
+
{{ 'auth.social.failed' | translate }}
|
|
197
|
+
</div>
|
|
198
|
+
<p class="text-muted-color font-medium">{{ errorDetail() }}</p>
|
|
199
|
+
<button fButton severity="secondary" [outlined]="true" (click)="backToLogin()">
|
|
200
|
+
<span>{{ 'auth.login.back.to.sign.in' | translate }}</span>
|
|
201
|
+
</button>
|
|
202
|
+
} @else {
|
|
203
|
+
<ui-icon name="spinner" [spin]="true" class="text-5xl text-primary"></ui-icon>
|
|
204
|
+
<div class="text-2xl font-medium text-color">
|
|
205
|
+
{{ 'auth.social.signing.in' | translate }}
|
|
206
|
+
</div>
|
|
207
|
+
}
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
`
|
|
211
|
+
}]
|
|
212
|
+
}],
|
|
213
|
+
ctorParameters: () => []
|
|
214
|
+
});
|
|
215
|
+
export { SocialCallbackPageComponent };
|
|
216
|
+
|
|
217
|
+
//# sourceMappingURL=flusys-ng-auth-social-callback-page.component-gTD7_LJY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flusys-ng-auth-social-callback-page.component-gTD7_LJY.mjs","names":[],"sources":["../../../projects/ng-auth/pages/social-callback/social-callback-page.component.ts"],"sourcesContent":["import { Component, computed, DestroyRef, inject, signal } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { AppFloatingConfigurator } from '@flusys/ng-layout';\nimport { PlatformService, TranslatePipe, TranslateService } from '@flusys/ng-shared';\nimport { FButtonDirective, MessageService, UiIconComponent } from '@flusys/ng-ui';\nimport {\n isCompanySelectionResponse,\n isLoginResponse,\n} from '../../interfaces/auth.interface';\nimport { AuthStateService } from '../../services/auth-state.service';\nimport { SocialAuthApiService } from '../../services/social-auth-api.service';\n\n@Component({\n selector: 'lib-social-callback-page',\n imports: [FButtonDirective, UiIconComponent, TranslatePipe, AppFloatingConfigurator],\n template: `\n <app-floating-configurator />\n <div class=\"bg-surface-ground flex items-center justify-center min-h-screen\">\n <div class=\"flex flex-col items-center gap-4 text-center px-4\">\n @if (errorDetail()) {\n <ui-icon name=\"exclamation-circle\" class=\"text-6xl text-danger\"></ui-icon>\n <div class=\"text-2xl font-medium text-color\">\n {{ 'auth.social.failed' | translate }}\n </div>\n <p class=\"text-muted-color font-medium\">{{ errorDetail() }}</p>\n <button fButton severity=\"secondary\" [outlined]=\"true\" (click)=\"backToLogin()\">\n <span>{{ 'auth.login.back.to.sign.in' | translate }}</span>\n </button>\n } @else {\n <ui-icon name=\"spinner\" [spin]=\"true\" class=\"text-5xl text-primary\"></ui-icon>\n <div class=\"text-2xl font-medium text-color\">\n {{ 'auth.social.signing.in' | translate }}\n </div>\n }\n </div>\n </div>\n `,\n})\nexport class SocialCallbackPageComponent {\n private readonly destroyRef = inject(DestroyRef);\n private readonly route = inject(ActivatedRoute);\n private readonly router = inject(Router);\n private readonly platform = inject(PlatformService);\n private readonly socialApi = inject(SocialAuthApiService);\n private readonly authState = inject(AuthStateService);\n private readonly messageService = inject(MessageService);\n private readonly translateAdapter = inject(TranslateService, {\n optional: true,\n });\n\n private readonly _error = signal<\n { key: string; vars?: Record<string, string | number> } | { raw: string } | null\n >(null);\n readonly errorDetail = computed(() => {\n const error = this._error();\n if (!error) return null;\n return 'key' in error ? this.translate(error.key, error.vars) : error.raw;\n });\n\n constructor() {\n if (this.platform.isServer) return;\n this.exchangeCode();\n }\n\n backToLogin(): void {\n this.router.navigate(['/auth/login']);\n }\n\n private exchangeCode(): void {\n const params = this.route.snapshot.queryParamMap;\n\n const providerError = params.get('error_description') ?? params.get('error');\n if (providerError) {\n this._error.set({ raw: providerError });\n return;\n }\n\n const code = params.get('code');\n const state = params.get('state');\n\n if (!code || !state) {\n this._error.set({ key: 'auth.social.state.invalid' });\n return;\n }\n\n this.socialApi\n .callback({ code, state, redirectUri: this.socialApi.redirectUri })\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe({\n next: (response) => {\n if (!response.data) {\n this._error.set({ key: 'auth.social.failed' });\n return;\n }\n\n if (isCompanySelectionResponse(response)) {\n this.authState.setSelectionState(response.data);\n this.router.navigate(['/auth/login']);\n return;\n }\n\n if (isLoginResponse(response)) {\n this.authState.setLoginState(response.data);\n this.messageService.add({\n severity: 'success',\n summary: this.translate('shared.success'),\n detail: response.messageKey\n ? this.translate(response.messageKey, response.messageVariables)\n : (response.message ?? this.translate('auth.login.success')),\n });\n this.authState.navigateAfterLogin(this.returnUrl());\n }\n },\n error: (error) => {\n const messageKey = error?.error?.messageKey;\n if (messageKey) {\n this._error.set({ key: messageKey, vars: error?.error?.messageVariables });\n } else if (error?.error?.message) {\n this._error.set({ raw: error.error.message });\n } else {\n this._error.set({ key: 'auth.social.failed' });\n }\n },\n });\n }\n\n private returnUrl(): string {\n return this.socialApi.consumeReturnUrl();\n }\n\n private translate(\n key: string,\n vars?: Record<string, unknown>,\n ): string {\n return this.translateAdapter?.translate(key, vars) ?? key;\n }\n}\n"],"mappings":";;;;;;;;AAuCA,IAAa,8BAAb,MAAa,4BAA2B;CACrB,aAAa,OAAO,UAAU;CAC9B,QAAQ,OAAO,cAAc;CAC7B,SAAS,OAAO,MAAM;CACtB,WAAW,OAAO,eAAe;CACjC,YAAY,OAAO,oBAAoB;CACvC,YAAY,OAAO,gBAAgB;CACnC,iBAAiB,OAAO,cAAc;CACtC,mBAAmB,OAAO,kBAAkB,EAC3D,UAAU,KACX,CAAA;CAEgB,SAAS,OAExB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CACE,cAAc,eAAc;EACnC,MAAM,QAAQ,KAAK,OAAM;EACzB,IAAI,CAAC,OAAO,OAAO;EACnB,OAAO,SAAS,QAAQ,KAAK,UAAU,MAAM,KAAK,MAAM,IAAI,IAAI,MAAM;CACxE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAEF,cAAA;EACE,IAAI,KAAK,SAAS,UAAU;EAC5B,K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