feat(rulib): token check

This commit is contained in:
2024-07-10 19:22:53 +03:00
parent 82a0ba102d
commit d1e32a94ca
3 changed files with 53 additions and 4 deletions

View File

@@ -15,6 +15,7 @@ import { EAuthTokenService } from "./enum";
export class AuthComponent implements AfterViewInit, OnDestroy {
private destroy$ = new Subject<void>();
@ViewChild("libSocialToken") libSocialToken: ElementRef<HTMLInputElement> | null = null;
isRuLibAuth = false;
constructor(
private route: ActivatedRoute,
private router: Router,
@@ -40,6 +41,15 @@ export class AuthComponent implements AfterViewInit, OnDestroy {
}
}
checkToken() {
this.rulibAuthService
.checkToken(this.rulibAuthService.getToken())
.pipe(takeUntil(this.destroy$))
.subscribe((data) => {
this.isRuLibAuth = data;
});
}
ngAfterViewInit(): void {
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((params) => {
const { token, service } = params;
@@ -50,6 +60,7 @@ export class AuthComponent implements AfterViewInit, OnDestroy {
if (this.libSocialToken) {
this.libSocialToken.nativeElement.value = this.rulibAuthService.getToken();
}
this.checkToken();
}
ngOnDestroy(): void {
this.destroy$.next();