Skip to content

Commit 9209045

Browse files
Merge pull request #7 from anindya-dhruba/dev
Dev
2 parents 0c75aaa + 5f6a337 commit 9209045

File tree

85 files changed

+14085
-55591
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+14085
-55591
lines changed

.env.example

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
APP_NAME="Laravel Vue SPA"
12
APP_ENV=local
23
APP_KEY=
34
APP_DEBUG=true
@@ -11,17 +12,20 @@ DB_DATABASE=homestead
1112
DB_USERNAME=homestead
1213
DB_PASSWORD=secret
1314

15+
JWT_SECRET=yourJwtSecretCodeGoesHere
16+
1417
BROADCAST_DRIVER=log
1518
CACHE_DRIVER=file
1619
SESSION_DRIVER=file
20+
SESSION_LIFETIME=120
1721
QUEUE_DRIVER=sync
1822

1923
REDIS_HOST=127.0.0.1
2024
REDIS_PASSWORD=null
2125
REDIS_PORT=6379
2226

2327
MAIL_DRIVER=smtp
24-
MAIL_HOST=mailtrap.io
28+
MAIL_HOST=smtp.mailtrap.io
2529
MAIL_PORT=2525
2630
MAIL_USERNAME=null
2731
MAIL_PASSWORD=null
@@ -30,3 +34,4 @@ MAIL_ENCRYPTION=null
3034
PUSHER_APP_ID=
3135
PUSHER_APP_KEY=
3236
PUSHER_APP_SECRET=
37+
PUSHER_APP_CLUSTER=mt1

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
* text=auto
22
*.css linguist-vendored
33
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
/node_modules
2-
/public/storage
32
/public/hot
3+
/public/storage
44
/storage/*.key
55
/vendor
66
/.idea
7+
/.vagrant
78
Homestead.json
89
Homestead.yaml
10+
npm-debug.log
11+
yarn-error.log
912
.env
13+
.DS_Store

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Anindya Dhruba
3+
Copyright (c) 2018 Anindya Dhruba
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Procfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/Console/Kernel.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ protected function schedule(Schedule $schedule)
2929
}
3030

3131
/**
32-
* Register the Closure based commands for the application.
32+
* Register the commands for the application.
3333
*
3434
* @return void
3535
*/
3636
protected function commands()
3737
{
38+
$this->load(__DIR__.'/Commands');
39+
3840
require base_path('routes/console.php');
3941
}
4042
}

app/Exceptions/Handler.php

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,27 @@
33
namespace App\Exceptions;
44

55
use Exception;
6-
use Illuminate\Auth\AuthenticationException;
76
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
87

98
class Handler extends ExceptionHandler
109
{
1110
/**
12-
* A list of the exception types that should not be reported.
11+
* A list of the exception types that are not reported.
1312
*
1413
* @var array
1514
*/
1615
protected $dontReport = [
17-
\Illuminate\Auth\AuthenticationException::class,
18-
\Illuminate\Auth\Access\AuthorizationException::class,
19-
\Symfony\Component\HttpKernel\Exception\HttpException::class,
20-
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
21-
\Illuminate\Session\TokenMismatchException::class,
22-
\Illuminate\Validation\ValidationException::class,
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var array
23+
*/
24+
protected $dontFlash = [
25+
'password',
26+
'password_confirmation',
2327
];
2428

2529
/**
@@ -46,20 +50,4 @@ public function render($request, Exception $exception)
4650
{
4751
return parent::render($request, $exception);
4852
}
49-
50-
/**
51-
* Convert an authentication exception into an unauthenticated response.
52-
*
53-
* @param \Illuminate\Http\Request $request
54-
* @param \Illuminate\Auth\AuthenticationException $exception
55-
* @return \Illuminate\Http\Response
56-
*/
57-
protected function unauthenticated($request, AuthenticationException $exception)
58-
{
59-
if ($request->expectsJson()) {
60-
return response()->json(['error' => 'Unauthenticated.'], 401);
61-
}
62-
63-
return redirect()->guest(route('login'));
64-
}
6553
}

app/Http/Controllers/Auth/LoginController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ class LoginController extends Controller
3434
*/
3535
public function __construct()
3636
{
37-
$this->middleware('guest', ['except' => 'logout']);
37+
$this->middleware('guest')->except('logout');
3838
}
3939
}

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ public function __construct()
4848
protected function validator(array $data)
4949
{
5050
return Validator::make($data, [
51-
'name' => 'required|max:255',
52-
'email' => 'required|email|max:255|unique:users',
53-
'password' => 'required|min:6|confirmed',
51+
'name' => 'required|string|max:255',
52+
'email' => 'required|string|email|max:255|unique:users',
53+
'password' => 'required|string|min:6|confirmed',
5454
]);
5555
}
5656

5757
/**
5858
* Create a new user instance after a valid registration.
5959
*
6060
* @param array $data
61-
* @return User
61+
* @return \App\User
6262
*/
6363
protected function create(array $data)
6464
{

app/Http/Controllers/AuthenticateController.php

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,27 @@
88

99
class AuthenticateController extends Controller
1010
{
11-
public function authenticate(Request $request)
12-
{
13-
$rules = [
14-
'email' => 'required|email',
15-
'password' => 'required'
16-
];
17-
18-
$this->validate($request, $rules);
19-
20-
$credentials = $request->only('email', 'password');
21-
22-
try {
23-
if (! $token = JWTAuth::attempt($credentials)) {
24-
return response()->json(['error' => 'Invalid Login Credential'], 401);
25-
}
26-
} catch (JWTException $e) {
27-
return response()->json(['error' => 'Could not create token'], 500);
28-
}
29-
30-
return response()->json(compact('token'));
31-
}
11+
public function authenticate(Request $request)
12+
{
13+
$rules = [
14+
'email' => 'required|email',
15+
'password' => 'required'
16+
];
17+
18+
$this->validate($request, $rules);
19+
20+
$credentials = $request->only('email', 'password');
21+
22+
try {
23+
if(!$token = JWTAuth::attempt($credentials)) {
24+
return response()->json(['error' => 'Invalid Login Credential'], 401);
25+
}
26+
} catch(JWTException $e) {
27+
return response()->json(['error' => 'Could not create token'], 500);
28+
}
29+
30+
$user = $request->user();
31+
32+
return response()->json(compact('token', 'user'));
33+
}
3234
}

0 commit comments

Comments
 (0)