@vyro-x/react-auth
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -9,4 +9,4 @@ import { AuthArgs } from '../types'; | ||
} & AuthArgs; | ||
export declare const logout: (args?: LogoutArgs) => void; | ||
export declare const logout: (args?: LogoutArgs) => Promise<void>; | ||
export declare const getLogoutUrl: (args?: LogoutArgs) => string; | ||
export {}; |
@@ -7,5 +7,9 @@ "use strict"; | ||
const tokens_1 = require("./tokens"); | ||
const logout = (args) => { | ||
const logout = async (args) => { | ||
const config = (0, config_1.getConfig)(); | ||
(0, tokens_1.clearAccessToken)(); | ||
(0, tokens_1.clearRefreshToken)(); | ||
if (config.onAuth) { | ||
await config.onLogout(); | ||
} | ||
location.href = (0, exports.getLogoutUrl)(args); | ||
@@ -12,0 +16,0 @@ }; |
@@ -32,2 +32,5 @@ "use strict"; | ||
(0, tokens_1.setRefreshToken)(refresh_token); | ||
if (config.onAuth) { | ||
await config.onAuth(user_id); | ||
} | ||
return { user_id }; | ||
@@ -34,0 +37,0 @@ } |
@@ -23,4 +23,7 @@ "use strict"; | ||
(0, tokens_1.setRefreshToken)(refresh_token); | ||
if (config.onAuth) { | ||
await config.onAuth(user_id); | ||
} | ||
return { user_id }; | ||
}; | ||
exports.verify = verify; |
@@ -30,2 +30,4 @@ export type Roles = 'admin' | 'customer' | 'public' | 'showroom:manager' | 'showroom:support' | 'showroom:reporting'; | ||
authApiUrl: string; | ||
onAuth?: (userId: string) => Promise<void> | void; | ||
onLogout?: () => Promise<void> | void; | ||
}; |
{ | ||
"name": "@vyro-x/react-auth", | ||
"description": "Client authentication", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "lib/index.js", |
34804
745