Browse Source

dep: upgrade dva to 2.6.0-beta.16, fix warning (#5534)

* dep: upgrade dva to 2.6.0-beta.16, fix warning

* lint: fix eslint error

* lint: fix eslint error

* doc: add security comment
pull/5723/head
chencheng (云谦) 7 years ago
committed by 陈帅
parent
commit
9a1df9f403
  1. 2
      package.json
  2. 21
      src/models/login.ts

2
package.json

@ -61,7 +61,7 @@
"@antv/data-set": "^0.10.2", "@antv/data-set": "^0.10.2",
"antd": "^3.23.6", "antd": "^3.23.6",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"dva": "^2.4.1", "dva": "^2.6.0-beta.16",
"lodash": "^4.17.11", "lodash": "^4.17.11",
"moment": "^2.24.0", "moment": "^2.24.0",
"omit.js": "^1.0.2", "omit.js": "^1.0.2",

21
src/models/login.ts

@ -1,7 +1,7 @@
import { Reducer } from 'redux'; import { Reducer } from 'redux';
import { routerRedux } from 'dva/router';
import { Effect } from 'dva'; import { Effect } from 'dva';
import { stringify } from 'querystring'; import { stringify } from 'querystring';
import router from 'umi/router';
import { fakeAccountLogin, getFakeCaptcha } from '@/services/login'; import { fakeAccountLogin, getFakeCaptcha } from '@/services/login';
import { setAuthority } from '@/utils/authority'; import { setAuthority } from '@/utils/authority';
@ -57,25 +57,24 @@ const Model: LoginModelType = {
return; return;
} }
} }
yield put(routerRedux.replace(redirect || '/')); router.replace(redirect || '/');
} }
}, },
*getCaptcha({ payload }, { call }) { *getCaptcha({ payload }, { call }) {
yield call(getFakeCaptcha, payload); yield call(getFakeCaptcha, payload);
}, },
*logout(_, { put }) {
logout() {
const { redirect } = getPageQuery(); const { redirect } = getPageQuery();
// redirect // Note: There may be security issues, please note
if (window.location.pathname !== '/user/login' && !redirect) { if (window.location.pathname !== '/user/login' && !redirect) {
yield put( router.replace({
routerRedux.replace({ pathname: '/user/login',
pathname: '/user/login', search: stringify({
search: stringify({ redirect: window.location.href,
redirect: window.location.href,
}),
}), }),
); });
} }
}, },
}, },

Loading…
Cancel
Save