Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
fhjw-vue
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mengmeng
fhjw-vue
Commits
87bd4d12
Commit
87bd4d12
authored
Nov 23, 2021
by
mengmeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加加密传输
parent
ef503eaa
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
41 deletions
+44
-41
main-navbar-update-password.vue
src/views/main-navbar-update-password.vue
+19
-36
login.vue
src/views/pages/login.vue
+25
-5
No files found.
src/views/main-navbar-update-password.vue
View file @
87bd4d12
...
...
@@ -72,52 +72,35 @@ export default {
};
},
computed
:
{
dataRule
()
{
var
validateConfirmPassword
=
(
rule
,
value
,
callback
)
=>
{
if
(
this
.
dataForm
.
newPassword
!==
value
)
{
return
callback
(
new
Error
(
this
.
$t
(
"updatePassword.validate.confirmPassword"
))
);
}
callback
();
};
dataRule
()
{
var
validateNewPass
=
(
rule
,
value
,
callback
)
=>
{
const
reg
=
/
(?=
.*
[
0-9
])(?=
.*
[
A-Z
])(?=
.*
[
a-z
])(?=
.*
[\W])(?=
.*
[\S])
^
[
0-9A-Za-z
\S]{8,18}
$/g
;
const
reg
=
/
(?=
.*
[
0-9
])(?=
.*
[
A-Z
])(?=
.*
[
a-z
])(?=
.*
[\W])(?=
.*
[\S])
^
[
0-9A-Za-z
\S]{8,18}
$/g
if
(
!
reg
.
test
(
value
))
{
callback
(
new
Error
(
"密码
应该为8-18位大小字母、数字、特殊字符组合"
));
callback
(
new
Error
(
"密码
必须由8-18位大小字母、数字、特殊字符组合"
))
}
else
{
callback
();
callback
()
}
}
var
validateConfirmPassword
=
(
rule
,
value
,
callback
)
=>
{
if
(
this
.
dataForm
.
newPassword
!==
value
)
{
return
callback
(
new
Error
(
this
.
$t
(
'updatePassword.validate.confirmPassword'
)))
}
callback
()
}
};
return
{
password
:
[
{
required
:
true
,
message
:
this
.
$t
(
"validate.required"
),
trigger
:
"blur"
,
},
{
required
:
true
,
message
:
this
.
$t
(
'validate.required'
),
trigger
:
'blur'
}
],
newPassword
:
[
{
required
:
true
,
message
:
this
.
$t
(
"validate.required"
),
trigger
:
"blur"
,
},
{
validator
:
validateNewPass
,
trigger
:
"blur"
},
{
required
:
true
,
message
:
this
.
$t
(
'validate.required'
),
trigger
:
'blur'
},
{
validator
:
validateNewPass
,
trigger
:
'blur'
}
],
confirmPassword
:
[
{
required
:
true
,
message
:
this
.
$t
(
"validate.required"
),
trigger
:
"blur"
,
},
{
validator
:
validateConfirmPassword
,
trigger
:
"blur"
},
],
};
},
{
required
:
true
,
message
:
this
.
$t
(
'validate.required'
),
trigger
:
'blur'
},
{
validator
:
validateConfirmPassword
,
trigger
:
'blur'
}
]
}
}
},
methods
:
{
init
()
{
...
...
src/views/pages/login.vue
View file @
87bd4d12
...
...
@@ -132,6 +132,7 @@ import Cookies from "js-cookie";
import
debounce
from
"lodash/debounce"
;
import
{
messages
}
from
"@/i18n"
;
import
{
getUUID
}
from
"@/utils"
;
import
crypto
from
'@/utils/crypto'
;
export
default
{
data
()
{
return
{
...
...
@@ -174,8 +175,18 @@ export default {
},
created
()
{
this
.
getCaptcha
();
this
.
getCryptoKey
();
},
methods
:
{
// 获取加密密钥
getCryptoKey
()
{
this
.
$http
.
get
(
'/getCryptoKey'
).
then
(({
data
:
res
})
=>
{
if
(
res
.
code
!==
0
)
{
return
this
.
$message
.
error
(
res
.
msg
)
}
this
.
dataForm
.
cryptoKey
=
res
.
data
}).
catch
(()
=>
{})
},
// 获取验证码
getCaptcha
()
{
this
.
dataForm
.
uuid
=
getUUID
();
...
...
@@ -188,11 +199,20 @@ export default {
if
(
!
valid
)
{
return
false
;
}
let
Base64
=
require
(
"js-base64"
).
Base64
;
//
let Base64 = require("js-base64").Base64;
// this.dataForm.password = this.$md5(this.dataForm.password);
this
.
dataForm
.
password
=
Base64
.
encode
(
this
.
dataForm
.
password
);
// this.dataForm.password = Base64.encode(this.dataForm.password);
// 对数据进行加密传输
let
key
=
crypto
.
decrypt
(
this
.
dataForm
.
cryptoKey
)
let
dataForm2
=
{
username
:
crypto
.
encrypt
(
this
.
dataForm
.
username
,
key
),
password
:
crypto
.
encrypt
(
this
.
dataForm
.
password
,
key
),
cryptoKey
:
this
.
dataForm
.
cryptoKey
,
uuid
:
this
.
dataForm
.
uuid
,
captcha
:
this
.
dataForm
.
captcha
}
this
.
$http
.
post
(
"/login"
,
this
.
dataForm
)
.
post
(
'/login'
,
{
...
dataForm2
}
)
.
then
(({
data
:
res
})
=>
{
if
(
res
.
code
!==
0
)
{
this
.
getCaptcha
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment