File tree Expand file tree Collapse file tree 4 files changed +31
-14
lines changed Expand file tree Collapse file tree 4 files changed +31
-14
lines changed Original file line number Diff line number Diff line change 1
1
import axios from 'axios' ;
2
+ import { encodePassword } from '@/utils/security' ;
2
3
3
4
export interface LoginRequest {
4
5
userName ?: string ;
@@ -22,10 +23,14 @@ export interface ExchangeReply {
22
23
refreshToken : string ;
23
24
}
24
25
25
- export function login ( request : LoginRequest ) {
26
+ export async function login ( request : LoginRequest ) {
27
+ const requestLogin = {
28
+ ...request ,
29
+ password : await encodePassword ( request . password ) ,
30
+ } ;
26
31
return axios . post < LoginReply > (
27
32
'/api/v1/admin/auth/access/actions/basic-login' ,
28
- request ,
33
+ requestLogin ,
29
34
) ;
30
35
}
31
36
Original file line number Diff line number Diff line change 7
7
:style =" { margin: 0, fontSize: '18px' }"
8
8
:heading =" 5"
9
9
>
10
- PowerX Dashboard
10
+ PowerX Dashboard - {{ PowerXVersion }}
11
11
</a-typography-title >
12
12
<icon-menu-fold
13
13
v-if =" !topMenu && appStore.device === 'mobile'"
Original file line number Diff line number Diff line change 1
1
import { defineStore } from 'pinia' ;
2
2
import { Notification } from '@arco-design/web-vue' ;
3
- import type { NotificationReturn } from '@arco-design/web-vue/es/notification/interface' ;
3
+
4
4
import type { RouteRecordNormalized } from 'vue-router' ;
5
5
import defaultSettings from '@/config/settings.json' ;
6
6
import { getMenuList } from '@/api/userinfo' ;
7
7
import { AppState } from './types' ;
8
8
9
- const sessionPrefix = 'app' ;
10
-
11
- function formatSessionKey ( key : string ) {
12
- return `${ sessionPrefix } :${ key } ` ;
13
- }
14
-
15
9
const useAppStore = defineStore ( 'app' , {
16
10
state : ( ) : AppState => ( { ...defaultSettings } ) ,
17
11
@@ -54,22 +48,21 @@ const useAppStore = defineStore('app', {
54
48
} ,
55
49
// 获取服务器菜单配置
56
50
async fetchServerMenuConfig ( ) {
57
- let notifyInstance : NotificationReturn | null = null ;
58
51
try {
59
- notifyInstance = Notification . info ( {
52
+ Notification . info ( {
60
53
id : 'menuNotice' ,
61
54
content : '加载中' ,
62
55
closable : true ,
63
56
} ) ;
64
57
const { data } = await getMenuList ( ) ;
65
58
this . serverMenu = data ;
66
- notifyInstance = Notification . success ( {
59
+ Notification . success ( {
67
60
id : 'menuNotice' ,
68
61
content : '成功' ,
69
62
closable : true ,
70
63
} ) ;
71
64
} catch ( error ) {
72
- notifyInstance = Notification . error ( {
65
+ Notification . error ( {
73
66
id : 'menuNotice' ,
74
67
content : '错误' ,
75
68
closable : true ,
Original file line number Diff line number Diff line change
1
+ export const encodePassword = async ( data : string ) : Promise < string > => {
2
+ const encoder = new TextEncoder ( ) ;
3
+ const dataBuffer = encoder . encode ( data ) ;
4
+ const hashBuffer = await crypto . subtle . digest ( 'SHA-256' , dataBuffer ) ;
5
+ const hashArray = Array . from ( new Uint8Array ( hashBuffer ) ) ;
6
+ const hashHex = hashArray
7
+ . map ( ( b ) => b . toString ( 16 ) . padStart ( 2 , '0' ) )
8
+ . join ( '' ) ;
9
+ return hashHex ;
10
+ } ;
11
+
12
+ // 验证密码函数
13
+ export const verifyPassword = async (
14
+ plainPassword : string ,
15
+ hashedPassword : string ,
16
+ ) : Promise < boolean > => {
17
+ const encryptedPassword = await encodePassword ( plainPassword ) ;
18
+ return encryptedPassword === hashedPassword ;
19
+ } ;
You can’t perform that action at this time.
0 commit comments