Commit 63efad97 by ethanlamzs

登陆服务的对接

1 parent cb00b86a
...@@ -74,8 +74,8 @@ const proxy = { ...@@ -74,8 +74,8 @@ const proxy = {
'GET /api/profile/basic': getProfileBasicData, 'GET /api/profile/basic': getProfileBasicData,
'GET /api/profile/advanced': getProfileAdvancedData, 'GET /api/profile/advanced': getProfileAdvancedData,
'POST /api/login/account': (req, res) => { 'POST /api/login/account': (req, res) => {
const { password, userName, type } = req.body; const { secret, account, type } = req.body;
if(password === '888888' && userName === 'admin'){ if(secret === '888888' && account === 'admin'){
res.send({ res.send({
status: 'ok', status: 'ok',
type, type,
...@@ -83,7 +83,7 @@ const proxy = { ...@@ -83,7 +83,7 @@ const proxy = {
}); });
return ; return ;
} }
if(password === '123456' && userName === 'user'){ if(secret === '123456' && account === 'user'){
res.send({ res.send({
status: 'ok', status: 'ok',
type, type,
......
...@@ -16,7 +16,7 @@ export default { ...@@ -16,7 +16,7 @@ export default {
payload: response, payload: response,
}); });
// Login successfully // Login successfully
if (response.status === 'ok') { if (response.ext.status === 'ok') {
// 非常粗暴的跳转,登陆成功之后权限会变成user或admin,会自动重定向到主页 // 非常粗暴的跳转,登陆成功之后权限会变成user或admin,会自动重定向到主页
// Login success after permission changes to admin or user // Login success after permission changes to admin or user
// The refresh will automatically redirect to the home page // The refresh will automatically redirect to the home page
...@@ -27,6 +27,7 @@ export default { ...@@ -27,6 +27,7 @@ export default {
*logout(_, { put, select }) { *logout(_, { put, select }) {
try { try {
// get location pathname // get location pathname
console.log("_logout");
const urlParams = new URL(window.location.href); const urlParams = new URL(window.location.href);
const pathname = yield select(state => state.routing.location.pathname); const pathname = yield select(state => state.routing.location.pathname);
// add the parameters in the url // add the parameters in the url
...@@ -39,9 +40,14 @@ export default { ...@@ -39,9 +40,14 @@ export default {
yield put({ yield put({
type: 'changeLoginStatus', type: 'changeLoginStatus',
payload: { payload: {
ext:{
status: false, status: false,
currentAuthority: 'guest', currentAuthority: 'guest',
}, },
token:{
value:"unknow"
},
},
}); });
window.location.reload(); window.location.reload();
} }
...@@ -50,11 +56,11 @@ export default { ...@@ -50,11 +56,11 @@ export default {
reducers: { reducers: {
changeLoginStatus(state, { payload }) { changeLoginStatus(state, { payload }) {
setAuthority(payload.currentAuthority); setAuthority(payload.ext.currentAuthority,payload.token.value);
return { return {
...state, ...state,
status: payload.status, status: payload.ext.status,
type: payload.type, type: payload.ext.type,
}; };
}, },
}, },
......
...@@ -63,8 +63,8 @@ export default class LoginPage extends Component { ...@@ -63,8 +63,8 @@ export default class LoginPage extends Component {
!login.submitting && !login.submitting &&
this.renderMessage('账户或密码错误(admin/888888)') this.renderMessage('账户或密码错误(admin/888888)')
} }
<UserName name="userName" placeholder="admin/user" /> <UserName name="account" placeholder="admin/user" />
<Password name="password" placeholder="888888/123456" /> <Password name="secret" placeholder="888888/123456" />
</Tab> </Tab>
<Tab key="mobile" tab="手机号登录"> <Tab key="mobile" tab="手机号登录">
{ {
......
...@@ -61,7 +61,10 @@ export async function queryFakeList(params) { ...@@ -61,7 +61,10 @@ export async function queryFakeList(params) {
} }
export async function fakeAccountLogin(params) { export async function fakeAccountLogin(params) {
return request('/api/login/account', { params.authType = 'THIRD_PART';
params.ext={type:params.type};
console.log(params);
return request('/api/token/get', {
method: 'POST', method: 'POST',
body: params, body: params,
}); });
......
...@@ -3,6 +3,13 @@ export function getAuthority() { ...@@ -3,6 +3,13 @@ export function getAuthority() {
return localStorage.getItem('antd-pro-authority') || 'admin'; return localStorage.getItem('antd-pro-authority') || 'admin';
} }
export function setAuthority(authority) { export function setAuthority(authority,token) {
if(token)
localStorage.setItem('session_token',token);
return localStorage.setItem('antd-pro-authority', authority); return localStorage.setItem('antd-pro-authority', authority);
} }
export function getUserToken(){
return localStorage.getItem('session_token'||'unkonw');
}
\ No newline at end of file \ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!