Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78ef6d9ca0 | ||
|
|
cee0bc4cfe | ||
|
|
9a8510d833 | ||
|
|
ee034a7252 | ||
|
|
65bb076384 |
+5
-10
@@ -80,7 +80,7 @@ export class SimApiCore {
|
|||||||
private debug: boolean = true
|
private debug: boolean = true
|
||||||
private auth: SimApiAuthConfig = {
|
private auth: SimApiAuthConfig = {
|
||||||
token_name: 'simapi-auth-token',
|
token_name: 'simapi-auth-token',
|
||||||
check_url: '/auth/check',
|
check_url: '/user/info',
|
||||||
logout_url: '/auth/logout',
|
logout_url: '/auth/logout',
|
||||||
login_url: '/auth/login',
|
login_url: '/auth/login',
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ export class SimApiCore {
|
|||||||
this.debug = config.debug
|
this.debug = config.debug
|
||||||
}
|
}
|
||||||
if (config.endpoints) {
|
if (config.endpoints) {
|
||||||
this.api.endpoints = { ...this.api.endpoints, ...config.endpoints }
|
this.api.endpoints = {...this.api.endpoints, ...config.endpoints}
|
||||||
}
|
}
|
||||||
if (config.defaultEndpoint) {
|
if (config.defaultEndpoint) {
|
||||||
this.api.defaultEndpoint = config.defaultEndpoint
|
this.api.defaultEndpoint = config.defaultEndpoint
|
||||||
@@ -185,7 +185,7 @@ export class SimApiCore {
|
|||||||
|
|
||||||
setToken(token: string): void {
|
setToken(token: string): void {
|
||||||
const name = this.auth.token_name
|
const name = this.auth.token_name
|
||||||
document.cookie = `${name}=${token}; path=/; secure; samesite=none`
|
document.cookie = `${name}=${token}; path=/; max-age=315360000; secure; samesite=none`
|
||||||
}
|
}
|
||||||
|
|
||||||
removeToken(): void {
|
removeToken(): void {
|
||||||
@@ -340,12 +340,7 @@ export class SimApiCore {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkLogin(url?: string | null): Promise<void> {
|
async checkLogin(url?: string | null): Promise<any> {
|
||||||
if (url !== null) {
|
return this.query(url ?? this.auth.check_url);
|
||||||
await this.query(url ?? this.auth.check_url).catch(() => {
|
|
||||||
})
|
|
||||||
} else if (this.getToken()) {
|
|
||||||
this.api.businessCallback[401]?.(null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user