zavadil-ts-common 1.1.50 → 1.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -125,7 +125,7 @@ export class RestClientWithOAuth extends RestClient {
|
|
125
125
|
}
|
126
126
|
|
127
127
|
/**
|
128
|
-
* Try to obtain access token, then return true or
|
128
|
+
* Try to obtain access token, then return true or reject.
|
129
129
|
* This is basically only used when initializing and trying to determine whether we need to redirect user to login page
|
130
130
|
*/
|
131
131
|
checkAccessToken(privilege?: string): Promise<boolean> {
|
@@ -134,4 +134,17 @@ export class RestClientWithOAuth extends RestClient {
|
|
134
134
|
.then((accessToken) => true);
|
135
135
|
}
|
136
136
|
|
137
|
+
checkAndRedirectToLogin(): Promise<boolean> {
|
138
|
+
return this.checkAccessToken()
|
139
|
+
.catch(
|
140
|
+
() => this.getServerInfo().then(
|
141
|
+
(si) => {
|
142
|
+
const documentlocation = `${si.oauthServerUrl}/login?app_name=${si.targetAudience}&redirect_url=${document.location}`;
|
143
|
+
console.log('redirect', documentlocation);
|
144
|
+
return Promise.resolve(false);
|
145
|
+
}
|
146
|
+
)
|
147
|
+
);
|
148
|
+
}
|
149
|
+
|
137
150
|
}
|