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
032938a9
authored
Jan 17, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
优化无密码登录
parent
70569f70
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
app/Http/Requests/UserRegister.php
app/Http/Services/UserService.php
app/Http/Requests/UserRegister.php
View file @
032938a9
...
...
@@ -27,7 +27,7 @@ class UserRegister extends FormRequest
public
function
rules
()
{
return
[
'password'
=>
'required'
,
//
'password' => 'required',
//'salt' => 'required',
'mobile'
=>
'required_without:email'
,
'email'
=>
'required_without:mobile'
,
...
...
app/Http/Services/UserService.php
View file @
032938a9
...
...
@@ -19,7 +19,9 @@ class UserService
}
if
(
!
$ucId
)
{
if
(
!
empty
(
$data
[
'password'
]))
{
$data
[
'password'
]
=
PasswordService
::
passwordHash
(
$data
[
'password'
],
$data
[
'salt'
]);
}
//去新增注册
$data
[
'create_time'
]
=
time
();
$ucId
=
UserModel
::
insertGetId
(
$data
);
...
...
@@ -53,8 +55,10 @@ class UserService
}
$salt
=
$exists
->
salt
;
$passwordHash
=
''
;
if
(
$data
[
'password'
])
{
$passwordHash
=
PasswordService
::
passwordHash
(
$data
[
'password'
],
$salt
);
}
$user
=
$loginQuery
->
select
([
'uc_id'
,
'mobile'
,
...
...
@@ -84,7 +88,7 @@ class UserService
//绑定手机
public
static
function
bindMobile
(
$ucId
,
$mobile
)
{
//先去判断这个
email
是否已经被其它账号使用了
//先去判断这个
手机号
是否已经被其它账号使用了
$exists
=
UserModel
::
where
(
'uc_id'
,
'!='
,
$ucId
)
->
where
(
'mobile'
,
$mobile
)
->
exists
();
if
(
$exists
)
{
throw
new
InvalidRequestException
(
'该手机号已经被其它账户绑定了,请确认后重新提交'
);
...
...
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