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
a9388bc9
Commit
a9388bc9
authored
Nov 30, 2017
by
Viral Solani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forgot Password API
parent
ae08355c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
+24
-5
AuthController.php
app/Http/Controllers/Api/V1/AuthController.php
+1
-1
ForgotPasswordController.php
app/Http/Controllers/Api/V1/ForgotPasswordController.php
+5
-4
UserRepository.php
app/Repositories/Frontend/Access/User/UserRepository.php
+18
-0
No files found.
app/Http/Controllers/Api/V1/AuthController.php
View file @
a9388bc9
...
...
@@ -39,7 +39,7 @@ class AuthController extends APIController
return
$this
->
respond
([
'message'
=>
trans
(
'api.messages.login.success'
),
'token'
=>
$token
,
'token'
=>
$token
]);
}
...
...
app/Http/Controllers/Api/V1/ForgotPasswordController.php
View file @
a9388bc9
...
...
@@ -2,11 +2,12 @@
namespace
App\Http\Controllers\Api\V1
;
use
Validator
;
use
App\Models\User\User
;
use
App\Notifications\UserNeedsPasswordReset
;
use
App\Repositories\UserRepository
;
use
Illuminate\Http\Request
;
use
Validator
;
use
App\Repositories\Frontend\Access\User\UserRepository
;
use
App\Notifications\Frontend\Auth\UserNeedsPasswordReset
;
class
ForgotPasswordController
extends
APIController
{
...
...
@@ -37,7 +38,7 @@ class ForgotPasswordController extends APIController
return
$this
->
throwValidation
(
$validation
->
messages
()
->
first
());
}
$user
=
$this
->
repository
->
getUserByEmail
(
$request
);
$user
=
$this
->
repository
->
findByEmail
(
$request
->
get
(
'email'
)
);
if
(
!
$user
)
{
return
$this
->
respondNotFound
(
trans
(
'api.messages.forgot_password.validation.email_not_found'
));
...
...
app/Repositories/Frontend/Access/User/UserRepository.php
View file @
a9388bc9
...
...
@@ -5,6 +5,7 @@ namespace App\Repositories\Frontend\Access\User;
use
App\Events\Frontend\Auth\UserConfirmed
;
use
App\Exceptions\GeneralException
;
use
App\Models\Access\User\SocialLogin
;
use
Illuminate\Support\Str
;
use
App\Models\Access\User\User
;
use
App\Notifications\Frontend\Auth\UserNeedsConfirmation
;
use
App\Repositories\Backend\Access\Role\RoleRepository
;
...
...
@@ -286,4 +287,21 @@ class UserRepository extends BaseRepository
throw
new
GeneralException
(
trans
(
'exceptions.frontend.auth.password.change_mismatch'
));
}
/**
* Create a new token for the user.
*
* @return string
*/
public
function
createNewToken
()
{
$token
=
hash_hmac
(
'sha256'
,
Str
::
random
(
40
),
'hashKey'
);
\DB
::
table
(
'password_resets'
)
->
insert
([
'email'
=>
request
(
'email'
),
'token'
=>
$token
,
]);
return
$token
;
}
}
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