Fix re-authentication
This commit is contained in:
@@ -66,7 +66,10 @@ export default class AuthenticationClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkSession(resolve, reject) {
|
checkSession(resolve, reject) {
|
||||||
this.webAuth.checkSession({state: {returnUrl: window.location.href}}, (err, result) => {
|
const state = {returnUrl: window.location.href};
|
||||||
|
const nonce = new Date().getTime().toString();
|
||||||
|
storeStateAndNonce(state, nonce);
|
||||||
|
this.webAuth.checkSession({state: JSON.stringify(state), nonce: nonce}, (err, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err || 'Re-authentication failed');
|
return reject(err || 'Re-authentication failed');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -22,14 +22,7 @@ const errorLink = onError(({ graphQLErrors, networkError, operation, forward })
|
|||||||
}
|
}
|
||||||
if (networkError) {
|
if (networkError) {
|
||||||
if (networkError.statusCode === 401) {
|
if (networkError.statusCode === 401) {
|
||||||
webAuth.checkSession((response) => {
|
webAuth.checkSession(() => {
|
||||||
const oldHeaders = operation.getContext().headers;
|
|
||||||
operation.setContext({
|
|
||||||
headers: {
|
|
||||||
...oldHeaders,
|
|
||||||
Authorization: `Bearer ${webAuth.accessToken()}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return forward(operation);
|
return forward(operation);
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user