PK 0Zα3 3 LICENSE.mdnu [ The MIT License (MIT) Copyright (c) Taylor Otwell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK 0Z auth-backend/RedirectsUsers.phpnu [ redirectTo(); } return property_exists($this, 'redirectTo') ? $this->redirectTo : '/home'; } } PK 0Zl! auth-backend/ResetsPasswords.phpnu [ route()->parameter('token'); return view('auth.passwords.reset')->with( ['token' => $token, 'email' => $request->email] ); } /** * Reset the given user's password. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse */ public function reset(Request $request) { $request->validate($this->rules(), $this->validationErrorMessages()); // Here we will attempt to reset the user's password. If it is successful we // will update the password on an actual user model and persist it to the // database. Otherwise we will parse the error and return the response. $response = $this->broker()->reset( $this->credentials($request), function ($user, $password) { $this->resetPassword($user, $password); } ); // If the password was successfully reset, we will redirect the user back to // the application's home authenticated view. If there is an error we can // redirect them back to where they came from with their error message. return $response == Password::PASSWORD_RESET ? $this->sendResetResponse($request, $response) : $this->sendResetFailedResponse($request, $response); } /** * Get the password reset validation rules. * * @return array */ protected function rules() { return [ 'token' => 'required', 'email' => 'required|email', 'password' => ['required', 'confirmed', Rules\Password::defaults()], ]; } /** * Get the password reset validation error messages. * * @return array */ protected function validationErrorMessages() { return []; } /** * Get the password reset credentials from the request. * * @param \Illuminate\Http\Request $request * @return array */ protected function credentials(Request $request) { return $request->only( 'email', 'password', 'password_confirmation', 'token' ); } /** * Reset the given user's password. * * @param \Illuminate\Contracts\Auth\CanResetPassword $user * @param string $password * @return void */ protected function resetPassword($user, $password) { $this->setUserPassword($user, $password); $user->setRememberToken(Str::random(60)); $user->save(); event(new PasswordReset($user)); $this->guard()->login($user); } /** * Set the user's password. * * @param \Illuminate\Contracts\Auth\CanResetPassword $user * @param string $password * @return void */ protected function setUserPassword($user, $password) { $user->password = Hash::make($password); } /** * Get the response for a successful password reset. * * @param \Illuminate\Http\Request $request * @param string $response * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse */ protected function sendResetResponse(Request $request, $response) { if ($request->wantsJson()) { return new JsonResponse(['message' => trans($response)], 200); } return redirect($this->redirectPath()) ->with('status', trans($response)); } /** * Get the response for a failed password reset. * * @param \Illuminate\Http\Request $request * @param string $response * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse */ protected function sendResetFailedResponse(Request $request, $response) { if ($request->wantsJson()) { throw ValidationException::withMessages([ 'email' => [trans($response)], ]); } return redirect()->back() ->withInput($request->only('email')) ->withErrors(['email' => trans($response)]); } /** * Get the broker to be used during password reset. * * @return \Illuminate\Contracts\Auth\PasswordBroker */ public function broker() { return Password::broker(); } /** * Get the guard to be used during password reset. * * @return \Illuminate\Contracts\Auth\StatefulGuard */ protected function guard() { return Auth::guard(); } } PK 0Zo8^T T auth-backend/ThrottlesLogins.phpnu [ limiter()->tooManyAttempts( $this->throttleKey($request), $this->maxAttempts() ); } /** * Increment the login attempts for the user. * * @param \Illuminate\Http\Request $request * @return void */ protected function incrementLoginAttempts(Request $request) { $this->limiter()->hit( $this->throttleKey($request), $this->decayMinutes() * 60 ); } /** * Redirect the user after determining they are locked out. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response * * @throws \Illuminate\Validation\ValidationException */ protected function sendLockoutResponse(Request $request) { $seconds = $this->limiter()->availableIn( $this->throttleKey($request) ); throw ValidationException::withMessages([ $this->username() => [trans('auth.throttle', [ 'seconds' => $seconds, 'minutes' => ceil($seconds / 60), ])], ])->status(Response::HTTP_TOO_MANY_REQUESTS); } /** * Clear the login locks for the given user credentials. * * @param \Illuminate\Http\Request $request * @return void */ protected function clearLoginAttempts(Request $request) { $this->limiter()->clear($this->throttleKey($request)); } /** * Fire an event when a lockout occurs. * * @param \Illuminate\Http\Request $request * @return void */ protected function fireLockoutEvent(Request $request) { event(new Lockout($request)); } /** * Get the throttle key for the given request. * * @param \Illuminate\Http\Request $request * @return string */ protected function throttleKey(Request $request) { return Str::transliterate(Str::lower($request->input($this->username())).'|'.$request->ip()); } /** * Get the rate limiter instance. * * @return \Illuminate\Cache\RateLimiter */ protected function limiter() { return app(RateLimiter::class); } /** * Get the maximum number of attempts to allow. * * @return int */ public function maxAttempts() { return property_exists($this, 'maxAttempts') ? $this->maxAttempts : 5; } /** * Get the number of minutes to throttle for. * * @return int */ public function decayMinutes() { return property_exists($this, 'decayMinutes') ? $this->decayMinutes : 1; } } PK 0ZVJ7 auth-backend/VerifiesEmails.phpnu [ user()->hasVerifiedEmail() ? redirect($this->redirectPath()) : view('auth.verify'); } /** * Mark the authenticated user's email address as verified. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse * * @throws \Illuminate\Auth\Access\AuthorizationException */ public function verify(Request $request) { if (! hash_equals((string) $request->route('id'), (string) $request->user()->getKey())) { throw new AuthorizationException; } if (! hash_equals((string) $request->route('hash'), sha1($request->user()->getEmailForVerification()))) { throw new AuthorizationException; } if ($request->user()->hasVerifiedEmail()) { return $request->wantsJson() ? new JsonResponse([], 204) : redirect($this->redirectPath()); } if ($request->user()->markEmailAsVerified()) { event(new Verified($request->user())); } if ($response = $this->verified($request)) { return $response; } return $request->wantsJson() ? new JsonResponse([], 204) : redirect($this->redirectPath())->with('verified', true); } /** * The user has been verified. * * @param \Illuminate\Http\Request $request * @return mixed */ protected function verified(Request $request) { // } /** * Resend the email verification notification. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse */ public function resend(Request $request) { if ($request->user()->hasVerifiedEmail()) { return $request->wantsJson() ? new JsonResponse([], 204) : redirect($this->redirectPath()); } $request->user()->sendEmailVerificationNotification(); return $request->wantsJson() ? new JsonResponse([], 202) : back()->with('resent', true); } } PK 0Z ' # auth-backend/AuthenticatesUsers.phpnu [ validateLogin($request); // If the class is using the ThrottlesLogins trait, we can automatically throttle // the login attempts for this application. We'll key this by the username and // the IP address of the client making these requests into this application. if (method_exists($this, 'hasTooManyLoginAttempts') && $this->hasTooManyLoginAttempts($request)) { $this->fireLockoutEvent($request); return $this->sendLockoutResponse($request); } if ($this->attemptLogin($request)) { if ($request->hasSession()) { $request->session()->put('auth.password_confirmed_at', time()); } return $this->sendLoginResponse($request); } // If the login attempt was unsuccessful we will increment the number of attempts // to login and redirect the user back to the login form. Of course, when this // user surpasses their maximum number of attempts they will get locked out. $this->incrementLoginAttempts($request); return $this->sendFailedLoginResponse($request); } /** * Validate the user login request. * * @param \Illuminate\Http\Request $request * @return void * * @throws \Illuminate\Validation\ValidationException */ protected function validateLogin(Request $request) { $request->validate([ $this->username() => 'required|string', 'password' => 'required|string', ]); } /** * Attempt to log the user into the application. * * @param \Illuminate\Http\Request $request * @return bool */ protected function attemptLogin(Request $request) { return $this->guard()->attempt( $this->credentials($request), $request->boolean('remember') ); } /** * Get the needed authorization credentials from the request. * * @param \Illuminate\Http\Request $request * @return array */ protected function credentials(Request $request) { return $request->only($this->username(), 'password'); } /** * Send the response after the user was authenticated. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse */ protected function sendLoginResponse(Request $request) { $request->session()->regenerate(); $this->clearLoginAttempts($request); if ($response = $this->authenticated($request, $this->guard()->user())) { return $response; } return $request->wantsJson() ? new JsonResponse([], 204) : redirect()->intended($this->redirectPath()); } /** * The user has been authenticated. * * @param \Illuminate\Http\Request $request * @param mixed $user * @return mixed */ protected function authenticated(Request $request, $user) { // } /** * Get the failed login response instance. * * @param \Illuminate\Http\Request $request * @return \Symfony\Component\HttpFoundation\Response * * @throws \Illuminate\Validation\ValidationException */ protected function sendFailedLoginResponse(Request $request) { throw ValidationException::withMessages([ $this->username() => [trans('auth.failed')], ]); } /** * Get the login username to be used by the controller. * * @return string */ public function username() { return 'email'; } /** * Log the user out of the application. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse */ public function logout(Request $request) { $this->guard()->logout(); $request->session()->invalidate(); $request->session()->regenerateToken(); if ($response = $this->loggedOut($request)) { return $response; } return $request->wantsJson() ? new JsonResponse([], 204) : redirect('/'); } /** * The user has logged out of the application. * * @param \Illuminate\Http\Request $request * @return mixed */ protected function loggedOut(Request $request) { // } /** * Get the guard to be used during authentication. * * @return \Illuminate\Contracts\Auth\StatefulGuard */ protected function guard() { return Auth::guard(); } } PK 0ZS ) auth-backend/SendsPasswordResetEmails.phpnu [ validateEmail($request); // We will send the password reset link to this user. Once we have attempted // to send the link, we will examine the response then see the message we // need to show to the user. Finally, we'll send out a proper response. $response = $this->broker()->sendResetLink( $this->credentials($request) ); return $response == Password::RESET_LINK_SENT ? $this->sendResetLinkResponse($request, $response) : $this->sendResetLinkFailedResponse($request, $response); } /** * Validate the email for the given request. * * @param \Illuminate\Http\Request $request * @return void */ protected function validateEmail(Request $request) { $request->validate(['email' => 'required|email']); } /** * Get the needed authentication credentials from the request. * * @param \Illuminate\Http\Request $request * @return array */ protected function credentials(Request $request) { return $request->only('email'); } /** * Get the response for a successful password reset link. * * @param \Illuminate\Http\Request $request * @param string $response * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse */ protected function sendResetLinkResponse(Request $request, $response) { return $request->wantsJson() ? new JsonResponse(['message' => trans($response)], 200) : back()->with('status', trans($response)); } /** * Get the response for a failed password reset link. * * @param \Illuminate\Http\Request $request * @param string $response * @return \Illuminate\Http\RedirectResponse * * @throws \Illuminate\Validation\ValidationException */ protected function sendResetLinkFailedResponse(Request $request, $response) { if ($request->wantsJson()) { throw ValidationException::withMessages([ 'email' => [trans($response)], ]); } return back() ->withInput($request->only('email')) ->withErrors(['email' => trans($response)]); } /** * Get the broker to be used during password reset. * * @return \Illuminate\Contracts\Auth\PasswordBroker */ public function broker() { return Password::broker(); } } PK 0Z0 auth-backend/RegistersUsers.phpnu [ validator($request->all())->validate(); event(new Registered($user = $this->create($request->all()))); $this->guard()->login($user); if ($response = $this->registered($request, $user)) { return $response; } return $request->wantsJson() ? new JsonResponse([], 201) : redirect($this->redirectPath()); } /** * Get the guard to be used during registration. * * @return \Illuminate\Contracts\Auth\StatefulGuard */ protected function guard() { return Auth::guard(); } /** * The user has been registered. * * @param \Illuminate\Http\Request $request * @param mixed $user * @return mixed */ protected function registered(Request $request, $user) { // } } PK 0Z/B^ ^ " auth-backend/ConfirmsPasswords.phpnu [ validate($this->rules(), $this->validationErrorMessages()); $this->resetPasswordConfirmationTimeout($request); return $request->wantsJson() ? new JsonResponse([], 204) : redirect()->intended($this->redirectPath()); } /** * Reset the password confirmation timeout. * * @param \Illuminate\Http\Request $request * @return void */ protected function resetPasswordConfirmationTimeout(Request $request) { $request->session()->put('auth.password_confirmed_at', time()); } /** * Get the password confirmation validation rules. * * @return array */ protected function rules() { return [ 'password' => 'required|current_password:web', ]; } /** * Get the password confirmation validation error messages. * * @return array */ protected function validationErrorMessages() { return []; } } PK 0ZCZ< < composer.jsonnu [ { "name": "laravel/ui", "description": "Laravel UI utilities and presets.", "keywords": ["laravel", "ui"], "license": "MIT", "authors": [ { "name": "Taylor Otwell", "email": "taylor@laravel.com" } ], "require": { "php": "^8.0", "illuminate/console": "^9.21|^10.0", "illuminate/filesystem": "^9.21|^10.0", "illuminate/support": "^9.21|^10.0", "illuminate/validation": "^9.21|^10.0" }, "require-dev": { "orchestra/testbench": "^7.0|^8.0", "phpunit/phpunit": "^9.3" }, "autoload": { "psr-4": { "Laravel\\Ui\\": "src/", "Illuminate\\Foundation\\Auth\\": "auth-backend/" } }, "config": { "sort-packages": true }, "extra": { "branch-alias": { "dev-master": "4.x-dev" }, "laravel": { "providers": [ "Laravel\\Ui\\UiServiceProvider" ] } }, "minimum-stability": "dev", "prefer-stable": true } PK 0Z5 5 src/AuthCommand.phpnu [ 'auth/login.blade.php', 'auth/passwords/confirm.stub' => 'auth/passwords/confirm.blade.php', 'auth/passwords/email.stub' => 'auth/passwords/email.blade.php', 'auth/passwords/reset.stub' => 'auth/passwords/reset.blade.php', 'auth/register.stub' => 'auth/register.blade.php', 'auth/verify.stub' => 'auth/verify.blade.php', 'home.stub' => 'home.blade.php', 'layouts/app.stub' => 'layouts/app.blade.php', ]; /** * Execute the console command. * * @return void * * @throws \InvalidArgumentException */ public function handle() { if (static::hasMacro($this->argument('type'))) { return call_user_func(static::$macros[$this->argument('type')], $this); } if (! in_array($this->argument('type'), ['bootstrap'])) { throw new InvalidArgumentException('Invalid preset.'); } $this->ensureDirectoriesExist(); $this->exportViews(); if (! $this->option('views')) { $this->exportBackend(); } $this->components->info('Authentication scaffolding generated successfully.'); } /** * Create the directories for the files. * * @return void */ protected function ensureDirectoriesExist() { if (! is_dir($directory = $this->getViewPath('layouts'))) { mkdir($directory, 0755, true); } if (! is_dir($directory = $this->getViewPath('auth/passwords'))) { mkdir($directory, 0755, true); } } /** * Export the authentication views. * * @return void */ protected function exportViews() { foreach ($this->views as $key => $value) { if (file_exists($view = $this->getViewPath($value)) && ! $this->option('force')) { if (! $this->components->confirm("The [$value] view already exists. Do you want to replace it?")) { continue; } } copy( __DIR__.'/Auth/'.$this->argument('type').'-stubs/'.$key, $view ); } } /** * Export the authentication backend. * * @return void */ protected function exportBackend() { $this->callSilent('ui:controllers'); $controller = app_path('Http/Controllers/HomeController.php'); if (file_exists($controller) && ! $this->option('force')) { if ($this->components->confirm("The [HomeController.php] file already exists. Do you want to replace it?")) { file_put_contents($controller, $this->compileControllerStub()); } } else { file_put_contents($controller, $this->compileControllerStub()); } file_put_contents( base_path('routes/web.php'), file_get_contents(__DIR__.'/Auth/stubs/routes.stub'), FILE_APPEND ); copy( __DIR__.'/../stubs/migrations/2014_10_12_100000_create_password_resets_table.php', base_path('database/migrations/2014_10_12_100000_create_password_resets_table.php') ); } /** * Compiles the "HomeController" stub. * * @return string */ protected function compileControllerStub() { return str_replace( '{{namespace}}', $this->laravel->getNamespace(), file_get_contents(__DIR__.'/Auth/stubs/controllers/HomeController.stub') ); } /** * Get full view path relative to the application's configured view path. * * @param string $path * @return string */ protected function getViewPath($path) { return implode(DIRECTORY_SEPARATOR, [ config('view.paths')[0] ?? resource_path('views'), $path, ]); } } PK 0Z,S src/UiServiceProvider.phpnu [ app->runningInConsole()) { $this->commands([ AuthCommand::class, ControllersCommand::class, UiCommand::class, ]); } } /** * Bootstrap any application services. * * @return void */ public function boot() { Route::mixin(new AuthRouteMethods); } } PK 0ZmM3 3 src/UiCommand.phpnu [ argument('type'))) { return call_user_func(static::$macros[$this->argument('type')], $this); } if (! in_array($this->argument('type'), ['bootstrap', 'vue', 'react'])) { throw new InvalidArgumentException('Invalid preset.'); } if ($this->option('auth')) { $this->call('ui:auth'); } $this->{$this->argument('type')}(); } /** * Install the "bootstrap" preset. * * @return void */ protected function bootstrap() { Presets\Bootstrap::install(); $this->components->info('Bootstrap scaffolding installed successfully.'); $this->components->warn('Please run [npm install && npm run dev] to compile your fresh scaffolding.'); } /** * Install the "vue" preset. * * @return void */ protected function vue() { Presets\Bootstrap::install(); Presets\Vue::install(); $this->components->info('Vue scaffolding installed successfully.'); $this->components->warn('Please run [npm install && npm run dev] to compile your fresh scaffolding.'); } /** * Install the "react" preset. * * @return void */ protected function react() { Presets\Bootstrap::install(); Presets\React::install(); $this->components->info('React scaffolding installed successfully.'); $this->components->warn('Please run [npm install && npm run dev] to compile your fresh scaffolding.'); } } PK 0Z(< src/Presets/Vue.phpnu [ '^4.0.0', 'vue' => '^3.2.37', ] + Arr::except($packages, [ '@vitejs/plugin-react', 'react', 'react-dom', ]); } /** * Update the Vite configuration. * * @return void */ protected static function updateViteConfiguration() { copy(__DIR__.'/vue-stubs/vite.config.js', base_path('vite.config.js')); } /** * Update the example component. * * @return void */ protected static function updateComponent() { (new Filesystem)->delete( resource_path('js/components/Example.js') ); copy( __DIR__.'/vue-stubs/ExampleComponent.vue', resource_path('js/components/ExampleComponent.vue') ); } /** * Update the bootstrapping files. * * @return void */ protected static function updateBootstrapping() { copy(__DIR__.'/vue-stubs/app.js', resource_path('js/app.js')); } } PK 0Z(֙_ _ src/Presets/Preset.phpnu [ isDirectory($directory = resource_path('js/components'))) { $filesystem->makeDirectory($directory, 0755, true); } } /** * Update the "package.json" file. * * @param bool $dev * @return void */ protected static function updatePackages($dev = true) { if (! file_exists(base_path('package.json'))) { return; } $configurationKey = $dev ? 'devDependencies' : 'dependencies'; $packages = json_decode(file_get_contents(base_path('package.json')), true); $packages[$configurationKey] = static::updatePackageArray( array_key_exists($configurationKey, $packages) ? $packages[$configurationKey] : [], $configurationKey ); ksort($packages[$configurationKey]); file_put_contents( base_path('package.json'), json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL ); } /** * Remove the installed Node modules. * * @return void */ protected static function removeNodeModules() { tap(new Filesystem, function ($files) { $files->deleteDirectory(base_path('node_modules')); $files->delete(base_path('yarn.lock')); }); } } PK 0ZB # src/Presets/react-stubs/Example.jsxnu [ import React from 'react'; import ReactDOM from 'react-dom/client'; function Example() { return (