checking auth
This commit is contained in:
@@ -32,7 +32,9 @@
|
||||
autocomplete="off"
|
||||
maxlength="20"
|
||||
/>
|
||||
<a class="btn btn--ghost" [href]="newQrUrl()" aria-label="Создать новый fastCHECK">{{ 'fastcheck.number_new' | translate }}</a>
|
||||
<button class="btn btn--ghost" type="button" (click)="createNewFastcheck($event)" aria-label="Создать новый fastCHECK">
|
||||
{{ 'fastcheck.number_new' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ export class FastcheckPage {
|
||||
webSessionId = signal<string>('');
|
||||
paid = signal<boolean>(false);
|
||||
loginOnly = signal<boolean>(false);
|
||||
isNewFlow = signal<boolean>(false);
|
||||
sessionToken = signal<string>(localStorage.getItem('fc_session') ?? '');
|
||||
private pollHandle: ReturnType<typeof setInterval> | null = null;
|
||||
private lastLookedUpNumber = '';
|
||||
@@ -276,6 +277,7 @@ export class FastcheckPage {
|
||||
if (!this.canPay()) return;
|
||||
this.error.set('');
|
||||
this.loginOnly.set(false);
|
||||
this.isNewFlow.set(false);
|
||||
this.openPopup();
|
||||
}
|
||||
|
||||
@@ -287,6 +289,7 @@ export class FastcheckPage {
|
||||
shareByTelegram(): void {
|
||||
if (!this.canShare()) return;
|
||||
this.error.set('');
|
||||
this.isNewFlow.set(false);
|
||||
|
||||
const tg = this.telegramId();
|
||||
if (tg) {
|
||||
@@ -299,6 +302,22 @@ export class FastcheckPage {
|
||||
this.openPopup();
|
||||
}
|
||||
|
||||
createNewFastcheck(event: Event): void {
|
||||
event.preventDefault();
|
||||
this.isNewFlow.set(true);
|
||||
this.loginOnly.set(false);
|
||||
this.openPopup();
|
||||
}
|
||||
|
||||
private doRedirectToNew(): void {
|
||||
const tok = this.webSessionId();
|
||||
if (tok) {
|
||||
localStorage.setItem('fc_session', tok);
|
||||
this.sessionToken.set(tok);
|
||||
}
|
||||
window.location.href = this.newQrUrl();
|
||||
}
|
||||
|
||||
/** POST /api/fastcheck/message/{telegramID} with all fastcheck fields. */
|
||||
private sendFastcheckToTelegram(telegramId: string): void {
|
||||
const url = `${FASTCHECK_STORE_API}/fastcheck/message/${encodeURIComponent(telegramId)}`;
|
||||
@@ -334,7 +353,9 @@ export class FastcheckPage {
|
||||
if (res?.Status) {
|
||||
this.popupLoading.set(false);
|
||||
this.webSessionId.set(existing);
|
||||
if (this.loginOnly()) {
|
||||
if (this.isNewFlow()) {
|
||||
this.doRedirectToNew();
|
||||
} else if (this.loginOnly()) {
|
||||
this.paid.set(true);
|
||||
} else {
|
||||
this.acceptFastcheck(existing);
|
||||
@@ -373,7 +394,7 @@ export class FastcheckPage {
|
||||
closePopup(): void {
|
||||
this.popupOpen.set(false);
|
||||
this.stopPolling();
|
||||
if (this.loginOnly() && this.paid()) {
|
||||
if ((this.loginOnly() || this.isNewFlow()) && this.paid()) {
|
||||
// Keep session alive — user is logged in, preserve token for next action.
|
||||
const tok = this.webSessionId();
|
||||
localStorage.setItem('fc_session', tok);
|
||||
@@ -400,7 +421,9 @@ export class FastcheckPage {
|
||||
next: (res) => {
|
||||
if (res?.Status) {
|
||||
this.stopPolling();
|
||||
if (this.loginOnly()) {
|
||||
if (this.isNewFlow()) {
|
||||
this.doRedirectToNew();
|
||||
} else if (this.loginOnly()) {
|
||||
// Identified — use userId as telegramID and send the fastcheck.
|
||||
const tg = res.userId || res.userSessionId || '';
|
||||
if (tg) {
|
||||
|
||||
Reference in New Issue
Block a user