1.初次登录必须修改密码

This commit is contained in:
1638245306
2024-11-06 13:09:09 +08:00
parent 436a722ce8
commit 421e89823a
8 changed files with 49 additions and 13 deletions

View File

@@ -3,6 +3,7 @@ export default {
label: { label: {
one1: 'User name login', one1: 'User name login',
two2: 'Mobile number', two2: 'Mobile number',
changePwd: 'Change The Password',
}, },
link: { link: {
one3: 'Third party login', one3: 'Third party login',

View File

@@ -3,6 +3,7 @@ export default {
label: { label: {
one1: '账号密码登录', one1: '账号密码登录',
two2: '手机号登录', two2: '手机号登录',
changePwd: '密码修改',
}, },
link: { link: {
one3: '第三方登录', one3: '第三方登录',
@@ -12,6 +13,8 @@ export default {
accountPlaceholder1: '请输入登录账号/邮箱/手机号', accountPlaceholder1: '请输入登录账号/邮箱/手机号',
accountPlaceholder2: '请输入登录密码', accountPlaceholder2: '请输入登录密码',
accountPlaceholder3: '请输入验证码', accountPlaceholder3: '请输入验证码',
accountPlaceholder4:'请输入新密码',
accountPlaceholder5:'请再次输入新密码',
accountBtnText: '登 录', accountBtnText: '登 录',
}, },
mobile: { mobile: {

View File

@@ -3,6 +3,7 @@ export default {
label: { label: {
one1: '用戶名登入', one1: '用戶名登入',
two2: '手機號登入', two2: '手機號登入',
changePwd: '密码修改',
}, },
link: { link: {
one3: '協力廠商登入', one3: '協力廠商登入',

View File

@@ -44,7 +44,7 @@ export async function initBackEndControlRoutes() {
if (!Session.get('token')) return false; if (!Session.get('token')) return false;
// 触发初始化用户信息 pinia // 触发初始化用户信息 pinia
// https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP // https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP
await useUserInfo().setUserInfos(); await useUserInfo().getApiUserInfo();
// 获取路由菜单数据 // 获取路由菜单数据
const res = await getBackEndControlRoutes(); const res = await getBackEndControlRoutes();
// 无登录权限时,添加判断 // 无登录权限时,添加判断

View File

@@ -28,6 +28,8 @@ import {checkVersion} from "/@/utils/upgrade";
const storesThemeConfig = useThemeConfig(pinia); const storesThemeConfig = useThemeConfig(pinia);
const {themeConfig} = storeToRefs(storesThemeConfig); const {themeConfig} = storeToRefs(storesThemeConfig);
const {isRequestRoutes} = themeConfig.value; const {isRequestRoutes} = themeConfig.value;
import {useUserInfo} from "/@/stores/userInfo";
const { userInfos } = storeToRefs(useUserInfo());
/** /**
* 创建一个可以被 Vue 应用程序使用的路由实例 * 创建一个可以被 Vue 应用程序使用的路由实例
@@ -111,7 +113,10 @@ router.beforeEach(async (to, from, next) => {
next(`/login?redirect=${to.path}&params=${JSON.stringify(to.query ? to.query : to.params)}`); next(`/login?redirect=${to.path}&params=${JSON.stringify(to.query ? to.query : to.params)}`);
Session.clear(); Session.clear();
NProgress.done(); 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'); next('/home');
NProgress.done(); NProgress.done();
}else if(token && frameOutRoutes.includes(to.path) ){ }else if(token && frameOutRoutes.includes(to.path) ){

View File

@@ -12,6 +12,7 @@ export interface UserInfosState {
email: string; email: string;
mobile: string; mobile: string;
gender: string; gender: string;
pwd_change_count:null|number;
dept_info: { dept_info: {
dept_id: number; dept_id: number;
dept_name: string; dept_name: string;

View File

@@ -15,6 +15,7 @@ export const useUserInfo = defineStore('userInfo', {
email: '', email: '',
mobile: '', mobile: '',
gender: '', gender: '',
pwd_change_count:null,
dept_info: { dept_info: {
dept_id: 0, dept_id: 0,
dept_name: '', dept_name: '',
@@ -29,16 +30,19 @@ export const useUserInfo = defineStore('userInfo', {
isSocketOpen: false isSocketOpen: false
}), }),
actions: { actions: {
async updateUserInfos() { async setPwdChangeCount(count: number) {
let userInfos: any = await this.getApiUserInfo(); this.userInfos.pwd_change_count = count;
this.userInfos.username = userInfos.data.name; },
this.userInfos.avatar = userInfos.data.avatar; async updateUserInfos(userInfos:any) {
this.userInfos.name = userInfos.data.name; this.userInfos.username = userInfos.name;
this.userInfos.email = userInfos.data.email; this.userInfos.avatar = userInfos.avatar;
this.userInfos.mobile = userInfos.data.mobile; this.userInfos.name = userInfos.name;
this.userInfos.gender = userInfos.data.gender; this.userInfos.email = userInfos.email;
this.userInfos.dept_info = userInfos.data.dept_info; this.userInfos.mobile = userInfos.mobile;
this.userInfos.role_info = userInfos.data.role_info; 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); Session.set('userInfo', this.userInfos);
}, },
async setUserInfos() { async setUserInfos() {
@@ -55,6 +59,7 @@ export const useUserInfo = defineStore('userInfo', {
this.userInfos.gender = userInfos.data.gender; this.userInfos.gender = userInfos.data.gender;
this.userInfos.dept_info = userInfos.data.dept_info; this.userInfos.dept_info = userInfos.data.dept_info;
this.userInfos.role_info = userInfos.data.role_info; this.userInfos.role_info = userInfos.data.role_info;
this.userInfos.pwd_change_count = userInfos.data.pwd_change_count;
Session.set('userInfo', this.userInfos); Session.set('userInfo', this.userInfos);
} }
}, },
@@ -65,7 +70,18 @@ export const useUserInfo = defineStore('userInfo', {
return request({ return request({
url: '/api/system/user/user_info/', url: '/api/system/user/user_info/',
method: 'get', 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);
})
}, },
}, },
}); });

View File

@@ -13,6 +13,15 @@ export function login(params: object) {
data: params data: params
}); });
} }
export function loginChangePwd(data: object) {
return request({
url: '/api/system/user/login_change_password/',
method: 'post',
data: data
});
}
export function getUserInfo() { export function getUserInfo() {
return request({ return request({
url: '/api/system/user/user_info/', url: '/api/system/user/user_info/',