Skip to content

Commit

Permalink
fix: send to login on 401
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Oct 5, 2023
1 parent d6e945e commit d2bd050
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion betanin/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def register_extensions(app):
MIGRATE.init_app(app, DB)
SOCKETIO.init_app(app)
JWT.init_app(app)
JWT._set_error_handler_callbacks(REST)


def register_cors(app):
Expand Down
6 changes: 5 additions & 1 deletion betanin_client/src/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ secureAxios.interceptors.request.use((config) => {
return config
}, undefined)
secureAxios.interceptors.response.use(undefined, (error) => {
if (error.response !== undefined && error.response.status === 401 && router.currentRoute.path !== '/login') {
if (
error.response !== undefined &&
(error.response.status === 401 || error.response.status === 422) &&
router.currentRoute.path !== '/login'
) {
// the token has expired. get a new one
auth.logout(router.currentRoute.fullPath)
}
Expand Down

0 comments on commit d2bd050

Please sign in to comment.