浏览代码

Only sign out if refresh tokens error is 401

tags/mobile-v9.2.1
Guillaume Vincent 3 年前
父节点
当前提交
c0e182b95c
共有 3 个文件被更改,包括 16 次插入6 次删除
  1. +4
    -3
      mobile/package.json
  2. +11
    -1
      mobile/src/AppContainer.js
  3. +1
    -2
      mobile/src/auth/authActions.js

+ 4
- 3
mobile/package.json 查看文件

@@ -6,11 +6,12 @@
"author": "Guillaume Vincent <guillaume@oslab.fr>",
"scripts": {
"android": "react-native run-android",
"android-log": "react-native log-android",
"ios": "react-native run-ios",
"ios-pod-install": "pod install --project-directory=./ios",
"log:android": "react-native log-android",
"clean:android": "cd android && ./gradlew clean && cd ../",
"ios": "react-native run-ios",
"log:ios": "react-native log-ios",
"clean:ios": "cd ios && xcodebuild clean && cd ../",
"ios-pod-install": "pod install --project-directory=./ios",
"start": "react-native start",
"test": "jest",
"test:watch": "jest --watch",


+ 11
- 1
mobile/src/AppContainer.js 查看文件

@@ -22,7 +22,17 @@ function App() {
if (isAuthenticated) {
dispatch(refreshTokens())
.then(() => dispatch(getPasswordProfiles()))
.catch(() => dispatch(signOut()));
.catch((error) => {
if (error.response) {
if (error.response.status === 401) {
dispatch(signOut());
}
} else if (error.request) {
console.log(error.request);
} else {
console.log("error", error.message);
}
});
}
}, [isAuthenticated, dispatch]);



+ 1
- 2
mobile/src/auth/authActions.js 查看文件

@@ -16,8 +16,7 @@ function getJWT(credentials) {
.then((response) => {
dispatch(setJWT(response.data));
return response;
})
.catch(console.error);
});
};
}



正在加载...
取消
保存