mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-27 16:34:05 +00:00
updated jwt
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use App\User;
|
||||
use JWTAuth;
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
use Validator, DB, Hash, Mail, Illuminate\Support\Facades\Password;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* API Register
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
$credentials = $request->only('name', 'email', 'password');
|
||||
$rules = [
|
||||
'name' => 'required|min:4',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|min:6',
|
||||
];
|
||||
$validator = Validator::make($credentials, $rules);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['success'=> false, 'error'=> $validator->messages()]);
|
||||
}
|
||||
$name = $request->name;
|
||||
$email = $request->email;
|
||||
$password = $request->password;
|
||||
User::create(['name' => $name, 'email' => $email, 'password' => Hash::make($password)]);
|
||||
return $this->login($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* API Login, on success return JWT Auth token
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$credentials = $request->only('email', 'password');
|
||||
$rules = [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required',
|
||||
];
|
||||
$validator = Validator::make($credentials, $rules);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['success'=> false, 'error'=> $validator->messages()]);
|
||||
}
|
||||
try {
|
||||
// attempt to verify the credentials and create a token for the user
|
||||
if (!$token = JWTAuth::attempt($credentials)) {
|
||||
return response()->json(['success' => false, 'error' => 'We cant find an account with this credentials.'], 401);
|
||||
}
|
||||
} catch (JWTException $e) {
|
||||
// something went wrong whilst attempting to encode the token
|
||||
return response()->json(['success' => false, 'error' => 'Failed to login, please try again.'], 500);
|
||||
}
|
||||
// all good so return the token
|
||||
return response()->json(['success' => true, 'data'=> [ 'token' => $token ]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out
|
||||
* Invalidate the token, so user cannot use it anymore
|
||||
* They have to relogin to get a new token
|
||||
*
|
||||
* @param Request $request
|
||||
*/
|
||||
public function logout(Request $request) {
|
||||
$this->validate($request, ['token' => 'required']);
|
||||
try {
|
||||
JWTAuth::invalidate($request->input('token'));
|
||||
return response()->json(['success' => true, 'message'=> "You have successfully logged out."]);
|
||||
} catch (JWTException $e) {
|
||||
// something went wrong whilst attempting to encode the token
|
||||
return response()->json(['success' => false, 'error' => 'Failed to logout, please try again.'], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API Recover Password
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function recover(Request $request)
|
||||
{
|
||||
$user = User::where('email', $request->email)->first();
|
||||
if (!$user) {
|
||||
$error_message = "Your email address was not found.";
|
||||
return response()->json(['success' => false, 'error' => ['email'=> $error_message]], 401);
|
||||
}
|
||||
try {
|
||||
Password::sendResetLink($request->only('email'), function (Message $message) {
|
||||
$message->subject('Your Password Reset Link');
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
//Return with error
|
||||
$error_message = $e->getMessage();
|
||||
return response()->json(['success' => false, 'error' => $error_message], 401);
|
||||
}
|
||||
return response()->json([
|
||||
'success' => true, 'data'=> ['message'=> 'A reset email has been sent! Please check your email.']
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
+23
-2
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
||||
class User extends Authenticatable
|
||||
class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
@@ -15,7 +16,7 @@ class User extends Authenticatable
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -26,4 +27,24 @@ class User extends Authenticatable
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the identifier that will be stored in the subject claim of the JWT.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getJWTIdentifier()
|
||||
{
|
||||
return $this->getKey();
|
||||
}
|
||||
/**
|
||||
* Return a key value array, containing any custom claims to be added to the JWT.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getJWTCustomClaims()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -8,7 +8,8 @@
|
||||
"php": "^7.1.3",
|
||||
"fideloper/proxy": "^4.0",
|
||||
"laravel/framework": "5.6.*",
|
||||
"laravel/tinker": "^1.0"
|
||||
"laravel/tinker": "^1.0",
|
||||
"tymon/jwt-auth": "dev-develop"
|
||||
},
|
||||
"require-dev": {
|
||||
"filp/whoops": "^2.0",
|
||||
|
||||
Generated
+361
-55
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "d5bca48e56bbf3a25645858fcab9c285",
|
||||
"content-hash": "f2d9e6ec1c09918f1f3130aa31e04472",
|
||||
"packages": [
|
||||
{
|
||||
"name": "dnoegel/php-xdg-base-dir",
|
||||
@@ -455,16 +455,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v5.6.16",
|
||||
"version": "v5.6.17",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "fcdbc791bc3e113ada38ab0a1147141fb9ec2b16"
|
||||
"reference": "0f787c763ae8fb9fae0c8c809830ba4fa81e2d9d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/fcdbc791bc3e113ada38ab0a1147141fb9ec2b16",
|
||||
"reference": "fcdbc791bc3e113ada38ab0a1147141fb9ec2b16",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/0f787c763ae8fb9fae0c8c809830ba4fa81e2d9d",
|
||||
"reference": "0f787c763ae8fb9fae0c8c809830ba4fa81e2d9d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -475,7 +475,7 @@
|
||||
"ext-openssl": "*",
|
||||
"league/flysystem": "^1.0.8",
|
||||
"monolog/monolog": "~1.12",
|
||||
"nesbot/carbon": "^1.24.1",
|
||||
"nesbot/carbon": "1.25.*",
|
||||
"php": "^7.1.3",
|
||||
"psr/container": "~1.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
@@ -590,20 +590,20 @@
|
||||
"framework",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2018-04-09T16:07:04+00:00"
|
||||
"time": "2018-04-17T12:51:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/tinker",
|
||||
"version": "v1.0.5",
|
||||
"version": "v1.0.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/tinker.git",
|
||||
"reference": "94f6daf2131508cebd11cd6f8632ba586d7ecc41"
|
||||
"reference": "b22fe905fcefdffae76b011e27c7ac09e07e052b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/tinker/zipball/94f6daf2131508cebd11cd6f8632ba586d7ecc41",
|
||||
"reference": "94f6daf2131508cebd11cd6f8632ba586d7ecc41",
|
||||
"url": "https://api.github.com/repos/laravel/tinker/zipball/b22fe905fcefdffae76b011e27c7ac09e07e052b",
|
||||
"reference": "b22fe905fcefdffae76b011e27c7ac09e07e052b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -611,7 +611,7 @@
|
||||
"illuminate/contracts": "~5.1",
|
||||
"illuminate/support": "~5.1",
|
||||
"php": ">=5.5.9",
|
||||
"psy/psysh": "0.7.*|0.8.*",
|
||||
"psy/psysh": "0.7.*|0.8.*|0.9.*",
|
||||
"symfony/var-dumper": "~3.0|~4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
@@ -653,7 +653,65 @@
|
||||
"laravel",
|
||||
"psysh"
|
||||
],
|
||||
"time": "2018-03-06T17:34:36+00:00"
|
||||
"time": "2018-04-16T12:10:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "lcobucci/jwt",
|
||||
"version": "3.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lcobucci/jwt.git",
|
||||
"reference": "0b5930be73582369e10c4d4bb7a12bac927a203c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/lcobucci/jwt/zipball/0b5930be73582369e10c4d4bb7a12bac927a203c",
|
||||
"reference": "0b5930be73582369e10c4d4bb7a12bac927a203c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-openssl": "*",
|
||||
"php": ">=5.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"mdanter/ecc": "~0.3.1",
|
||||
"mikey179/vfsstream": "~1.5",
|
||||
"phpmd/phpmd": "~2.2",
|
||||
"phpunit/php-invoker": "~1.1",
|
||||
"phpunit/phpunit": "~4.5",
|
||||
"squizlabs/php_codesniffer": "~2.3"
|
||||
},
|
||||
"suggest": {
|
||||
"mdanter/ecc": "Required to use Elliptic Curves based algorithms."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Lcobucci\\JWT\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Luís Otávio Cobucci Oblonczyk",
|
||||
"email": "lcobucci@gmail.com",
|
||||
"role": "developer"
|
||||
}
|
||||
],
|
||||
"description": "A simple library to work with JSON Web Token and JSON Web Signature",
|
||||
"keywords": [
|
||||
"JWS",
|
||||
"jwt"
|
||||
],
|
||||
"time": "2017-09-01T08:23:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
@@ -817,6 +875,69 @@
|
||||
],
|
||||
"time": "2017-06-19T01:22:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "namshi/jose",
|
||||
"version": "7.2.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/namshi/jose.git",
|
||||
"reference": "89a24d7eb3040e285dd5925fcad992378b82bcff"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/namshi/jose/zipball/89a24d7eb3040e285dd5925fcad992378b82bcff",
|
||||
"reference": "89a24d7eb3040e285dd5925fcad992378b82bcff",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-date": "*",
|
||||
"ext-hash": "*",
|
||||
"ext-json": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-spl": "*",
|
||||
"php": ">=5.5",
|
||||
"symfony/polyfill-php56": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpseclib/phpseclib": "^2.0",
|
||||
"phpunit/phpunit": "^4.5|^5.0",
|
||||
"satooshi/php-coveralls": "^1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-openssl": "Allows to use OpenSSL as crypto engine.",
|
||||
"phpseclib/phpseclib": "Allows to use Phpseclib as crypto engine, use version ^2.0."
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Namshi\\JOSE\\": "src/Namshi/JOSE/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alessandro Nadalin",
|
||||
"email": "alessandro.nadalin@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Alessandro Cinelli (cirpo)",
|
||||
"email": "alessandro.cinelli@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "JSON Object Signing and Encryption library for PHP.",
|
||||
"keywords": [
|
||||
"JSON Web Signature",
|
||||
"JSON Web Token",
|
||||
"JWS",
|
||||
"json",
|
||||
"jwt",
|
||||
"token"
|
||||
],
|
||||
"time": "2016-12-05T07:27:31+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nesbot/carbon",
|
||||
"version": "1.25.0",
|
||||
@@ -872,24 +993,24 @@
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v3.1.5",
|
||||
"version": "v4.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||
"reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce"
|
||||
"reference": "e4a54fa90a5cd8e8dd3fb4099942681731c5cdd3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bb87e28e7d7b8d9a7fda231d37457c9210faf6ce",
|
||||
"reference": "bb87e28e7d7b8d9a7fda231d37457c9210faf6ce",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/e4a54fa90a5cd8e8dd3fb4099942681731c5cdd3",
|
||||
"reference": "e4a54fa90a5cd8e8dd3fb4099942681731c5cdd3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=5.5"
|
||||
"php": ">=7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0|~5.0"
|
||||
"phpunit/phpunit": "^6.5 || ^7.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/php-parse"
|
||||
@@ -897,7 +1018,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
"dev-master": "4.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -919,7 +1040,7 @@
|
||||
"parser",
|
||||
"php"
|
||||
],
|
||||
"time": "2018-02-28T20:30:58+00:00"
|
||||
"time": "2018-03-25T17:35:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/random_compat",
|
||||
@@ -1115,29 +1236,29 @@
|
||||
},
|
||||
{
|
||||
"name": "psy/psysh",
|
||||
"version": "v0.8.18",
|
||||
"version": "v0.9.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bobthecow/psysh.git",
|
||||
"reference": "5357b1cffc8fb375d6a9e3c86d5c82dd38a40834"
|
||||
"reference": "79c280013cf0b30fa23f3ba8bd3649218075adf4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/5357b1cffc8fb375d6a9e3c86d5c82dd38a40834",
|
||||
"reference": "5357b1cffc8fb375d6a9e3c86d5c82dd38a40834",
|
||||
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/79c280013cf0b30fa23f3ba8bd3649218075adf4",
|
||||
"reference": "79c280013cf0b30fa23f3ba8bd3649218075adf4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"dnoegel/php-xdg-base-dir": "0.1",
|
||||
"jakub-onderka/php-console-highlighter": "0.3.*",
|
||||
"nikic/php-parser": "~1.3|~2.0|~3.0",
|
||||
"php": ">=5.3.9",
|
||||
"nikic/php-parser": "~1.3|~2.0|~3.0|~4.0",
|
||||
"php": ">=5.4.0",
|
||||
"symfony/console": "~2.3.10|^2.4.2|~3.0|~4.0",
|
||||
"symfony/var-dumper": "~2.7|~3.0|~4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"hoa/console": "~3.16|~1.14",
|
||||
"phpunit/phpunit": "^4.8.35|^5.4.3",
|
||||
"hoa/console": "~2.15|~3.16",
|
||||
"phpunit/phpunit": "~4.8.35|~5.0|~6.0|~7.0",
|
||||
"symfony/finder": "~2.1|~3.0|~4.0"
|
||||
},
|
||||
"suggest": {
|
||||
@@ -1153,15 +1274,15 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-develop": "0.8.x-dev"
|
||||
"dev-develop": "0.9.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Psy/functions.php"
|
||||
"src/functions.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Psy\\": "src/Psy/"
|
||||
"Psy\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
@@ -1183,7 +1304,7 @@
|
||||
"interactive",
|
||||
"shell"
|
||||
],
|
||||
"time": "2018-04-02T05:41:44+00:00"
|
||||
"time": "2018-04-18T12:32:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
@@ -1807,6 +1928,62 @@
|
||||
],
|
||||
"time": "2018-01-30T19:27:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php56",
|
||||
"version": "v1.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php56.git",
|
||||
"reference": "ebc999ce5f14204c5150b9bd15f8f04e621409d8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ebc999ce5f14204c5150b9bd15f8f04e621409d8",
|
||||
"reference": "ebc999ce5f14204c5150b9bd15f8f04e621409d8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"symfony/polyfill-util": "~1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php56\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2018-01-30T19:27:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php72",
|
||||
"version": "v1.7.0",
|
||||
@@ -1862,6 +2039,58 @@
|
||||
],
|
||||
"time": "2018-01-31T17:43:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-util",
|
||||
"version": "v1.7.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-util.git",
|
||||
"reference": "e17c808ec4228026d4f5a8832afa19be85979563"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-util/zipball/e17c808ec4228026d4f5a8832afa19be85979563",
|
||||
"reference": "e17c808ec4228026d4f5a8832afa19be85979563",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.7-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Util\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony utilities for portability of PHP codes",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compat",
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"shim"
|
||||
],
|
||||
"time": "2018-01-31T18:08:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v4.0.8",
|
||||
@@ -2173,6 +2402,81 @@
|
||||
"homepage": "https://github.com/tijsverkoyen/CssToInlineStyles",
|
||||
"time": "2017-11-27T11:13:29+00:00"
|
||||
},
|
||||
{
|
||||
"name": "tymon/jwt-auth",
|
||||
"version": "dev-develop",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tymondesigns/jwt-auth.git",
|
||||
"reference": "2b79229235d83523a05069ccb9c97cd5ec0b8123"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/2b79229235d83523a05069ccb9c97cd5ec0b8123",
|
||||
"reference": "2b79229235d83523a05069ccb9c97cd5ec0b8123",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/auth": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
|
||||
"illuminate/contracts": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
|
||||
"illuminate/http": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
|
||||
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
|
||||
"lcobucci/jwt": "^3.2",
|
||||
"namshi/jose": "^7.0",
|
||||
"nesbot/carbon": "^1.0",
|
||||
"php": "^5.5.9 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"cartalyst/sentinel": "2.0.*",
|
||||
"illuminate/console": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
|
||||
"illuminate/database": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
|
||||
"illuminate/routing": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*",
|
||||
"mockery/mockery": ">=0.9.9",
|
||||
"phpunit/phpunit": "~4.8 || ~6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-develop": "1.0-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"aliases": {
|
||||
"JWTAuth": "Tymon\\JWTAuth\\Facades\\JWTAuth",
|
||||
"JWTFactory": "Tymon\\JWTAuth\\Facades\\JWTFactory"
|
||||
},
|
||||
"providers": [
|
||||
"Tymon\\JWTAuth\\Providers\\LaravelServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Tymon\\JWTAuth\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sean Tymon",
|
||||
"email": "tymon148@gmail.com",
|
||||
"homepage": "https://tymon.xyz",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "JSON Web Token Authentication for Laravel and Lumen",
|
||||
"homepage": "https://github.com/tymondesigns/jwt-auth",
|
||||
"keywords": [
|
||||
"Authentication",
|
||||
"JSON Web Token",
|
||||
"auth",
|
||||
"jwt",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2018-03-10T22:14:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "vlucas/phpdotenv",
|
||||
"version": "v2.4.0",
|
||||
@@ -2866,23 +3170,23 @@
|
||||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
"version": "1.7.5",
|
||||
"version": "1.7.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/prophecy.git",
|
||||
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401"
|
||||
"reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401",
|
||||
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/33a7e3c4fda54e912ff6338c48823bd5c0f0b712",
|
||||
"reference": "33a7e3c4fda54e912ff6338c48823bd5c0f0b712",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"doctrine/instantiator": "^1.0.2",
|
||||
"php": "^5.3|^7.0",
|
||||
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0",
|
||||
"sebastian/comparator": "^1.1|^2.0",
|
||||
"sebastian/comparator": "^1.1|^2.0|^3.0",
|
||||
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
@@ -2925,7 +3229,7 @@
|
||||
"spy",
|
||||
"stub"
|
||||
],
|
||||
"time": "2018-02-19T10:16:54+00:00"
|
||||
"time": "2018-04-18T13:57:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
@@ -3178,16 +3482,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "7.1.3",
|
||||
"version": "7.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9"
|
||||
"reference": "6d51299e307dc510149e0b7cd1931dd11770e1cb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9",
|
||||
"reference": "a7834993ddbf4b0ed2c3b2dc1f3b1d093ef910a9",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6d51299e307dc510149e0b7cd1931dd11770e1cb",
|
||||
"reference": "6d51299e307dc510149e0b7cd1931dd11770e1cb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3206,7 +3510,7 @@
|
||||
"phpunit/php-text-template": "^1.2.1",
|
||||
"phpunit/php-timer": "^2.0",
|
||||
"phpunit/phpunit-mock-objects": "^6.1.1",
|
||||
"sebastian/comparator": "^2.1",
|
||||
"sebastian/comparator": "^2.1 || ^3.0",
|
||||
"sebastian/diff": "^3.0",
|
||||
"sebastian/environment": "^3.1",
|
||||
"sebastian/exporter": "^3.1",
|
||||
@@ -3254,7 +3558,7 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2018-04-13T02:28:50+00:00"
|
||||
"time": "2018-04-18T13:41:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
@@ -3359,30 +3663,30 @@
|
||||
},
|
||||
{
|
||||
"name": "sebastian/comparator",
|
||||
"version": "2.1.3",
|
||||
"version": "3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/comparator.git",
|
||||
"reference": "34369daee48eafb2651bea869b4b15d75ccc35f9"
|
||||
"reference": "ed5fd2281113729f1ebcc64d101ad66028aeb3d5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9",
|
||||
"reference": "34369daee48eafb2651bea869b4b15d75ccc35f9",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/ed5fd2281113729f1ebcc64d101ad66028aeb3d5",
|
||||
"reference": "ed5fd2281113729f1ebcc64d101ad66028aeb3d5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.0",
|
||||
"sebastian/diff": "^2.0 || ^3.0",
|
||||
"php": "^7.1",
|
||||
"sebastian/diff": "^3.0",
|
||||
"sebastian/exporter": "^3.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.4"
|
||||
"phpunit/phpunit": "^7.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.1.x-dev"
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -3419,7 +3723,7 @@
|
||||
"compare",
|
||||
"equality"
|
||||
],
|
||||
"time": "2018-02-01T13:46:46+00:00"
|
||||
"time": "2018-04-18T13:33:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/diff",
|
||||
@@ -3968,7 +4272,9 @@
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": [],
|
||||
"stability-flags": {
|
||||
"tymon/jwt-auth": 20
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
|
||||
+3
-1
@@ -146,10 +146,10 @@ return [
|
||||
Illuminate\Translation\TranslationServiceProvider::class,
|
||||
Illuminate\Validation\ValidationServiceProvider::class,
|
||||
Illuminate\View\ViewServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Package Service Providers...
|
||||
*/
|
||||
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
@@ -208,6 +208,8 @@ return [
|
||||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class,
|
||||
'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class,
|
||||
|
||||
],
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+10
-3
@@ -13,6 +13,13 @@ use Illuminate\Http\Request;
|
||||
|
|
||||
*/
|
||||
|
||||
Route::middleware('auth:api')->get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
//Route::middleware('auth:api')->get('/user', function (Request $request) {
|
||||
// return $request->user();
|
||||
//});
|
||||
|
||||
Route::post('register', 'AuthController@register');
|
||||
Route::post('login', 'AuthController@login');
|
||||
Route::post('recover', 'AuthController@recover');
|
||||
Route::group(['middleware' => ['jwt.auth']], function() {
|
||||
Route::get('logout', 'AuthController@logout');
|
||||
});
|
||||
@@ -14,3 +14,6 @@
|
||||
Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.request');
|
||||
Route::post('password/reset', 'Auth\ResetPasswordController@postReset')->name('password.reset');
|
||||
|
||||
Reference in New Issue
Block a user