1.初次登录必须修改密码
This commit is contained in:
@@ -3,6 +3,7 @@ export default {
|
||||
label: {
|
||||
one1: 'User name login',
|
||||
two2: 'Mobile number',
|
||||
changePwd: 'Change The Password',
|
||||
},
|
||||
link: {
|
||||
one3: 'Third party login',
|
||||
|
||||
@@ -3,6 +3,7 @@ export default {
|
||||
label: {
|
||||
one1: '账号密码登录',
|
||||
two2: '手机号登录',
|
||||
changePwd: '密码修改',
|
||||
},
|
||||
link: {
|
||||
one3: '第三方登录',
|
||||
@@ -12,6 +13,8 @@ export default {
|
||||
accountPlaceholder1: '请输入登录账号/邮箱/手机号',
|
||||
accountPlaceholder2: '请输入登录密码',
|
||||
accountPlaceholder3: '请输入验证码',
|
||||
accountPlaceholder4:'请输入新密码',
|
||||
accountPlaceholder5:'请再次输入新密码',
|
||||
accountBtnText: '登 录',
|
||||
},
|
||||
mobile: {
|
||||
|
||||
@@ -3,6 +3,7 @@ export default {
|
||||
label: {
|
||||
one1: '用戶名登入',
|
||||
two2: '手機號登入',
|
||||
changePwd: '密码修改',
|
||||
},
|
||||
link: {
|
||||
one3: '協力廠商登入',
|
||||
|
||||
@@ -44,7 +44,7 @@ export async function initBackEndControlRoutes() {
|
||||
if (!Session.get('token')) return false;
|
||||
// 触发初始化用户信息 pinia
|
||||
// https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP
|
||||
await useUserInfo().setUserInfos();
|
||||
await useUserInfo().getApiUserInfo();
|
||||
// 获取路由菜单数据
|
||||
const res = await getBackEndControlRoutes();
|
||||
// 无登录权限时,添加判断
|
||||
|
||||
@@ -28,6 +28,8 @@ import {checkVersion} from "/@/utils/upgrade";
|
||||
const storesThemeConfig = useThemeConfig(pinia);
|
||||
const {themeConfig} = storeToRefs(storesThemeConfig);
|
||||
const {isRequestRoutes} = themeConfig.value;
|
||||
import {useUserInfo} from "/@/stores/userInfo";
|
||||
const { userInfos } = storeToRefs(useUserInfo());
|
||||
|
||||
/**
|
||||
* 创建一个可以被 Vue 应用程序使用的路由实例
|
||||
@@ -111,7 +113,10 @@ router.beforeEach(async (to, from, next) => {
|
||||
next(`/login?redirect=${to.path}¶ms=${JSON.stringify(to.query ? to.query : to.params)}`);
|
||||
Session.clear();
|
||||
NProgress.done();
|
||||
} else if (token && to.path === '/login') {
|
||||
}else if (token && to.path === '/login' && userInfos.value.pwd_change_count===0 ) {
|
||||
next('/login');
|
||||
NProgress.done();
|
||||
} else if (token && to.path === '/login' && userInfos.value.pwd_change_count>0) {
|
||||
next('/home');
|
||||
NProgress.done();
|
||||
}else if(token && frameOutRoutes.includes(to.path) ){
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface UserInfosState {
|
||||
email: string;
|
||||
mobile: string;
|
||||
gender: string;
|
||||
pwd_change_count:null|number;
|
||||
dept_info: {
|
||||
dept_id: number;
|
||||
dept_name: string;
|
||||
|
||||
@@ -15,6 +15,7 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
email: '',
|
||||
mobile: '',
|
||||
gender: '',
|
||||
pwd_change_count:null,
|
||||
dept_info: {
|
||||
dept_id: 0,
|
||||
dept_name: '',
|
||||
@@ -29,16 +30,19 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
isSocketOpen: false
|
||||
}),
|
||||
actions: {
|
||||
async updateUserInfos() {
|
||||
let userInfos: any = await this.getApiUserInfo();
|
||||
this.userInfos.username = userInfos.data.name;
|
||||
this.userInfos.avatar = userInfos.data.avatar;
|
||||
this.userInfos.name = userInfos.data.name;
|
||||
this.userInfos.email = userInfos.data.email;
|
||||
this.userInfos.mobile = userInfos.data.mobile;
|
||||
this.userInfos.gender = userInfos.data.gender;
|
||||
this.userInfos.dept_info = userInfos.data.dept_info;
|
||||
this.userInfos.role_info = userInfos.data.role_info;
|
||||
async setPwdChangeCount(count: number) {
|
||||
this.userInfos.pwd_change_count = count;
|
||||
},
|
||||
async updateUserInfos(userInfos:any) {
|
||||
this.userInfos.username = userInfos.name;
|
||||
this.userInfos.avatar = userInfos.avatar;
|
||||
this.userInfos.name = userInfos.name;
|
||||
this.userInfos.email = userInfos.email;
|
||||
this.userInfos.mobile = userInfos.mobile;
|
||||
this.userInfos.gender = userInfos.gender;
|
||||
this.userInfos.dept_info = userInfos.dept_info;
|
||||
this.userInfos.role_info = userInfos.role_info;
|
||||
this.userInfos.pwd_change_count = userInfos.pwd_change_count;
|
||||
Session.set('userInfo', this.userInfos);
|
||||
},
|
||||
async setUserInfos() {
|
||||
@@ -55,6 +59,7 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
this.userInfos.gender = userInfos.data.gender;
|
||||
this.userInfos.dept_info = userInfos.data.dept_info;
|
||||
this.userInfos.role_info = userInfos.data.role_info;
|
||||
this.userInfos.pwd_change_count = userInfos.data.pwd_change_count;
|
||||
Session.set('userInfo', this.userInfos);
|
||||
}
|
||||
},
|
||||
@@ -65,7 +70,18 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
return request({
|
||||
url: '/api/system/user/user_info/',
|
||||
method: 'get',
|
||||
});
|
||||
}).then((res:any)=>{
|
||||
this.userInfos.username = res.data.name;
|
||||
this.userInfos.avatar = res.data.avatar;
|
||||
this.userInfos.name = res.data.name;
|
||||
this.userInfos.email = res.data.email;
|
||||
this.userInfos.mobile = res.data.mobile;
|
||||
this.userInfos.gender = res.data.gender;
|
||||
this.userInfos.dept_info = res.data.dept_info;
|
||||
this.userInfos.role_info = res.data.role_info;
|
||||
this.userInfos.pwd_change_count = res.data.pwd_change_count;
|
||||
Session.set('userInfo', this.userInfos);
|
||||
})
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -13,6 +13,15 @@ export function login(params: object) {
|
||||
data: params
|
||||
});
|
||||
}
|
||||
|
||||
export function loginChangePwd(data: object) {
|
||||
return request({
|
||||
url: '/api/system/user/login_change_password/',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
export function getUserInfo() {
|
||||
return request({
|
||||
url: '/api/system/user/user_info/',
|
||||
|
||||
Reference in New Issue
Block a user