checking auth

This commit is contained in:
sdarbinyan
2026-05-15 13:41:11 +04:00
parent 5d58a387ca
commit a0ffcf0f86
2 changed files with 29 additions and 4 deletions

View File

@@ -32,7 +32,9 @@
autocomplete="off" autocomplete="off"
maxlength="20" 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>
</div> </div>

View File

@@ -97,6 +97,7 @@ export class FastcheckPage {
webSessionId = signal<string>(''); webSessionId = signal<string>('');
paid = signal<boolean>(false); paid = signal<boolean>(false);
loginOnly = signal<boolean>(false); loginOnly = signal<boolean>(false);
isNewFlow = signal<boolean>(false);
sessionToken = signal<string>(localStorage.getItem('fc_session') ?? ''); sessionToken = signal<string>(localStorage.getItem('fc_session') ?? '');
private pollHandle: ReturnType<typeof setInterval> | null = null; private pollHandle: ReturnType<typeof setInterval> | null = null;
private lastLookedUpNumber = ''; private lastLookedUpNumber = '';
@@ -276,6 +277,7 @@ export class FastcheckPage {
if (!this.canPay()) return; if (!this.canPay()) return;
this.error.set(''); this.error.set('');
this.loginOnly.set(false); this.loginOnly.set(false);
this.isNewFlow.set(false);
this.openPopup(); this.openPopup();
} }
@@ -287,6 +289,7 @@ export class FastcheckPage {
shareByTelegram(): void { shareByTelegram(): void {
if (!this.canShare()) return; if (!this.canShare()) return;
this.error.set(''); this.error.set('');
this.isNewFlow.set(false);
const tg = this.telegramId(); const tg = this.telegramId();
if (tg) { if (tg) {
@@ -299,6 +302,22 @@ export class FastcheckPage {
this.openPopup(); 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. */ /** POST /api/fastcheck/message/{telegramID} with all fastcheck fields. */
private sendFastcheckToTelegram(telegramId: string): void { private sendFastcheckToTelegram(telegramId: string): void {
const url = `${FASTCHECK_STORE_API}/fastcheck/message/${encodeURIComponent(telegramId)}`; const url = `${FASTCHECK_STORE_API}/fastcheck/message/${encodeURIComponent(telegramId)}`;
@@ -334,7 +353,9 @@ export class FastcheckPage {
if (res?.Status) { if (res?.Status) {
this.popupLoading.set(false); this.popupLoading.set(false);
this.webSessionId.set(existing); this.webSessionId.set(existing);
if (this.loginOnly()) { if (this.isNewFlow()) {
this.doRedirectToNew();
} else if (this.loginOnly()) {
this.paid.set(true); this.paid.set(true);
} else { } else {
this.acceptFastcheck(existing); this.acceptFastcheck(existing);
@@ -373,7 +394,7 @@ export class FastcheckPage {
closePopup(): void { closePopup(): void {
this.popupOpen.set(false); this.popupOpen.set(false);
this.stopPolling(); 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. // Keep session alive — user is logged in, preserve token for next action.
const tok = this.webSessionId(); const tok = this.webSessionId();
localStorage.setItem('fc_session', tok); localStorage.setItem('fc_session', tok);
@@ -400,7 +421,9 @@ export class FastcheckPage {
next: (res) => { next: (res) => {
if (res?.Status) { if (res?.Status) {
this.stopPolling(); this.stopPolling();
if (this.loginOnly()) { if (this.isNewFlow()) {
this.doRedirectToNew();
} else if (this.loginOnly()) {
// Identified — use userId as telegramID and send the fastcheck. // Identified — use userId as telegramID and send the fastcheck.
const tg = res.userId || res.userSessionId || ''; const tg = res.userId || res.userSessionId || '';
if (tg) { if (tg) {