From da224d234cde967d6b6a09690e825cb02d37cb93 Mon Sep 17 00:00:00 2001 From: Hongyuan Ma Date: Wed, 4 Jul 2018 11:46:40 +0800 Subject: [PATCH] add onLogout function --- front-end/src/component/nav-top/index.jsx | 20 +++++++++++++++----- web/apps/users/views.py | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/front-end/src/component/nav-top/index.jsx b/front-end/src/component/nav-top/index.jsx index a9843b2..11caa9f 100644 --- a/front-end/src/component/nav-top/index.jsx +++ b/front-end/src/component/nav-top/index.jsx @@ -3,17 +3,27 @@ import {Link} from 'react-router-dom'; import './index.css'; import slonik from 'image/slonik.png' - +import PGUtil from 'util/util.jsx' +const _util = new PGUtil(); +import User from 'service/user-service.jsx' +const _user = new User(); class NavTop extends React.Component { constructor(props) { super(props); - this.state = {isLoggedIn: true} + this.state = { + username: _util.getStorage('userInfo').username || '' + } } - // log out - onLogout() { - //todo + // logout + onLogout(){ + _user.logout().then(res => { + _util.removeStorage('userInfo'); + window.location.href = '/login'; + }, errMsg => { + _util.errorTips(errMsg); + }); } render() { diff --git a/web/apps/users/views.py b/web/apps/users/views.py index 5125a51..fc6795f 100644 --- a/web/apps/users/views.py +++ b/web/apps/users/views.py @@ -27,7 +27,7 @@ class CustomBackend(ModelBackend): class UserMachinePermission(permissions.BasePermission): """ - Global permission check for blacklisted IPs. + Machine permission check """ def has_permission(self, request, view): -- 2.39.5