Skip to content

Commit d9cf563

Browse files
author
Tony Lea
committed
Adding functionality for login, register, and viewing dashboard
1 parent 6e092c3 commit d9cf563

File tree

126 files changed

+4196
-347
lines changed

Some content is hidden

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

126 files changed

+4196
-347
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/storage/*.key
77
/storage/pail
88
/vendor
9+
.DS_Store
910
.env
1011
.env.backup
1112
.env.production

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

README.md

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,35 @@
77
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
88
</p>
99

10-
## About Laravel
10+
## Vue Starter Kit
1111

12-
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
12+
Welcome to the Laravel **Vue Starter Kit**, a starter kit built using [Laravel](https://laravel.com), [Vue](https://vuejs.org), [Inertia](https://inertiajs.com), and [Tailwind CSS](https://tailwindcss.com).
1313

14-
- [Simple, fast routing engine](https://laravel.com/docs/routing).
15-
- [Powerful dependency injection container](https://laravel.com/docs/container).
16-
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
17-
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
18-
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
19-
- [Robust background job processing](https://laravel.com/docs/queues).
20-
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
14+
## Installation
2115

22-
Laravel is accessible, powerful, and provides tools required for large, robust applications.
16+
To install the starter kit, run the following command:
2317

24-
## Learning Laravel
18+
1. git clone https://github.com/laravel/vue-starter-kit
19+
2. cd vue-starter-kit
20+
3. composer run dev
2521

26-
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
22+
## Icons
2723

28-
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
24+
This starter kit leverages the [Lucide Vue Library](https://lucide.dev/guide/packages/lucide-vue-next), which provides you with a collection of over 1000 icons. View the full list of icons [here](https://lucide.dev/icons).
2925

30-
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
26+
Here's a quick example of using an icon in one of your Vue Components:
3127

32-
## Laravel Sponsors
28+
```
29+
<script setup lang="ts">
30+
...
31+
import { Rocket } from 'lucide-vue-next';
32+
...
33+
</script>
3334
34-
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
35-
36-
### Premium Partners
37-
38-
- **[Vehikl](https://vehikl.com/)**
39-
- **[Tighten Co.](https://tighten.co)**
40-
- **[WebReinvent](https://webreinvent.com/)**
41-
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
42-
- **[64 Robots](https://64robots.com)**
43-
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
44-
- **[Cyber-Duck](https://cyber-duck.co.uk)**
45-
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
46-
- **[Jump24](https://jump24.co.uk)**
47-
- **[Redberry](https://redberry.international/laravel/)**
48-
- **[Active Logic](https://activelogic.com)**
49-
- **[byte5](https://byte5.de)**
50-
- **[OP.GG](https://op.gg)**
51-
52-
## Contributing
53-
54-
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
55-
56-
## Code of Conduct
57-
58-
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
59-
60-
## Security Vulnerabilities
61-
62-
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [[email protected]](mailto:[email protected]). All security vulnerabilities will be promptly addressed.
63-
64-
## License
65-
66-
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
35+
<template>
36+
<p class="flex items-center space-x-2">
37+
<Rocket />
38+
<span class="text-lg font-medium">Vue Starter Kit</span>
39+
</p>
40+
</template>
41+
```
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Http\Requests\Auth\LoginRequest;
7+
use Illuminate\Foundation\Inspiring;
8+
use Illuminate\Http\RedirectResponse;
9+
use Illuminate\Http\Request;
10+
use Illuminate\Support\Facades\Auth;
11+
use Illuminate\Support\Facades\Route;
12+
use Inertia\Inertia;
13+
use Inertia\Response;
14+
15+
class AuthenticatedSessionController extends Controller
16+
{
17+
/**
18+
* Display the login view.
19+
*/
20+
public function create(): Response
21+
{
22+
[$message, $author] = str(Inspiring::quotes()->random())->explode('-');
23+
24+
return Inertia::render('Auth/Login', [
25+
'canResetPassword' => Route::has('password.request'),
26+
'status' => session('status'),
27+
'name' => config('app.name'),
28+
'quote' => ['message' => trim($message), 'author' => trim($author)],
29+
]);
30+
}
31+
32+
/**
33+
* Handle an incoming authentication request.
34+
*/
35+
public function store(LoginRequest $request): RedirectResponse
36+
{
37+
$request->authenticate();
38+
39+
$request->session()->regenerate();
40+
41+
return redirect()->intended(route('dashboard', absolute: false));
42+
}
43+
44+
/**
45+
* Destroy an authenticated session.
46+
*/
47+
public function destroy(Request $request): RedirectResponse
48+
{
49+
Auth::guard('web')->logout();
50+
51+
$request->session()->invalidate();
52+
53+
$request->session()->regenerateToken();
54+
55+
return redirect('/');
56+
}
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Auth;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Models\User;
7+
use Illuminate\Auth\Events\Registered;
8+
use Illuminate\Foundation\Inspiring;
9+
use Illuminate\Http\RedirectResponse;
10+
use Illuminate\Http\Request;
11+
use Illuminate\Support\Facades\Auth;
12+
use Illuminate\Support\Facades\Hash;
13+
use Illuminate\Validation\Rules;
14+
use Inertia\Inertia;
15+
use Inertia\Response;
16+
17+
class RegisteredUserController extends Controller
18+
{
19+
/**
20+
* Display the registration view.
21+
*/
22+
public function create(): Response
23+
{
24+
[$message, $author] = str(Inspiring::quotes()->random())->explode('-');
25+
26+
return Inertia::render('Auth/Register', [
27+
'name' => config('app.name'),
28+
'quote' => ['message' => trim($message), 'author' => trim($author)],
29+
]);
30+
}
31+
32+
/**
33+
* Handle an incoming registration request.
34+
*
35+
* @throws \Illuminate\Validation\ValidationException
36+
*/
37+
public function store(Request $request): RedirectResponse
38+
{
39+
$request->validate([
40+
'name' => 'required|string|max:255',
41+
'email' => 'required|string|lowercase|email|max:255|unique:'.User::class,
42+
'password' => ['required', 'confirmed', Rules\Password::defaults()],
43+
]);
44+
45+
$user = User::create([
46+
'name' => $request->name,
47+
'email' => $request->email,
48+
'password' => Hash::make($request->password),
49+
]);
50+
51+
event(new Registered($user));
52+
53+
Auth::login($user);
54+
55+
return redirect(route('dashboard', absolute: false));
56+
}
57+
}

app/Http/Middleware/HandleInertiaRequests.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public function version(Request $request): ?string
3636
public function share(Request $request): array
3737
{
3838
return array_merge(parent::share($request), [
39-
//
39+
'auth' => [
40+
'user' => $request->user(),
41+
],
4042
]);
4143
}
4244
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace App\Http\Requests\Auth;
4+
5+
use Illuminate\Auth\Events\Lockout;
6+
use Illuminate\Foundation\Http\FormRequest;
7+
use Illuminate\Support\Facades\Auth;
8+
use Illuminate\Support\Facades\RateLimiter;
9+
use Illuminate\Support\Str;
10+
use Illuminate\Validation\ValidationException;
11+
12+
class LoginRequest extends FormRequest
13+
{
14+
/**
15+
* Determine if the user is authorized to make this request.
16+
*/
17+
public function authorize(): bool
18+
{
19+
return true;
20+
}
21+
22+
/**
23+
* Get the validation rules that apply to the request.
24+
*
25+
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
26+
*/
27+
public function rules(): array
28+
{
29+
return [
30+
'email' => ['required', 'string', 'email'],
31+
'password' => ['required', 'string'],
32+
];
33+
}
34+
35+
/**
36+
* Attempt to authenticate the request's credentials.
37+
*
38+
* @throws \Illuminate\Validation\ValidationException
39+
*/
40+
public function authenticate(): void
41+
{
42+
$this->ensureIsNotRateLimited();
43+
44+
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
45+
RateLimiter::hit($this->throttleKey());
46+
47+
throw ValidationException::withMessages([
48+
'email' => trans('auth.failed'),
49+
]);
50+
}
51+
52+
RateLimiter::clear($this->throttleKey());
53+
}
54+
55+
/**
56+
* Ensure the login request is not rate limited.
57+
*
58+
* @throws \Illuminate\Validation\ValidationException
59+
*/
60+
public function ensureIsNotRateLimited(): void
61+
{
62+
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
63+
return;
64+
}
65+
66+
event(new Lockout($this));
67+
68+
$seconds = RateLimiter::availableIn($this->throttleKey());
69+
70+
throw ValidationException::withMessages([
71+
'email' => trans('auth.throttle', [
72+
'seconds' => $seconds,
73+
'minutes' => ceil($seconds / 60),
74+
]),
75+
]);
76+
}
77+
78+
/**
79+
* Get the rate limiting throttle key for the request.
80+
*/
81+
public function throttleKey(): string
82+
{
83+
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
84+
}
85+
}

components.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://shadcn-vue.com/schema.json",
3+
"style": "default",
4+
"typescript": true,
5+
"tsConfigPath": "./tsconfig.json",
6+
"tailwind": {
7+
"config": "tailwind.config.js",
8+
"css": "resources/css/app.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"framework": "laravel",
14+
"aliases": {
15+
"components": "resources/js/Components",
16+
"utils": "@/utils.ts"
17+
}
18+
}

0 commit comments

Comments
 (0)