Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-adminpanel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
laravel-adminpanel
Commits
bcfbaa1e
Commit
bcfbaa1e
authored
Dec 03, 2017
by
Viral Solani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add reset password api
parent
b1cf53d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
ResetPasswordController.php
app/Http/Controllers/Api/V1/ResetPasswordController.php
+82
-0
No files found.
app/Http/Controllers/Api/V1/ResetPasswordController.php
0 → 100644
View file @
bcfbaa1e
<?php
namespace
App\Http\Controllers\Api\V1
;
use
App\Repositories\Frontend\Access\User\UserRepository
;
use
Illuminate\Foundation\Auth\ResetsPasswords
;
use
Illuminate\Http\Request
;
/**
* Class ResetPasswordController.
*/
class
ResetPasswordController
extends
APIController
{
/**
* Reset Password
* @param ResetPasswordRequest
* @param JWTAuth
*
* @return \Illuminate\Http\JsonResponse
*/
public
function
resetPassword
(
ResetPasswordRequest
$request
,
JWTAuth
$JWTAuth
)
{
$response
=
$this
->
broker
()
->
reset
(
$this
->
credentials
(
$request
),
function
(
$user
,
$password
)
{
$this
->
reset
(
$user
,
$password
);
}
);
if
(
$response
!==
Password
::
PASSWORD_RESET
)
{
throw
new
HttpException
(
500
);
}
if
(
!
Config
::
get
(
'boilerplate.reset_password.release_token'
))
{
return
response
()
->
json
([
'status'
=>
'ok'
,
]);
}
$user
=
User
::
where
(
'email'
,
'='
,
$request
->
get
(
'email'
))
->
first
();
return
response
()
->
json
([
'status'
=>
'ok'
,
'token'
=>
$JWTAuth
->
fromUser
(
$user
)
]);
}
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public
function
broker
()
{
return
Password
::
broker
();
}
/**
* Get the password reset credentials from the request.
*
* @param ResetPasswordRequest $request
* @return array
*/
protected
function
credentials
(
ResetPasswordRequest
$request
)
{
return
$request
->
only
(
'email'
,
'password'
,
'password_confirmation'
,
'token'
);
}
/**
* Reset the given user's password.
*
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
* @param string $password
* @return void
*/
protected
function
reset
(
$user
,
$password
)
{
$user
->
password
=
$password
;
$user
->
save
();
}
}
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