Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
ucenter
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
70569f70
authored
Jan 17, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修复盐的问题
parent
7220ba08
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
app/Http/Services/UserService.php
app/Http/Services/UserService.php
View file @
70569f70
...
...
@@ -19,6 +19,7 @@ class UserService
}
if
(
!
$ucId
)
{
$data
[
'password'
]
=
PasswordService
::
passwordHash
(
$data
[
'password'
],
$data
[
'salt'
]);
//去新增注册
$data
[
'create_time'
]
=
time
();
$ucId
=
UserModel
::
insertGetId
(
$data
);
...
...
@@ -41,15 +42,18 @@ class UserService
{
$loginQuery
=
UserModel
::
where
(
'status'
,
UserModel
::
STATUS_ENABLE
);
if
(
!
empty
(
$data
[
'mobile'
]))
{
$
salt
=
UserModel
::
where
(
'mobile'
,
$data
[
'mobile'
])
->
value
(
'salt'
);
$
exists
=
UserModel
::
where
(
'mobile'
,
$data
[
'mobile'
])
->
first
(
);
$loginQuery
->
where
(
'mobile'
,
$data
[
'mobile'
]);
}
else
{
$
salt
=
UserModel
::
where
(
'email'
,
$data
[
'email'
])
->
value
(
'salt'
);
$
exists
=
UserModel
::
where
(
'email'
,
$data
[
'email'
])
->
first
(
);
$loginQuery
->
where
(
'email'
,
$data
[
'email'
]);
}
if
(
empty
(
$
salt
))
{
if
(
empty
(
$
exists
))
{
throw
new
InvalidRequestException
(
'该账号不存在'
);
}
$salt
=
$exists
->
salt
;
$passwordHash
=
PasswordService
::
passwordHash
(
$data
[
'password'
],
$salt
);
$user
=
$loginQuery
->
select
([
'uc_id'
,
...
...
@@ -57,10 +61,9 @@ class UserService
'email'
,
'create_time'
,
])
->
where
(
'password'
,
$passwordHash
)
->
first
();
UserModel
::
where
(
'uc_id'
,
$user
[
'uc_id'
])
->
update
([
'last_login_time'
=>
time
()]);
return
$user
?:
[];
return
$user
?
$user
->
toArray
()
:
[];
}
//绑定邮箱
...
...
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