logout done
This commit is contained in:
parent
377e5bb936
commit
a75e927ee8
@ -63,8 +63,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
// since we use jwt, session is not necessary
|
// since we use jwt, session is not necessary
|
||||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
|
// TODO: we should use a better way to match the resources
|
||||||
// requests for resource and auth api are always allowed
|
// requests for resource and auth api are always allowed
|
||||||
.antMatchers("/", "/*.html", "/favicon.ico", "/**/*.html").permitAll()
|
.antMatchers("/", "/*.html", "/**/*.js", "/**/*.css", "/favicon.ico", "/**/*.html", "/**/*.svg", "/console-fe/public/*", "/**/*.png", "/*.png").permitAll()
|
||||||
.antMatchers("/v1/cs/health").permitAll()
|
.antMatchers("/v1/cs/health").permitAll()
|
||||||
.antMatchers("/v1/auth/**").permitAll()
|
.antMatchers("/v1/auth/**").permitAll()
|
||||||
.anyRequest().authenticated();
|
.anyRequest().authenticated();
|
||||||
|
@ -26,7 +26,7 @@ module.exports = Object.assign({}, base, {
|
|||||||
context: ['/'],
|
context: ['/'],
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
secure: false,
|
secure: false,
|
||||||
target: 'http://console.nacos.io',
|
target: 'http://localhost:8848',
|
||||||
pathRewrite: {'^/v1' : '/nacos/v1'}
|
pathRewrite: {'^/v1' : '/nacos/v1'}
|
||||||
}],
|
}],
|
||||||
disableHostCheck: true,
|
disableHostCheck: true,
|
||||||
|
@ -613,7 +613,10 @@ const request = (function(_global) {
|
|||||||
// 处理403 forbidden
|
// 处理403 forbidden
|
||||||
if (error && error.status === 403) {
|
if (error && error.status === 403) {
|
||||||
// 跳转至login页
|
// 跳转至login页
|
||||||
window.location = '/#/login';
|
// TODO: 用 react-router 重写,改造成本比较高,这里先hack
|
||||||
|
const url = window.location.href;
|
||||||
|
const base_url = url.split('#')[0];
|
||||||
|
window.location = `${base_url}#/login`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { withRouter } from 'react-router-dom';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { ConfigProvider } from '@alifd/next';
|
import { ConfigProvider } from '@alifd/next';
|
||||||
import siteConfig from '../config';
|
import siteConfig from '../config';
|
||||||
@ -20,6 +21,7 @@ import { aliwareIntl } from '@/globalLib';
|
|||||||
|
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
|
|
||||||
|
@withRouter
|
||||||
@connect(
|
@connect(
|
||||||
state => ({ ...state.locale }),
|
state => ({ ...state.locale }),
|
||||||
{ changeLanguage }
|
{ changeLanguage }
|
||||||
@ -37,8 +39,17 @@ class Header extends React.Component {
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
logout = () => {
|
||||||
|
window.localStorage.clear();
|
||||||
|
this.props.history.push('/login');
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { locale = {}, language = 'en-us' } = this.props;
|
const {
|
||||||
|
locale = {},
|
||||||
|
language = 'en-us',
|
||||||
|
location: { pathname },
|
||||||
|
} = this.props;
|
||||||
const { home, docs, blog, community, languageSwitchButton } = locale;
|
const { home, docs, blog, community, languageSwitchButton } = locale;
|
||||||
const BASE_URL = `https://nacos.io/${language}/`;
|
const BASE_URL = `https://nacos.io/${language}/`;
|
||||||
const NAV_MENU = [
|
const NAV_MENU = [
|
||||||
@ -74,6 +85,12 @@ class Header extends React.Component {
|
|||||||
title={siteConfig.name}
|
title={siteConfig.name}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
{/* if is login page, we will show logout */}
|
||||||
|
{pathname !== '/login' && (
|
||||||
|
<span className="logout" onClick={this.logout}>
|
||||||
|
退出
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
<span className="language-switch language-switch-primary" onClick={this.switchLang}>
|
<span className="language-switch language-switch-primary" onClick={this.switchLang}>
|
||||||
{languageSwitchButton}
|
{languageSwitchButton}
|
||||||
</span>
|
</span>
|
||||||
|
@ -98,6 +98,17 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
.header-container .header-body .logout {
|
||||||
|
float: right;
|
||||||
|
display: inline-block;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin-right: 40px;
|
||||||
|
text-align: center;
|
||||||
|
font-family: PingFangSC-Medium;
|
||||||
|
color: white;
|
||||||
|
font-size: 14px;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
.header-container .header-body .language-switch:hover {
|
.header-container .header-body .language-switch:hover {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Card, Form, Input, Message } from '@alifd/next';
|
import { Card, Form, Input, Message } from '@alifd/next';
|
||||||
|
import { withRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
import Header from '../../layouts/Header';
|
import Header from '../../layouts/Header';
|
||||||
@ -7,6 +8,7 @@ import { request } from '../../globalLib';
|
|||||||
|
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
|
|
||||||
|
@withRouter
|
||||||
class Login extends React.Component {
|
class Login extends React.Component {
|
||||||
handleSubmit = values => {
|
handleSubmit = values => {
|
||||||
request({
|
request({
|
||||||
@ -19,7 +21,7 @@ class Login extends React.Component {
|
|||||||
// TODO: 封装一个方法存储、读取token
|
// TODO: 封装一个方法存储、读取token
|
||||||
localStorage.setItem('token', data);
|
localStorage.setItem('token', data);
|
||||||
// TODO: 使用react router
|
// TODO: 使用react router
|
||||||
window.location = '/#/';
|
this.props.history.push('/');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: () => {
|
error: () => {
|
||||||
@ -37,12 +39,12 @@ class Login extends React.Component {
|
|||||||
<section
|
<section
|
||||||
className="top-section"
|
className="top-section"
|
||||||
style={{
|
style={{
|
||||||
background: 'url(/img/black_dot.png) repeat',
|
background: 'url(img/black_dot.png) repeat',
|
||||||
backgroundSize: '14px 14px',
|
backgroundSize: '14px 14px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="vertical-middle product-area">
|
<div className="vertical-middle product-area">
|
||||||
<img className="product-logo" src="/img/nacos.png" />
|
<img className="product-logo" src="img/nacos.png" />
|
||||||
<p className="product-desc">
|
<p className="product-desc">
|
||||||
an easy-to-use dynamic service discovery, configuration and service management
|
an easy-to-use dynamic service discovery, configuration and service management
|
||||||
platform for building cloud native applications
|
platform for building cloud native applications
|
||||||
|
File diff suppressed because one or more lines are too long
BIN
console/src/main/resources/static/img/black_dot.png
Normal file
BIN
console/src/main/resources/static/img/black_dot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 114 B |
BIN
console/src/main/resources/static/img/nacos.png
Normal file
BIN
console/src/main/resources/static/img/nacos.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user