Skip to content

Commit a331816

Browse files
committed
Upgrade to Nuxt 2.8 and Laravel 5.8
1 parent 83ff55c commit a331816

Some content is hidden

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

65 files changed

+4516
-2509
lines changed

Diff for: .env.example

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@ APP_NAME="Laravel Nuxt"
22
APP_ENV=local
33
APP_KEY=
44
APP_DEBUG=true
5-
APP_LOG_LEVEL=debug
65
APP_URL=http://localhost
76

7+
LOG_CHANNEL=stack
8+
89
DB_CONNECTION=mysql
910
DB_HOST=127.0.0.1
1011
DB_PORT=3306
11-
DB_DATABASE=homestead
12-
DB_USERNAME=homestead
13-
DB_PASSWORD=secret
12+
DB_DATABASE=laravel
13+
DB_USERNAME=root
14+
DB_PASSWORD=
1415

1516
BROADCAST_DRIVER=log
1617
CACHE_DRIVER=file
18+
QUEUE_CONNECTION=sync
1719
SESSION_DRIVER=file
18-
QUEUE_DRIVER=sync
20+
SESSION_LIFETIME=120
1921

2022
REDIS_HOST=127.0.0.1
2123
REDIS_PASSWORD=null
@@ -28,8 +30,14 @@ MAIL_USERNAME=null
2830
MAIL_PASSWORD=null
2931
MAIL_ENCRYPTION=null
3032

33+
AWS_ACCESS_KEY_ID=
34+
AWS_SECRET_ACCESS_KEY=
35+
AWS_DEFAULT_REGION=us-east-1
36+
AWS_BUCKET=
37+
3138
PUSHER_APP_ID=
3239
PUSHER_APP_KEY=
3340
PUSHER_APP_SECRET=
41+
PUSHER_APP_CLUSTER=mt1
3442

3543
JWT_TTL=1440

Diff for: .gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
/public/storage
44
/storage/*.key
55
/vendor
6-
/.idea
7-
/.vagrant
6+
.env
7+
.env.backup
8+
.phpunit.result.cache
89
Homestead.json
910
Homestead.yaml
1011
npm-debug.log
1112
yarn-error.log
12-
.env
1313
.nuxt
1414
/dist
1515
/public/_nuxt

Diff for: CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
## Unreleased
44

5-
- Upgrade to Nuxt 2.7
5+
- Upgrade to Nuxt 2.8
6+
- Upgrade to Laravel 5.8
7+
- Added email verification
68
- SPA mode by default
79
- Update npm dependencies
10+
- Removed yarn.lock in favor of package-lock.json
811

912
## 1.1.0 - 2018-05-10
1013

Diff for: README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212

1313
## Features
1414

15-
- Laravel 5.6
16-
- Nuxt 2.7
17-
- VueI18n
18-
- SPA or SSR
19-
- Authentication with JWT
15+
- Nuxt 2.8
16+
- Laravel 5.8
17+
- SPA or SSR
2018
- Socialite integration
21-
- Bootstrap 4 + Font Awesome 5
22-
- Login, register, password reset and profile pages
19+
- VueI18n + ESlint + Bootstrap 4 + Font Awesome 5
20+
- Login, register, email verification and password reset
2321

2422
## Installation
2523

Diff for: app/Exceptions/Handler.php

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Exceptions;
44

55
use Exception;
6+
use Illuminate\Auth\AuthenticationException;
67
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
78

89
class Handler extends ExceptionHandler
@@ -50,4 +51,18 @@ public function render($request, Exception $exception)
5051
{
5152
return parent::render($request, $exception);
5253
}
54+
55+
/**
56+
* Convert an authentication exception into a response.
57+
*
58+
* @param \Illuminate\Http\Request $request
59+
* @param \Illuminate\Auth\AuthenticationException $exception
60+
* @return \Illuminate\Http\Response
61+
*/
62+
protected function unauthenticated($request, AuthenticationException $exception)
63+
{
64+
return $request->expectsJson()
65+
? response()->json(['message' => $exception->getMessage()], 401)
66+
: redirect()->guest(url('/login'));
67+
}
5368
}

Diff for: app/Exceptions/VerifyEmailException.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Validation\ValidationException;
6+
7+
class VerifyEmailException extends ValidationException
8+
{
9+
/**
10+
* @param \App\User $user
11+
* @return static
12+
*/
13+
public static function forUser($user)
14+
{
15+
return static::withMessages([
16+
'email' => [__('You must :linkOpen verify :linkClose your email first.', [
17+
'linkOpen' => '<a href="/email/resend?email='.urlencode($user->email).'">',
18+
'linkClose' => '</a>',
19+
])],
20+
]);
21+
}
22+
}

Diff for: app/Http/Controllers/Auth/ForgotPasswordController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ public function __construct()
2323
/**
2424
* Get the response for a successful password reset link.
2525
*
26+
* @param \Illuminate\Http\Request $request
2627
* @param string $response
2728
* @return \Illuminate\Http\RedirectResponse
2829
*/
29-
protected function sendResetLinkResponse($response)
30+
protected function sendResetLinkResponse(Request $request, $response)
3031
{
3132
return ['status' => trans($response)];
3233
}

Diff for: app/Http/Controllers/Auth/LoginController.php

+35-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use Illuminate\Http\Request;
66
use App\Http\Controllers\Controller;
7+
use App\Exceptions\VerifyEmailException;
8+
use Illuminate\Contracts\Auth\MustVerifyEmail;
9+
use Illuminate\Validation\ValidationException;
710
use Illuminate\Foundation\Auth\AuthenticatesUsers;
811

912
class LoginController extends Controller
@@ -30,20 +33,25 @@ protected function attemptLogin(Request $request)
3033
{
3134
$token = $this->guard()->attempt($this->credentials($request));
3235

33-
if ($token) {
34-
$this->guard()->setToken($token);
36+
if (! $token) {
37+
return false;
38+
}
3539

36-
return true;
40+
$user = $this->guard()->user();
41+
if ($user instanceof MustVerifyEmail && ! $user->hasVerifiedEmail()) {
42+
return false;
3743
}
3844

39-
return false;
45+
$this->guard()->setToken($token);
46+
47+
return true;
4048
}
4149

4250
/**
4351
* Send the response after the user was authenticated.
4452
*
4553
* @param \Illuminate\Http\Request $request
46-
* @return \Illuminate\Http\Response
54+
* @return \Illuminate\Http\JsonResponse
4755
*/
4856
protected function sendLoginResponse(Request $request)
4957
{
@@ -52,11 +60,31 @@ protected function sendLoginResponse(Request $request)
5260
$token = (string) $this->guard()->getToken();
5361
$expiration = $this->guard()->getPayload()->get('exp');
5462

55-
return [
63+
return response()->json([
5664
'token' => $token,
5765
'token_type' => 'bearer',
5866
'expires_in' => $expiration - time(),
59-
];
67+
]);
68+
}
69+
70+
/**
71+
* Get the failed login response instance.
72+
*
73+
* @param \Illuminate\Http\Request $request
74+
* @return \Illuminate\Http\JsonResponse
75+
*
76+
* @throws \Illuminate\Validation\ValidationException
77+
*/
78+
protected function sendFailedLoginResponse(Request $request)
79+
{
80+
$user = $this->guard()->user();
81+
if ($user instanceof MustVerifyEmail && ! $user->hasVerifiedEmail()) {
82+
throw VerifyEmailException::forUser($user);
83+
}
84+
85+
throw ValidationException::withMessages([
86+
$this->username() => [trans('auth.failed')],
87+
]);
6088
}
6189

6290
/**

Diff for: app/Http/Controllers/Auth/OAuthController.php

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ protected function createUser($provider, $sUser)
9797
$user = User::create([
9898
'name' => $sUser->getName(),
9999
'email' => $sUser->getEmail(),
100+
'email_verified_at' => now(),
100101
]);
101102

102103
$user->oauthProviders()->create([

Diff for: app/Http/Controllers/Auth/RegisterController.php

+12-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Http\Request;
77
use App\Http\Controllers\Controller;
88
use Illuminate\Support\Facades\Validator;
9+
use Illuminate\Contracts\Auth\MustVerifyEmail;
910
use Illuminate\Foundation\Auth\RegistersUsers;
1011

1112
class RegisterController extends Controller
@@ -26,12 +27,18 @@ public function __construct()
2627
* The user has been registered.
2728
*
2829
* @param \Illuminate\Http\Request $request
29-
* @param mixed $user
30-
* @return mixed
30+
* @param \App\User $user
31+
* @return \Illuminate\Http\JsonResponse
3132
*/
32-
protected function registered(Request $request, $user)
33+
protected function registered(Request $request, User $user)
3334
{
34-
return $user;
35+
if ($user instanceof MustVerifyEmail) {
36+
$user->sendEmailVerificationNotification();
37+
38+
return response()->json(['status' => trans('verification.sent')]);
39+
}
40+
41+
return response()->json($user);
3542
}
3643

3744
/**
@@ -53,7 +60,7 @@ protected function validator(array $data)
5360
* Create a new user instance after a valid registration.
5461
*
5562
* @param array $data
56-
* @return User
63+
* @return \App\User
5764
*/
5865
protected function create(array $data)
5966
{

Diff for: app/Http/Controllers/Auth/ResetPasswordController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ public function __construct()
2323
/**
2424
* Get the response for a successful password reset.
2525
*
26+
* @param \Illuminate\Http\Request $request
2627
* @param string $response
2728
* @return \Illuminate\Http\RedirectResponse
2829
*/
29-
protected function sendResetResponse($response)
30+
protected function sendResetResponse(Request $request, $response)
3031
{
3132
return ['status' => trans($response)];
3233
}

Diff for: app/Http/Controllers/Auth/VerificationController.php

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\User;
6+
use Illuminate\Http\Request;
7+
use Illuminate\Support\Facades\URL;
8+
use App\Http\Controllers\Controller;
9+
use Illuminate\Auth\Events\Verified;
10+
use Illuminate\Validation\ValidationException;
11+
12+
class VerificationController extends Controller
13+
{
14+
/**
15+
* Create a new controller instance.
16+
*
17+
* @return void
18+
*/
19+
public function __construct()
20+
{
21+
$this->middleware('throttle:6,1')->only('verify', 'resend');
22+
}
23+
24+
/**
25+
* Mark the user's email address as verified.
26+
*
27+
* @param \Illuminate\Http\Request $request
28+
* @param \App\User $user
29+
* @return \Illuminate\Http\JsonResponse
30+
*/
31+
public function verify(Request $request, User $user)
32+
{
33+
if (! URL::hasValidSignature($request)) {
34+
return response()->json([
35+
'status' => trans('verification.invalid'),
36+
], 400);
37+
}
38+
39+
if ($user->hasVerifiedEmail()) {
40+
return response()->json([
41+
'status' => trans('verification.already_verified'),
42+
], 400);
43+
}
44+
45+
$user->markEmailAsVerified();
46+
47+
event(new Verified($user));
48+
49+
return response()->json([
50+
'status' => trans('verification.verified'),
51+
]);
52+
}
53+
54+
/**
55+
* Resend the email verification notification.
56+
*
57+
* @param \Illuminate\Http\Request $request
58+
* @return \Illuminate\Http\JsonResponse
59+
*/
60+
public function resend(Request $request)
61+
{
62+
$this->validate($request, ['email' => 'required|email']);
63+
64+
$user = User::where('email', $request->email)->first();
65+
66+
if (is_null($user)) {
67+
throw ValidationException::withMessages([
68+
'email' => [trans('verification.user')],
69+
]);
70+
}
71+
72+
if ($user->hasVerifiedEmail()) {
73+
throw ValidationException::withMessages([
74+
'email' => [trans('verification.already_verified')],
75+
]);
76+
}
77+
78+
$user->sendEmailVerificationNotification();
79+
80+
return response()->json(['status' => trans('verification.sent')]);
81+
}
82+
}

Diff for: app/Http/Controllers/Settings/PasswordController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class PasswordController extends Controller
1616
public function update(Request $request)
1717
{
1818
$this->validate($request, [
19-
'password' => 'required|confirmed|min:6',
19+
'password' => 'required|confirmed|min:8',
2020
]);
2121

2222
$request->user()->update([

0 commit comments

Comments
 (0)