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
243d2906
Commit
243d2906
authored
Dec 04, 2017
by
Viral Solani
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://github.com/viralsolani/laravel-adminpanel
into develop
parents
f39415e0
36716b68
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
117 deletions
+2
-117
ForgotPasswordController.php
app/Http/Controllers/Api/V1/ForgotPasswordController.php
+1
-1
ResetPasswordController.php
app/Http/Controllers/Api/V1/ResetPasswordController.php
+0
-115
UserRepository.php
app/Repositories/Frontend/Access/User/UserRepository.php
+1
-1
No files found.
app/Http/Controllers/Api/V1/ForgotPasswordController.php
View file @
243d2906
...
...
@@ -43,7 +43,7 @@ class ForgotPasswordController extends APIController
return
$this
->
respondNotFound
(
trans
(
'api.messages.forgot_password.validation.email_not_found'
));
}
$token
=
$this
->
repository
->
createNew
Token
();
$token
=
$this
->
repository
->
save
Token
();
$user
->
notify
(
new
UserNeedsPasswordReset
(
$token
));
...
...
app/Http/Controllers/Api/V1/ResetPasswordController.php
deleted
100644 → 0
View file @
f39415e0
<?php
namespace
App\Http\Controllers\Api\V1
;
use
App\Repositories\Frontend\Access\User\UserRepository
;
use
Tymon\JWTAuth\JWTAuth
;
use
Illuminate\Support\Facades\Password
;
use
Illuminate\Foundation\Auth\ResetsPasswords
;
use
Illuminate\Http\Request
;
use
Validator
;
/**
* Class ResetPasswordController.
*/
class
ResetPasswordController
extends
APIController
{
/**
* User Repository
* @var obj
*/
protected
$user
;
/**
* Rest Password Constructor
*
* @param UserRepository $user
*/
public
function
__construct
(
UserRepository
$user
)
{
$this
->
user
=
$user
;
}
/**
* Reset Password
* @param Request
* @param JWTAuth
*
* @return \Illuminate\Http\JsonResponse
*/
public
function
reset
(
Request
$request
,
JWTAuth
$JWTAuth
)
{
$validation
=
Validator
::
make
(
$request
->
all
(),
[
'token'
=>
'required'
,
'email'
=>
'required|email'
,
'password'
=>
'required|min:4|confirmed|regex:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$"'
,
]);
if
(
$validation
->
fails
())
{
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
dd
(
'viral'
);
$response
=
$this
->
broker
()
->
reset
(
$this
->
credentials
(
$request
),
function
(
$user
,
$password
)
{
$this
->
resetPassword
(
$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 $request
* @return array
*/
protected
function
credentials
(
$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
resetPassword
(
$user
,
$password
)
{
$user
->
password
=
$password
;
$user
->
save
();
}
}
app/Repositories/Frontend/Access/User/UserRepository.php
View file @
243d2906
...
...
@@ -293,7 +293,7 @@ class UserRepository extends BaseRepository
*
* @return string
*/
public
function
createNew
Token
()
public
function
save
Token
()
{
$token
=
hash_hmac
(
'sha256'
,
Str
::
random
(
40
),
'hashKey'
);
...
...
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