-
-
Save martinAlt335/3424b56d0bb04761f463a0940a60d264 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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