mirror of
https://github.com/janishutz/oidc-login-sdk.git
synced 2026-10-08 17:36:20 +02:00
chore(check): Add option to use queries
This commit is contained in:
1 parent
1915ba5628
commit
349e37f4a9
1 file changed
+3
-2
+3
-2
@@ -27,13 +27,14 @@ export const loginInNewTab = () => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a user is authenticated. This can also be done implicitly using a call to a protected endpoint
|
* Check if a user is authenticated. This can also be done implicitly using a call to a protected endpoint
|
||||||
|
* @param query Query string, without the leading question mark. E.g. `test=true&force=false`
|
||||||
* @returns A promise resolving to a boolean indicating authentication status
|
* @returns A promise resolving to a boolean indicating authentication status
|
||||||
*/
|
*/
|
||||||
export const check = async (): Promise<boolean> => {
|
export const check = async ( query?: string ): Promise<boolean> => {
|
||||||
let status: boolean;
|
let status: boolean;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
status = ( await request.get( config.get().authCheckEndpoint ?? '/auth/v2/check' ) ).ok;
|
status = ( await request.get( config.get().authCheckEndpoint ?? '/auth/v2/check' + ( query ? '?' + query : '' ) ) ).ok;
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
if ( e instanceof AuthError ) {
|
if ( e instanceof AuthError ) {
|
||||||
status = false;
|
status = false;
|
||||||
|
|||||||
Reference in new issue
Block a user