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
5619d8c8
authored
Jan 18, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改密码接口
parent
b74e4ca4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
1 deletions
app/Http/Controllers/Api/AuthController.php
app/Http/Controllers/Api/UserController.php
app/Http/Services/UserService.php
routes/api.php
app/Http/Controllers/Api/AuthController.php
View file @
5619d8c8
...
...
@@ -40,4 +40,22 @@ class AuthController extends Controller
return
$this
->
setSuccessData
([
'uc_id'
=>
$user
[
'uc_id'
],
'user'
=>
$user
]);
}
public
function
changePassword
(
Request
$request
)
{
$ucId
=
$request
->
input
(
'uc_id'
);
$password
=
$request
->
input
(
'password'
);
if
(
empty
(
$ucId
))
{
return
$this
->
setError
(
'uc_id不能为控'
);
}
if
(
empty
(
$password
))
{
return
$this
->
setError
(
'密码不能为空'
);
}
$result
=
UserService
::
changePassword
(
$ucId
,
$password
);
if
(
!
$result
)
{
return
$this
->
setError
(
'修改密码失败,请确认uc_id'
);
}
return
$this
->
setSuccess
(
'修改密码成功'
);
}
}
app/Http/Controllers/Api/UserController.php
View file @
5619d8c8
...
...
@@ -35,7 +35,7 @@ class UserController extends Controller
if
(
empty
(
$mobile
))
{
return
$this
->
setError
(
'mobile不能为空'
);
}
UserService
::
bind
Email
(
$ucId
,
$mobile
);
UserService
::
bind
Mobile
(
$ucId
,
$mobile
);
return
$this
->
setSuccess
(
'绑定成功'
);
}
...
...
app/Http/Services/UserService.php
View file @
5619d8c8
...
...
@@ -4,6 +4,7 @@ namespace App\Http\Services;
use
App\Exceptions\InvalidRequestException
;
use
App\Http\Models\UserModel
;
use
http\Client\Curl\User
;
class
UserService
{
...
...
@@ -99,4 +100,14 @@ class UserService
'update_time'
=>
time
(),
]);
}
//修改密码
public
static
function
changePassword
(
$ucId
,
$password
)
{
return
UserModel
::
where
(
'uc_id'
,
$ucId
)
->
update
([
'password'
=>
$password
,
'update_time'
=>
time
(),
]);
}
}
routes/api.php
View file @
5619d8c8
...
...
@@ -6,6 +6,8 @@ use Illuminate\Support\Facades\Route;
Route
::
namespace
(
'Api'
)
->
group
(
function
()
{
Route
::
match
([
"GET"
,
"POST"
],
'/auth/register'
,
'AuthController@register'
);
Route
::
match
([
"GET"
,
"POST"
],
'/auth/login'
,
'AuthController@login'
);
Route
::
match
([
"GET"
,
"POST"
],
'/auth/changePassword'
,
'AuthController@changePassword'
);
Route
::
match
([
"GET"
,
"POST"
],
'/user/bindEmail'
,
'UserController@bindEmail'
);
Route
::
match
([
"GET"
,
"POST"
],
'/user/bindMobile'
,
'UserController@bindMobile'
);
});
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