From 5cd2cf6cc7e236f4e9f7e63da162d9012eb9e3d1 Mon Sep 17 00:00:00 2001 From: Hongyuan Ma Date: Sun, 8 Jul 2018 11:50:28 +0800 Subject: [PATCH] add UnauthorizedCode --- front-end/src/app.jsx | 2 +- front-end/src/component/nav-top/index.jsx | 22 +++++------ front-end/src/page/portal/index.jsx | 16 ++++++-- front-end/src/service/user-service.jsx | 11 +++--- front-end/src/util/constant.jsx | 2 +- front-end/src/util/util.jsx | 48 +++++++++++++---------- web/apps/test_records/views.py | 1 + web/apps/user_operation/views.py | 25 +++++++++--- web/apps/util/__init__.py | 0 web/apps/util/exception_handler.py | 16 ++++++++ web/apps/util/response.py | 38 ++++++++++++++++++ web/pgperffarm/settings.py | 15 +++---- web/pgperffarm/urls.py | 2 + 13 files changed, 144 insertions(+), 54 deletions(-) create mode 100644 web/apps/util/__init__.py create mode 100644 web/apps/util/exception_handler.py create mode 100644 web/apps/util/response.py diff --git a/front-end/src/app.jsx b/front-end/src/app.jsx index c2f23ec..78443b1 100644 --- a/front-end/src/app.jsx +++ b/front-end/src/app.jsx @@ -1,6 +1,6 @@ import React from 'react'; import ReactDom from 'react-dom'; -import {HashRouter as Router, Route, Link, Redirect, Switch} from 'react-router-dom'; +import {BrowserRouter as Router, Route, Link, Redirect, Switch} from 'react-router-dom'; import createHistory from 'history/createHashHistory' const history = createHistory() import {spring, AnimatedRoute, AnimatedSwitch} from 'react-router-transition'; diff --git a/front-end/src/component/nav-top/index.jsx b/front-end/src/component/nav-top/index.jsx index 69157fc..f474075 100644 --- a/front-end/src/component/nav-top/index.jsx +++ b/front-end/src/component/nav-top/index.jsx @@ -18,13 +18,9 @@ class NavTop extends React.Component { } // logout - onLogout(){ - _user.logout().then(res => { - _util.removeStorage('userInfo'); - window.location.href = '/login'; - }, errMsg => { - _util.errorTips(errMsg); - }); + onLogout() { + _util.removeStorage('userInfo'); + window.location.href = '/login'; } render() { @@ -34,19 +30,20 @@ class NavTop extends React.Component { if (isLoggedIn) { button =