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
76e0b3a5
Commit
76e0b3a5
authored
Nov 14, 2017
by
Viral Solani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Refactor User Activation
parent
fdd02f0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
12 deletions
+27
-12
AuthController.php
app/Http/Controllers/Api/V1/AuthController.php
+27
-12
No files found.
app/Http/Controllers/Api/V1/AuthController.php
View file @
76e0b3a5
...
...
@@ -48,15 +48,24 @@ class AuthController extends APIController
]);
}
/**
* Check if user is authenticated or not.
*
* @return \Illuminate\Http\JsonResponse
*/
public
function
check
()
{
try
{
JWTAuth
::
parseToken
()
->
authenticate
();
}
catch
(
JWTException
$e
)
{
return
response
([
'authenticated'
=>
false
]);
return
$this
->
respond
([
'authenticated'
=>
false
]);
}
return
response
([
'authenticated'
=>
true
]);
return
$this
->
respond
([
'authenticated'
=>
true
]);
}
/**
...
...
@@ -126,27 +135,33 @@ class AuthController extends APIController
]);
}
/**
* Activate User
*
* @param $activation_token [description]
*
* @return \Illuminate\Http\JsonResponse
*/
public
function
activate
(
$activation_token
)
{
$user
=
User
::
where
ActivationToken
(
$activation_token
)
->
first
();
$user
=
User
::
where
ConfirmationCode
(
$activation_token
)
->
first
();
if
(
!
$user
)
{
return
response
()
->
json
([
'message'
=>
'Invalid activation token!'
],
422
);
return
$this
->
throwValidation
(
'Invalid activation token!'
);
}
if
(
$user
->
status
==
'activated'
)
{
return
response
()
->
json
([
'message'
=>
'Your account has already been activated!'
],
422
);
if
(
$user
->
status
==
1
)
{
return
$this
->
throwValidation
(
'Your account has already been activated!'
);
}
if
(
$user
->
status
!=
'pending_activation'
)
{
return
response
()
->
json
([
'message'
=>
'Invalid activation token!'
],
422
);
}
$user
->
status
=
'activated'
;
$user
->
confirmed
=
1
;
$user
->
status
=
1
;
$user
->
save
();
$user
->
notify
(
new
Activated
(
$user
));
return
response
()
->
json
([
'message'
=>
'Your account has been activated!'
]);
return
$this
->
respond
([
'message'
=>
'Your account has been activated!'
]);
}
public
function
password
(
Request
$request
)
...
...
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