Skip to content

Instantly share code, notes, and snippets.

@martinAlt335
Created May 22, 2022 02:13
Show Gist options
  • Save martinAlt335/3424b56d0bb04761f463a0940a60d264 to your computer and use it in GitHub Desktop.
Save martinAlt335/3424b56d0bb04761f463a0940a60d264 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import SuperTokens from 'supertokens-website';
import { environment } from '../../../environments/environment';
import { CookieService } from 'ngx-cookie-service';
@Injectable({
providedIn: 'root',
})
export class SuperTokensService {
constructor(private cookieService: CookieService) {
SuperTokens.init({
apiDomain: environment.apiUrl,
apiBasePath: '/auth',
});
}
async attemptRefreshingSession(): Promise<boolean> {
return SuperTokens.attemptRefreshingSession();
}
async signOut(): Promise<void> {
try {
await SuperTokens.signOut();
this.cookieService.delete('sIRTFrontend', '/');
} catch (e) {
console.log(`No session to sign-out from. Ignoring request. ${e}`);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment