diff --git a/app/Http/Controllers/Auth/ConfirmPasswordController.php b/app/Http/Controllers/Auth/ConfirmPasswordController.php new file mode 100644 index 00000000..138c1f08 --- /dev/null +++ b/app/Http/Controllers/Auth/ConfirmPasswordController.php @@ -0,0 +1,40 @@ +middleware('auth'); + } +} diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 6a247fef..465c39cc 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -19,14 +19,4 @@ class ForgotPasswordController extends Controller */ use SendsPasswordResetEmails; - - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct() - { - $this->middleware('guest'); - } } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 75949531..18a0d088 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\AuthenticatesUsers; class LoginController extends Controller @@ -25,7 +26,7 @@ class LoginController extends Controller * * @var string */ - protected $redirectTo = '/home'; + protected $redirectTo = RouteServiceProvider::HOME; /** * Create a new controller instance. @@ -34,6 +35,6 @@ class LoginController extends Controller */ public function __construct() { - $this->middleware('guest', ['except' => 'logout']); + $this->middleware('guest')->except('logout'); } } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 6b1b95b5..ed1a5e07 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -2,12 +2,12 @@ namespace App\Http\Controllers\Auth; -use App\Models\User; use App\Http\Controllers\Controller; -use Illuminate\Auth\Events\Registered; -use Illuminate\Http\Request; -use Illuminate\Support\Facades\Validator; +use App\Providers\RouteServiceProvider; +use App\Models\User; use Illuminate\Foundation\Auth\RegistersUsers; +use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Validator; class RegisterController extends Controller { @@ -29,7 +29,7 @@ class RegisterController extends Controller * * @var string */ - protected $redirectTo = '/home'; + protected $redirectTo = RouteServiceProvider::HOME; /** * Create a new controller instance. @@ -50,9 +50,9 @@ public function __construct() protected function validator(array $data) { return Validator::make($data, [ - 'name' => 'required|max:255', - 'email' => 'required|email|max:255|unique:users', - 'password' => 'required|min:6|confirmed', + 'name' => ['required', 'string', 'max:255'], + 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], + 'password' => ['required', 'string', 'min:8', 'confirmed'], ]); } @@ -60,36 +60,14 @@ protected function validator(array $data) * Create a new user instance after a valid registration. * * @param array $data - * @return User + * @return \App\Models\User */ protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], - 'password' => bcrypt($data['password']), + 'password' => Hash::make($data['password']), ]); } - - /** - * Handle a registration request for the application. - * - * @param \Illuminate\Http\Request $request - * @return \Illuminate\Http\Response - */ - public function register(Request $request) - { - $this->validator($request->all())->validate(); - - event(new Registered($user = $this->create($request->all()))); - - if ($request->expectsJson()) { - return response()->json(['Created'], 201); - } - - $this->guard()->login($user); - - return $this->registered($request, $user) - ?: redirect($this->redirectPath()); - } } diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index cf726eec..b1726a36 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\ResetsPasswords; class ResetPasswordController extends Controller @@ -25,15 +26,5 @@ class ResetPasswordController extends Controller * * @var string */ - protected $redirectTo = '/home'; - - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct() - { - $this->middleware('guest'); - } + protected $redirectTo = RouteServiceProvider::HOME; } diff --git a/app/Http/Controllers/Auth/VerificationController.php b/app/Http/Controllers/Auth/VerificationController.php new file mode 100644 index 00000000..5e749af8 --- /dev/null +++ b/app/Http/Controllers/Auth/VerificationController.php @@ -0,0 +1,42 @@ +middleware('auth'); + $this->middleware('signed')->only('verify'); + $this->middleware('throttle:6,1')->only('verify', 'resend'); + } +} diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 718956aa..5e53a321 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -10,6 +10,8 @@ class RouteServiceProvider extends ServiceProvider { + const HOME = '/'; + /** * This namespace is applied to your controller routes. * diff --git a/composer.json b/composer.json index d0a56e92..576d2da6 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "guzzlehttp/guzzle": "^7.0.1", "laravel/framework": "^8.12", "laravel/sanctum": "^2.8", - "laravel/tinker": "^2.5" + "laravel/tinker": "^2.5", + "laravel/ui": "^3.1" }, "require-dev": { "facade/ignition": "^2.5", diff --git a/composer.lock b/composer.lock index 5d857c82..df1bf458 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0b65e1f2438fc4b62dc22e80a6da1265", + "content-hash": "921df622357932e7e2aa761032770523", "packages": [ { "name": "asm89/stack-cors", @@ -1191,6 +1191,64 @@ }, "time": "2020-10-29T13:07:12+00:00" }, + { + "name": "laravel/ui", + "version": "v3.1.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/ui.git", + "reference": "444072cb2f8baaa15172c5cde2bd30d188c3b7e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/ui/zipball/444072cb2f8baaa15172c5cde2bd30d188c3b7e7", + "reference": "444072cb2f8baaa15172c5cde2bd30d188c3b7e7", + "shasum": "" + }, + "require": { + "illuminate/console": "^8.0", + "illuminate/filesystem": "^8.0", + "illuminate/support": "^8.0", + "php": "^7.3|^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + }, + "laravel": { + "providers": [ + "Laravel\\Ui\\UiServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Ui\\": "src/", + "Illuminate\\Foundation\\Auth\\": "auth-backend/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Laravel UI utilities and presets.", + "keywords": [ + "laravel", + "ui" + ], + "support": { + "issues": "https://github.com/laravel/ui/issues", + "source": "https://github.com/laravel/ui/tree/v3.1.0" + }, + "time": "2020-11-03T19:51:21+00:00" + }, { "name": "league/commonmark", "version": "1.5.7", diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index 0d5cb845..0ee0a36a 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -1,8 +1,8 @@ {
-