34 |
35 | );
36 | }
37 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/PasswordResetLinkController.php:
--------------------------------------------------------------------------------
1 | session('status'),
22 | ]);
23 | }
24 |
25 | /**
26 | * Handle an incoming password reset link request.
27 | *
28 | * @throws \Illuminate\Validation\ValidationException
29 | */
30 | public function store(Request $request): RedirectResponse
31 | {
32 | $request->validate([
33 | 'email' => 'required|email',
34 | ]);
35 |
36 | // We will send the password reset link to this user. Once we have attempted
37 | // to send the link, we will examine the response then see the message we
38 | // need to show to the user. Finally, we'll send out a proper response.
39 | $status = Password::sendResetLink(
40 | $request->only('email')
41 | );
42 |
43 | if ($status == Password::RESET_LINK_SENT) {
44 | return back()->with('status', __($status));
45 | }
46 |
47 | throw ValidationException::withMessages([
48 | 'email' => [trans($status)],
49 | ]);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/database/migrations/0001_01_01_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | id();
16 | $table->string('role');
17 | $table->string('name');
18 | $table->string('email')->unique();
19 | $table->timestamp('email_verified_at')->nullable();
20 | $table->string('password');
21 | $table->rememberToken();
22 | $table->timestamps();
23 | });
24 |
25 | Schema::create('password_reset_tokens', function (Blueprint $table) {
26 | $table->string('email')->primary();
27 | $table->string('token');
28 | $table->timestamp('created_at')->nullable();
29 | });
30 |
31 | Schema::create('sessions', function (Blueprint $table) {
32 | $table->string('id')->primary();
33 | $table->foreignId('user_id')->nullable()->index();
34 | $table->string('ip_address', 45)->nullable();
35 | $table->text('user_agent')->nullable();
36 | $table->longText('payload');
37 | $table->integer('last_activity')->index();
38 | });
39 | }
40 |
41 | /**
42 | * Reverse the migrations.
43 | */
44 | public function down(): void
45 | {
46 | Schema::dropIfExists('users');
47 | Schema::dropIfExists('password_reset_tokens');
48 | Schema::dropIfExists('sessions');
49 | }
50 | };
51 |
--------------------------------------------------------------------------------
/tests/Pest.php:
--------------------------------------------------------------------------------
1 | in('Feature');
18 |
19 | /*
20 | |--------------------------------------------------------------------------
21 | | Expectations
22 | |--------------------------------------------------------------------------
23 | |
24 | | When you're writing tests, you often need to check that values meet certain conditions. The
25 | | "expect()" function gives you access to a set of "expectations" methods that you can use
26 | | to assert different things. Of course, you may extend the Expectation API at any time.
27 | |
28 | */
29 |
30 | expect()->extend('toBeOne', function () {
31 | return $this->toBe(1);
32 | });
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | Functions
37 | |--------------------------------------------------------------------------
38 | |
39 | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your
40 | | project that you don't want to repeat in every file. Here you can also expose helpers as
41 | | global functions to help you to reduce the number of lines of code in your test files.
42 | |
43 | */
44 |
45 | function something()
46 | {
47 | // ..
48 | }
49 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ProfileController.php:
--------------------------------------------------------------------------------
1 | $request->user() instanceof MustVerifyEmail,
23 | 'status' => session('status'),
24 | ]);
25 | }
26 |
27 | /**
28 | * Update the user's profile information.
29 | */
30 | public function update(ProfileUpdateRequest $request): RedirectResponse
31 | {
32 | $request->user()->fill($request->validated());
33 |
34 | if ($request->user()->isDirty('email')) {
35 | $request->user()->email_verified_at = null;
36 | }
37 |
38 | $request->user()->save();
39 |
40 | return Redirect::route('profile.edit');
41 | }
42 |
43 | /**
44 | * Delete the user's account.
45 | */
46 | public function destroy(Request $request): RedirectResponse
47 | {
48 | $request->validate([
49 | 'password' => ['required', 'current_password'],
50 | ]);
51 |
52 | $user = $request->user();
53 |
54 | Auth::logout();
55 |
56 | $user->delete();
57 |
58 | $request->session()->invalidate();
59 | $request->session()->regenerateToken();
60 |
61 | return Redirect::to('/');
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/tests/Feature/Auth/PasswordResetTest.php:
--------------------------------------------------------------------------------
1 | get('/forgot-password');
9 |
10 | $response->assertStatus(200);
11 | });
12 |
13 | test('reset password link can be requested', function () {
14 | Notification::fake();
15 |
16 | $user = User::factory()->create();
17 |
18 | $this->post('/forgot-password', ['email' => $user->email]);
19 |
20 | Notification::assertSentTo($user, ResetPassword::class);
21 | });
22 |
23 | test('reset password screen can be rendered', function () {
24 | Notification::fake();
25 |
26 | $user = User::factory()->create();
27 |
28 | $this->post('/forgot-password', ['email' => $user->email]);
29 |
30 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
31 | $response = $this->get('/reset-password/'.$notification->token);
32 |
33 | $response->assertStatus(200);
34 |
35 | return true;
36 | });
37 | });
38 |
39 | test('password can be reset with valid token', function () {
40 | Notification::fake();
41 |
42 | $user = User::factory()->create();
43 |
44 | $this->post('/forgot-password', ['email' => $user->email]);
45 |
46 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
47 | $response = $this->post('/reset-password', [
48 | 'token' => $notification->token,
49 | 'email' => $user->email,
50 | 'password' => 'password',
51 | 'password_confirmation' => 'password',
52 | ]);
53 |
54 | $response
55 | ->assertSessionHasNoErrors()
56 | ->assertRedirect(route('login'));
57 |
58 | return true;
59 | });
60 | });
61 |
--------------------------------------------------------------------------------
/database/seeders/ArticleSeeder.php:
--------------------------------------------------------------------------------
1 | get();
27 |
28 | foreach ($editors as $editor) {
29 | for ($i = 0; $i < 20; $i++) {
30 | if (empty($unique_pics)) {
31 | throw new \Exception('Ran out of unique images.');
32 | }
33 |
34 | $article = Article::factory()->make([
35 | 'article_image' => array_shift($unique_pics),
36 | 'user_id' => $editor->id,
37 | ]);
38 |
39 | $article->save();
40 | }
41 | }
42 |
43 | $chiefs = User::where('role', 'chief-editor')->get();
44 | foreach ($chiefs as $chief) {
45 | for ($i = 0; $i < 10; $i++) {
46 | if (empty($unique_pics)) {
47 | throw new \Exception('Ran out of unique images.');
48 | }
49 |
50 | $article = Article::factory()->make([
51 | 'article_image' => array_shift($unique_pics),
52 | 'user_id' => $chief->id,
53 | ]);
54 |
55 | $article->save();
56 | }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/resources/js/Pages/Auth/VerifyEmail.jsx:
--------------------------------------------------------------------------------
1 | import GuestLayout from '@/Layouts/GuestLayout';
2 | import PrimaryButton from '@/Components/PrimaryButton';
3 | import { Head, Link, useForm } from '@inertiajs/react';
4 |
5 | export default function VerifyEmail({ status }) {
6 | const { post, processing } = useForm({});
7 |
8 | const submit = (e) => {
9 | e.preventDefault();
10 |
11 | post(route('verification.send'));
12 | };
13 |
14 | return (
15 |
16 |
17 |
18 |
19 | Thanks for signing up! Before getting started, could you verify your email address by clicking on the
20 | link we just emailed to you? If you didn't receive the email, we will gladly send you another.
21 |
23 | Forgot your password? No problem. Just let us know your email address and we will email you a password
24 | reset link that will allow you to choose a new one.
25 |
52 | Once your account is deleted, all of its resources and data will be permanently deleted. Before
53 | deleting your account, please download any data or information that you wish to retain.
54 |
55 |
56 |
57 | Delete Account
58 |
59 |
60 |
96 |
97 |
98 | );
99 | }
100 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_MAILER', 'log'),
18 |
19 | /*
20 | |--------------------------------------------------------------------------
21 | | Mailer Configurations
22 | |--------------------------------------------------------------------------
23 | |
24 | | Here you may configure all of the mailers used by your application plus
25 | | their respective settings. Several examples have been configured for
26 | | you and you are free to add your own as your application requires.
27 | |
28 | | Laravel supports a variety of mail "transport" drivers that can be used
29 | | when delivering an email. You may specify which one you're using for
30 | | your mailers below. You may also add additional mailers if needed.
31 | |
32 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
33 | | "postmark", "resend", "log", "array",
34 | | "failover", "roundrobin"
35 | |
36 | */
37 |
38 | 'mailers' => [
39 |
40 | 'smtp' => [
41 | 'transport' => 'smtp',
42 | 'url' => env('MAIL_URL'),
43 | 'host' => env('MAIL_HOST', '127.0.0.1'),
44 | 'port' => env('MAIL_PORT', 2525),
45 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
46 | 'username' => env('MAIL_USERNAME'),
47 | 'password' => env('MAIL_PASSWORD'),
48 | 'timeout' => null,
49 | 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
50 | ],
51 |
52 | 'ses' => [
53 | 'transport' => 'ses',
54 | ],
55 |
56 | 'postmark' => [
57 | 'transport' => 'postmark',
58 | // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
59 | // 'client' => [
60 | // 'timeout' => 5,
61 | // ],
62 | ],
63 |
64 | 'resend' => [
65 | 'transport' => 'resend',
66 | ],
67 |
68 | 'sendmail' => [
69 | 'transport' => 'sendmail',
70 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
71 | ],
72 |
73 | 'log' => [
74 | 'transport' => 'log',
75 | 'channel' => env('MAIL_LOG_CHANNEL'),
76 | ],
77 |
78 | 'array' => [
79 | 'transport' => 'array',
80 | ],
81 |
82 | 'failover' => [
83 | 'transport' => 'failover',
84 | 'mailers' => [
85 | 'smtp',
86 | 'log',
87 | ],
88 | ],
89 |
90 | 'roundrobin' => [
91 | 'transport' => 'roundrobin',
92 | 'mailers' => [
93 | 'ses',
94 | 'postmark',
95 | ],
96 | ],
97 |
98 | ],
99 |
100 | /*
101 | |--------------------------------------------------------------------------
102 | | Global "From" Address
103 | |--------------------------------------------------------------------------
104 | |
105 | | You may wish for all emails sent by your application to be sent from
106 | | the same address. Here you may specify a name and address that is
107 | | used globally for all emails that are sent by your application.
108 | |
109 | */
110 |
111 | 'from' => [
112 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
113 | 'name' => env('MAIL_FROM_NAME', 'Example'),
114 | ],
115 |
116 | ];
117 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | ## About Laravel
11 |
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:
13 |
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).
21 |
22 | Laravel is accessible, powerful, and provides tools required for large, robust applications.
23 |
24 | ## Learning Laravel
25 |
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.
27 |
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.
29 |
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.
31 |
32 | ## Laravel Sponsors
33 |
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 [taylor@laravel.com](mailto:taylor@laravel.com). 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).
67 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'database'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Queue Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure the connection options for every queue backend
24 | | used by your application. An example configuration is provided for
25 | | each backend supported by Laravel. You're also free to add more.
26 | |
27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'connection' => env('DB_QUEUE_CONNECTION'),
40 | 'table' => env('DB_QUEUE_TABLE', 'jobs'),
41 | 'queue' => env('DB_QUEUE', 'default'),
42 | 'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
43 | 'after_commit' => false,
44 | ],
45 |
46 | 'beanstalkd' => [
47 | 'driver' => 'beanstalkd',
48 | 'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
49 | 'queue' => env('BEANSTALKD_QUEUE', 'default'),
50 | 'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
51 | 'block_for' => 0,
52 | 'after_commit' => false,
53 | ],
54 |
55 | 'sqs' => [
56 | 'driver' => 'sqs',
57 | 'key' => env('AWS_ACCESS_KEY_ID'),
58 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
59 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
60 | 'queue' => env('SQS_QUEUE', 'default'),
61 | 'suffix' => env('SQS_SUFFIX'),
62 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
63 | 'after_commit' => false,
64 | ],
65 |
66 | 'redis' => [
67 | 'driver' => 'redis',
68 | 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
69 | 'queue' => env('REDIS_QUEUE', 'default'),
70 | 'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
71 | 'block_for' => null,
72 | 'after_commit' => false,
73 | ],
74 |
75 | ],
76 |
77 | /*
78 | |--------------------------------------------------------------------------
79 | | Job Batching
80 | |--------------------------------------------------------------------------
81 | |
82 | | The following options configure the database and table that store job
83 | | batching information. These options can be updated to any database
84 | | connection and table which has been defined by your application.
85 | |
86 | */
87 |
88 | 'batching' => [
89 | 'database' => env('DB_CONNECTION', 'sqlite'),
90 | 'table' => 'job_batches',
91 | ],
92 |
93 | /*
94 | |--------------------------------------------------------------------------
95 | | Failed Queue Jobs
96 | |--------------------------------------------------------------------------
97 | |
98 | | These options configure the behavior of failed queue job logging so you
99 | | can control how and where failed jobs are stored. Laravel ships with
100 | | support for storing failed jobs in a simple file or in a database.
101 | |
102 | | Supported drivers: "database-uuids", "dynamodb", "file", "null"
103 | |
104 | */
105 |
106 | 'failed' => [
107 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
108 | 'database' => env('DB_CONNECTION', 'sqlite'),
109 | 'table' => 'failed_jobs',
110 | ],
111 |
112 | ];
113 |
--------------------------------------------------------------------------------
/resources/js/Pages/Profile/Partials/UpdateProfileInformationForm.jsx:
--------------------------------------------------------------------------------
1 | import InputError from '@/Components/InputError';
2 | import InputLabel from '@/Components/InputLabel';
3 | import PrimaryButton from '@/Components/PrimaryButton';
4 | import TextInput from '@/Components/TextInput';
5 | import { Link, useForm, usePage } from '@inertiajs/react';
6 | import { Transition } from '@headlessui/react';
7 |
8 | export default function UpdateProfileInformation({ mustVerifyEmail, status, className = '' }) {
9 | const user = usePage().props.auth.user;
10 |
11 | const { data, setData, patch, errors, processing, recentlySuccessful } = useForm({
12 | name: user.name,
13 | email: user.email,
14 | });
15 |
16 | const submit = (e) => {
17 | e.preventDefault();
18 |
19 | patch(route('profile.update'));
20 | };
21 |
22 | return (
23 |
24 |
25 |
Profile Information
26 |
27 |
28 | Update your account's profile information and email address.
29 |
30 |
31 |
32 |
101 |
102 | );
103 | }
104 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => env('AUTH_GUARD', 'web'),
18 | 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | which utilizes session storage plus the Eloquent user provider.
29 | |
30 | | All authentication guards have a user provider, which defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | system used by the application. Typically, Eloquent is utilized.
33 | |
34 | | Supported: "session"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 | ],
44 |
45 | /*
46 | |--------------------------------------------------------------------------
47 | | User Providers
48 | |--------------------------------------------------------------------------
49 | |
50 | | All authentication guards have a user provider, which defines how the
51 | | users are actually retrieved out of your database or other storage
52 | | system used by the application. Typically, Eloquent is utilized.
53 | |
54 | | If you have multiple user tables or models you may configure multiple
55 | | providers to represent the model / table. These providers may then
56 | | be assigned to any extra authentication guards you have defined.
57 | |
58 | | Supported: "database", "eloquent"
59 | |
60 | */
61 |
62 | 'providers' => [
63 | 'users' => [
64 | 'driver' => 'eloquent',
65 | 'model' => env('AUTH_MODEL', App\Models\User::class),
66 | ],
67 |
68 | // 'users' => [
69 | // 'driver' => 'database',
70 | // 'table' => 'users',
71 | // ],
72 | ],
73 |
74 | /*
75 | |--------------------------------------------------------------------------
76 | | Resetting Passwords
77 | |--------------------------------------------------------------------------
78 | |
79 | | These configuration options specify the behavior of Laravel's password
80 | | reset functionality, including the table utilized for token storage
81 | | and the user provider that is invoked to actually retrieve users.
82 | |
83 | | The expiry time is the number of minutes that each reset token will be
84 | | considered valid. This security feature keeps tokens short-lived so
85 | | they have less time to be guessed. You may change this as needed.
86 | |
87 | | The throttle setting is the number of seconds a user must wait before
88 | | generating more password reset tokens. This prevents the user from
89 | | quickly generating a very large amount of password reset tokens.
90 | |
91 | */
92 |
93 | 'passwords' => [
94 | 'users' => [
95 | 'provider' => 'users',
96 | 'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
97 | 'expire' => 60,
98 | 'throttle' => 60,
99 | ],
100 | ],
101 |
102 | /*
103 | |--------------------------------------------------------------------------
104 | | Password Confirmation Timeout
105 | |--------------------------------------------------------------------------
106 | |
107 | | Here you may define the amount of seconds before a password confirmation
108 | | window expires and users are asked to re-enter their password via the
109 | | confirmation screen. By default, the timeout lasts for three hours.
110 | |
111 | */
112 |
113 | 'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
114 |
115 | ];
116 |
--------------------------------------------------------------------------------
/resources/js/Pages/Auth/Register.jsx:
--------------------------------------------------------------------------------
1 | import { useEffect } from 'react';
2 | import GuestLayout from '@/Layouts/GuestLayout';
3 | import InputError from '@/Components/InputError';
4 | import InputLabel from '@/Components/InputLabel';
5 | import PrimaryButton from '@/Components/PrimaryButton';
6 | import TextInput from '@/Components/TextInput';
7 | import { Head, Link, useForm } from '@inertiajs/react';
8 |
9 | export default function Register() {
10 | const { data, setData, post, processing, errors, reset } = useForm({
11 | name: '',
12 | email: '',
13 | password: '',
14 | password_confirmation: '',
15 | });
16 |
17 | useEffect(() => {
18 | return () => {
19 | reset('password', 'password_confirmation');
20 | };
21 | }, []);
22 |
23 | const submit = (e) => {
24 | e.preventDefault();
25 |
26 | post(route('register'));
27 | };
28 |
29 | return (
30 |
31 |
32 |
33 |
115 |
116 | );
117 | }
118 |
--------------------------------------------------------------------------------
/resources/js/Pages/Profile/Partials/UpdatePasswordForm.jsx:
--------------------------------------------------------------------------------
1 | import { useRef } from 'react';
2 | import InputError from '@/Components/InputError';
3 | import InputLabel from '@/Components/InputLabel';
4 | import PrimaryButton from '@/Components/PrimaryButton';
5 | import TextInput from '@/Components/TextInput';
6 | import { useForm } from '@inertiajs/react';
7 | import { Transition } from '@headlessui/react';
8 |
9 | export default function UpdatePasswordForm({ className = '' }) {
10 | const passwordInput = useRef();
11 | const currentPasswordInput = useRef();
12 |
13 | const { data, setData, errors, put, reset, processing, recentlySuccessful } = useForm({
14 | current_password: '',
15 | password: '',
16 | password_confirmation: '',
17 | });
18 |
19 | const updatePassword = (e) => {
20 | e.preventDefault();
21 |
22 | put(route('password.update'), {
23 | preserveScroll: true,
24 | onSuccess: () => reset(),
25 | onError: (errors) => {
26 | if (errors.password) {
27 | reset('password', 'password_confirmation');
28 | passwordInput.current.focus();
29 | }
30 |
31 | if (errors.current_password) {
32 | reset('current_password');
33 | currentPasswordInput.current.focus();
34 | }
35 | },
36 | });
37 | };
38 |
39 | return (
40 |
41 |
42 |
Update Password
43 |
44 |
45 | Ensure your account is using a long, random password to stay secure.
46 |
47 |
48 |
49 |
111 |
112 | );
113 | }
114 |
--------------------------------------------------------------------------------
/config/app.php:
--------------------------------------------------------------------------------
1 | env('APP_NAME', 'Laravel'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Application Environment
21 | |--------------------------------------------------------------------------
22 | |
23 | | This value determines the "environment" your application is currently
24 | | running in. This may determine how you prefer to configure various
25 | | services the application utilizes. Set this in your ".env" file.
26 | |
27 | */
28 |
29 | 'env' => env('APP_ENV', 'production'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Application Debug Mode
34 | |--------------------------------------------------------------------------
35 | |
36 | | When your application is in debug mode, detailed error messages with
37 | | stack traces will be shown on every error that occurs within your
38 | | application. If disabled, a simple generic error page is shown.
39 | |
40 | */
41 |
42 | 'debug' => (bool) env('APP_DEBUG', false),
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Application URL
47 | |--------------------------------------------------------------------------
48 | |
49 | | This URL is used by the console to properly generate URLs when using
50 | | the Artisan command line tool. You should set this to the root of
51 | | the application so that it's available within Artisan commands.
52 | |
53 | */
54 |
55 | 'url' => env('APP_URL', 'http://localhost'),
56 |
57 | /*
58 | |--------------------------------------------------------------------------
59 | | Application Timezone
60 | |--------------------------------------------------------------------------
61 | |
62 | | Here you may specify the default timezone for your application, which
63 | | will be used by the PHP date and date-time functions. The timezone
64 | | is set to "UTC" by default as it is suitable for most use cases.
65 | |
66 | */
67 |
68 | 'timezone' => env('APP_TIMEZONE', 'UTC'),
69 |
70 | /*
71 | |--------------------------------------------------------------------------
72 | | Application Locale Configuration
73 | |--------------------------------------------------------------------------
74 | |
75 | | The application locale determines the default locale that will be used
76 | | by Laravel's translation / localization methods. This option can be
77 | | set to any locale for which you plan to have translation strings.
78 | |
79 | */
80 |
81 | 'locale' => env('APP_LOCALE', 'en'),
82 |
83 | 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
84 |
85 | 'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
86 |
87 | /*
88 | |--------------------------------------------------------------------------
89 | | Encryption Key
90 | |--------------------------------------------------------------------------
91 | |
92 | | This key is utilized by Laravel's encryption services and should be set
93 | | to a random, 32 character string to ensure that all encrypted values
94 | | are secure. You should do this prior to deploying the application.
95 | |
96 | */
97 |
98 | 'cipher' => 'AES-256-CBC',
99 |
100 | 'key' => env('APP_KEY'),
101 |
102 | 'previous_keys' => [
103 | ...array_filter(
104 | explode(',', env('APP_PREVIOUS_KEYS', ''))
105 | ),
106 | ],
107 |
108 | /*
109 | |--------------------------------------------------------------------------
110 | | Maintenance Mode Driver
111 | |--------------------------------------------------------------------------
112 | |
113 | | These configuration options determine the driver used to determine and
114 | | manage Laravel's "maintenance mode" status. The "cache" driver will
115 | | allow maintenance mode to be controlled across multiple machines.
116 | |
117 | | Supported drivers: "file", "cache"
118 | |
119 | */
120 |
121 | 'maintenance' => [
122 | 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
123 | 'store' => env('APP_MAINTENANCE_STORE', 'database'),
124 | ],
125 |
126 | ];
127 |
--------------------------------------------------------------------------------
/config/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Deprecations Log Channel
26 | |--------------------------------------------------------------------------
27 | |
28 | | This option controls the log channel that should be used to log warnings
29 | | regarding deprecated PHP and library features. This allows you to get
30 | | your application ready for upcoming major versions of dependencies.
31 | |
32 | */
33 |
34 | 'deprecations' => [
35 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
36 | 'trace' => env('LOG_DEPRECATIONS_TRACE', false),
37 | ],
38 |
39 | /*
40 | |--------------------------------------------------------------------------
41 | | Log Channels
42 | |--------------------------------------------------------------------------
43 | |
44 | | Here you may configure the log channels for your application. Laravel
45 | | utilizes the Monolog PHP logging library, which includes a variety
46 | | of powerful log handlers and formatters that you're free to use.
47 | |
48 | | Available Drivers: "single", "daily", "slack", "syslog",
49 | | "errorlog", "monolog", "custom", "stack"
50 | |
51 | */
52 |
53 | 'channels' => [
54 |
55 | 'stack' => [
56 | 'driver' => 'stack',
57 | 'channels' => explode(',', env('LOG_STACK', 'single')),
58 | 'ignore_exceptions' => false,
59 | ],
60 |
61 | 'single' => [
62 | 'driver' => 'single',
63 | 'path' => storage_path('logs/laravel.log'),
64 | 'level' => env('LOG_LEVEL', 'debug'),
65 | 'replace_placeholders' => true,
66 | ],
67 |
68 | 'daily' => [
69 | 'driver' => 'daily',
70 | 'path' => storage_path('logs/laravel.log'),
71 | 'level' => env('LOG_LEVEL', 'debug'),
72 | 'days' => env('LOG_DAILY_DAYS', 14),
73 | 'replace_placeholders' => true,
74 | ],
75 |
76 | 'slack' => [
77 | 'driver' => 'slack',
78 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
79 | 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
80 | 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
81 | 'level' => env('LOG_LEVEL', 'critical'),
82 | 'replace_placeholders' => true,
83 | ],
84 |
85 | 'papertrail' => [
86 | 'driver' => 'monolog',
87 | 'level' => env('LOG_LEVEL', 'debug'),
88 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
89 | 'handler_with' => [
90 | 'host' => env('PAPERTRAIL_URL'),
91 | 'port' => env('PAPERTRAIL_PORT'),
92 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
93 | ],
94 | 'processors' => [PsrLogMessageProcessor::class],
95 | ],
96 |
97 | 'stderr' => [
98 | 'driver' => 'monolog',
99 | 'level' => env('LOG_LEVEL', 'debug'),
100 | 'handler' => StreamHandler::class,
101 | 'formatter' => env('LOG_STDERR_FORMATTER'),
102 | 'with' => [
103 | 'stream' => 'php://stderr',
104 | ],
105 | 'processors' => [PsrLogMessageProcessor::class],
106 | ],
107 |
108 | 'syslog' => [
109 | 'driver' => 'syslog',
110 | 'level' => env('LOG_LEVEL', 'debug'),
111 | 'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
112 | 'replace_placeholders' => true,
113 | ],
114 |
115 | 'errorlog' => [
116 | 'driver' => 'errorlog',
117 | 'level' => env('LOG_LEVEL', 'debug'),
118 | 'replace_placeholders' => true,
119 | ],
120 |
121 | 'null' => [
122 | 'driver' => 'monolog',
123 | 'handler' => NullHandler::class,
124 | ],
125 |
126 | 'emergency' => [
127 | 'path' => storage_path('logs/laravel.log'),
128 | ],
129 |
130 | ],
131 |
132 | ];
133 |
--------------------------------------------------------------------------------
/resources/js/Components/DeleteNotification.jsx:
--------------------------------------------------------------------------------
1 | import { useForm } from '@inertiajs/react'
2 | import {
3 | Button,
4 | Card,
5 | CardHeader,
6 | CardBody,
7 | CardFooter,
8 | Image
9 | } from '@nextui-org/react'
10 | import { useEffect, useState } from 'react'
11 | import ThumbsUp from './ThumbsUp'
12 |
13 | const DeleteNotification = ({ editor, entity, closeNotif }) => {
14 | const { delete: destroy } = useForm({ id: entity.article.id })
15 | const [timeoutId, setTimeoutId] = useState(null)
16 | const duration = 6000
17 |
18 | useEffect(() => {
19 | // Clear any existing timeout
20 | if (timeoutId) {
21 | clearTimeout(timeoutId)
22 | }
23 | // Start a new timeout
24 | const newTimeoutId = setTimeout(() => {
25 | closeNotif(entity.article)
26 | }, duration)
27 |
28 | setTimeoutId(newTimeoutId)
29 |
30 | return () => {
31 | if (timeoutId) {
32 | clearTimeout(timeoutId)
33 | }
34 | }
35 | }, [])
36 |
37 | // Handle the delete approval request.
38 | const handleApproveDelete = () => {
39 | destroy(route('article.destroy'), {
40 | preserveScroll: true,
41 | onSuccess: () => closeNotif(entity.article)
42 | })
43 | }
44 |
45 | // Stop the timer on mouse enter
46 | const handleMouseEnter = () => {
47 | if (timeoutId) {
48 | clearTimeout(timeoutId)
49 | }
50 | }
51 |
52 | // Restart the timer after mouse leave
53 | const handleMouseLeave = () => {
54 | const newTimeoutId = setTimeout(() => {
55 | closeNotif(entity)
56 | }, duration)
57 |
58 | setTimeoutId(newTimeoutId)
59 | }
60 |
61 | return (
62 |
68 |
69 |
70 |
71 |
72 | Someone has requested to delete an article
73 |
74 |
75 |
76 |
101 |
102 |
103 |
104 | {editor.name} has
105 | requsted to delete the article{' '}
106 | {entity.article.title}.
107 |
115 | Do you want to allow this?
116 |
117 |
118 |
119 |
128 |
131 |
132 |
133 | )
134 | }
135 |
136 | export default DeleteNotification
137 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'sqlite'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Database Connections
24 | |--------------------------------------------------------------------------
25 | |
26 | | Below are all of the database connections defined for your application.
27 | | An example configuration is provided for each database system which
28 | | is supported by Laravel. You're free to add / remove connections.
29 | |
30 | */
31 |
32 | 'connections' => [
33 |
34 | 'sqlite' => [
35 | 'driver' => 'sqlite',
36 | 'url' => env('DB_URL'),
37 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
38 | 'prefix' => '',
39 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
40 | ],
41 |
42 | 'mysql' => [
43 | 'driver' => 'mysql',
44 | 'url' => env('DB_URL'),
45 | 'host' => env('DB_HOST', '127.0.0.1'),
46 | 'port' => env('DB_PORT', '3306'),
47 | 'database' => env('DB_DATABASE', 'laravel'),
48 | 'username' => env('DB_USERNAME', 'root'),
49 | 'password' => env('DB_PASSWORD', ''),
50 | 'unix_socket' => env('DB_SOCKET', ''),
51 | 'charset' => env('DB_CHARSET', 'utf8mb4'),
52 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
53 | 'prefix' => '',
54 | 'prefix_indexes' => true,
55 | 'strict' => true,
56 | 'engine' => null,
57 | 'options' => extension_loaded('pdo_mysql') ? array_filter([
58 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
59 | ]) : [],
60 | ],
61 |
62 | 'mariadb' => [
63 | 'driver' => 'mariadb',
64 | 'url' => env('DB_URL'),
65 | 'host' => env('DB_HOST', '127.0.0.1'),
66 | 'port' => env('DB_PORT', '3306'),
67 | 'database' => env('DB_DATABASE', 'laravel'),
68 | 'username' => env('DB_USERNAME', 'root'),
69 | 'password' => env('DB_PASSWORD', ''),
70 | 'unix_socket' => env('DB_SOCKET', ''),
71 | 'charset' => env('DB_CHARSET', 'utf8mb4'),
72 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
73 | 'prefix' => '',
74 | 'prefix_indexes' => true,
75 | 'strict' => true,
76 | 'engine' => null,
77 | 'options' => extension_loaded('pdo_mysql') ? array_filter([
78 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
79 | ]) : [],
80 | ],
81 |
82 | 'pgsql' => [
83 | 'driver' => 'pgsql',
84 | 'url' => env('DB_URL'),
85 | 'host' => env('DB_HOST', '127.0.0.1'),
86 | 'port' => env('DB_PORT', '5432'),
87 | 'database' => env('DB_DATABASE', 'laravel'),
88 | 'username' => env('DB_USERNAME', 'root'),
89 | 'password' => env('DB_PASSWORD', ''),
90 | 'charset' => env('DB_CHARSET', 'utf8'),
91 | 'prefix' => '',
92 | 'prefix_indexes' => true,
93 | 'search_path' => 'public',
94 | 'sslmode' => 'prefer',
95 | ],
96 |
97 | 'sqlsrv' => [
98 | 'driver' => 'sqlsrv',
99 | 'url' => env('DB_URL'),
100 | 'host' => env('DB_HOST', 'localhost'),
101 | 'port' => env('DB_PORT', '1433'),
102 | 'database' => env('DB_DATABASE', 'laravel'),
103 | 'username' => env('DB_USERNAME', 'root'),
104 | 'password' => env('DB_PASSWORD', ''),
105 | 'charset' => env('DB_CHARSET', 'utf8'),
106 | 'prefix' => '',
107 | 'prefix_indexes' => true,
108 | // 'encrypt' => env('DB_ENCRYPT', 'yes'),
109 | // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
110 | ],
111 |
112 | ],
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Migration Repository Table
117 | |--------------------------------------------------------------------------
118 | |
119 | | This table keeps track of all the migrations that have already run for
120 | | your application. Using this information, we can determine which of
121 | | the migrations on disk haven't actually been run on the database.
122 | |
123 | */
124 |
125 | 'migrations' => [
126 | 'table' => 'migrations',
127 | 'update_date_on_publish' => true,
128 | ],
129 |
130 | /*
131 | |--------------------------------------------------------------------------
132 | | Redis Databases
133 | |--------------------------------------------------------------------------
134 | |
135 | | Redis is an open source, fast, and advanced key-value store that also
136 | | provides a richer body of commands than a typical key-value system
137 | | such as Memcached. You may define your connection settings here.
138 | |
139 | */
140 |
141 | 'redis' => [
142 |
143 | 'client' => env('REDIS_CLIENT', 'phpredis'),
144 |
145 | 'options' => [
146 | 'cluster' => env('REDIS_CLUSTER', 'redis'),
147 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
148 | ],
149 |
150 | 'default' => [
151 | 'url' => env('REDIS_URL'),
152 | 'host' => env('REDIS_HOST', '127.0.0.1'),
153 | 'username' => env('REDIS_USERNAME'),
154 | 'password' => env('REDIS_PASSWORD'),
155 | 'port' => env('REDIS_PORT', '6379'),
156 | 'database' => env('REDIS_DB', '0'),
157 | ],
158 |
159 | 'cache' => [
160 | 'url' => env('REDIS_URL'),
161 | 'host' => env('REDIS_HOST', '127.0.0.1'),
162 | 'username' => env('REDIS_USERNAME'),
163 | 'password' => env('REDIS_PASSWORD'),
164 | 'port' => env('REDIS_PORT', '6379'),
165 | 'database' => env('REDIS_CACHE_DB', '1'),
166 | ],
167 |
168 | ],
169 |
170 | ];
171 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'database'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Session Lifetime
26 | |--------------------------------------------------------------------------
27 | |
28 | | Here you may specify the number of minutes that you wish the session
29 | | to be allowed to remain idle before it expires. If you want them
30 | | to expire immediately when the browser is closed then you may
31 | | indicate that via the expire_on_close configuration option.
32 | |
33 | */
34 |
35 | 'lifetime' => env('SESSION_LIFETIME', 120),
36 |
37 | 'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
38 |
39 | /*
40 | |--------------------------------------------------------------------------
41 | | Session Encryption
42 | |--------------------------------------------------------------------------
43 | |
44 | | This option allows you to easily specify that all of your session data
45 | | should be encrypted before it's stored. All encryption is performed
46 | | automatically by Laravel and you may use the session like normal.
47 | |
48 | */
49 |
50 | 'encrypt' => env('SESSION_ENCRYPT', false),
51 |
52 | /*
53 | |--------------------------------------------------------------------------
54 | | Session File Location
55 | |--------------------------------------------------------------------------
56 | |
57 | | When utilizing the "file" session driver, the session files are placed
58 | | on disk. The default storage location is defined here; however, you
59 | | are free to provide another location where they should be stored.
60 | |
61 | */
62 |
63 | 'files' => storage_path('framework/sessions'),
64 |
65 | /*
66 | |--------------------------------------------------------------------------
67 | | Session Database Connection
68 | |--------------------------------------------------------------------------
69 | |
70 | | When using the "database" or "redis" session drivers, you may specify a
71 | | connection that should be used to manage these sessions. This should
72 | | correspond to a connection in your database configuration options.
73 | |
74 | */
75 |
76 | 'connection' => env('SESSION_CONNECTION'),
77 |
78 | /*
79 | |--------------------------------------------------------------------------
80 | | Session Database Table
81 | |--------------------------------------------------------------------------
82 | |
83 | | When using the "database" session driver, you may specify the table to
84 | | be used to store sessions. Of course, a sensible default is defined
85 | | for you; however, you're welcome to change this to another table.
86 | |
87 | */
88 |
89 | 'table' => env('SESSION_TABLE', 'sessions'),
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Session Cache Store
94 | |--------------------------------------------------------------------------
95 | |
96 | | When using one of the framework's cache driven session backends, you may
97 | | define the cache store which should be used to store the session data
98 | | between requests. This must match one of your defined cache stores.
99 | |
100 | | Affects: "apc", "dynamodb", "memcached", "redis"
101 | |
102 | */
103 |
104 | 'store' => env('SESSION_STORE'),
105 |
106 | /*
107 | |--------------------------------------------------------------------------
108 | | Session Sweeping Lottery
109 | |--------------------------------------------------------------------------
110 | |
111 | | Some session drivers must manually sweep their storage location to get
112 | | rid of old sessions from storage. Here are the chances that it will
113 | | happen on a given request. By default, the odds are 2 out of 100.
114 | |
115 | */
116 |
117 | 'lottery' => [2, 100],
118 |
119 | /*
120 | |--------------------------------------------------------------------------
121 | | Session Cookie Name
122 | |--------------------------------------------------------------------------
123 | |
124 | | Here you may change the name of the session cookie that is created by
125 | | the framework. Typically, you should not need to change this value
126 | | since doing so does not grant a meaningful security improvement.
127 | |
128 | */
129 |
130 | 'cookie' => env(
131 | 'SESSION_COOKIE',
132 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
133 | ),
134 |
135 | /*
136 | |--------------------------------------------------------------------------
137 | | Session Cookie Path
138 | |--------------------------------------------------------------------------
139 | |
140 | | The session cookie path determines the path for which the cookie will
141 | | be regarded as available. Typically, this will be the root path of
142 | | your application, but you're free to change this when necessary.
143 | |
144 | */
145 |
146 | 'path' => env('SESSION_PATH', '/'),
147 |
148 | /*
149 | |--------------------------------------------------------------------------
150 | | Session Cookie Domain
151 | |--------------------------------------------------------------------------
152 | |
153 | | This value determines the domain and subdomains the session cookie is
154 | | available to. By default, the cookie will be available to the root
155 | | domain and all subdomains. Typically, this shouldn't be changed.
156 | |
157 | */
158 |
159 | 'domain' => env('SESSION_DOMAIN'),
160 |
161 | /*
162 | |--------------------------------------------------------------------------
163 | | HTTPS Only Cookies
164 | |--------------------------------------------------------------------------
165 | |
166 | | By setting this option to true, session cookies will only be sent back
167 | | to the server if the browser has a HTTPS connection. This will keep
168 | | the cookie from being sent to you when it can't be done securely.
169 | |
170 | */
171 |
172 | 'secure' => env('SESSION_SECURE_COOKIE'),
173 |
174 | /*
175 | |--------------------------------------------------------------------------
176 | | HTTP Access Only
177 | |--------------------------------------------------------------------------
178 | |
179 | | Setting this value to true will prevent JavaScript from accessing the
180 | | value of the cookie and the cookie will only be accessible through
181 | | the HTTP protocol. It's unlikely you should disable this option.
182 | |
183 | */
184 |
185 | 'http_only' => env('SESSION_HTTP_ONLY', true),
186 |
187 | /*
188 | |--------------------------------------------------------------------------
189 | | Same-Site Cookies
190 | |--------------------------------------------------------------------------
191 | |
192 | | This option determines how your cookies behave when cross-site requests
193 | | take place, and can be used to mitigate CSRF attacks. By default, we
194 | | will set this value to "lax" to permit secure cross-site requests.
195 | |
196 | | See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
197 | |
198 | | Supported: "lax", "strict", "none", null
199 | |
200 | */
201 |
202 | 'same_site' => env('SESSION_SAME_SITE', 'lax'),
203 |
204 | /*
205 | |--------------------------------------------------------------------------
206 | | Partitioned Cookies
207 | |--------------------------------------------------------------------------
208 | |
209 | | Setting this value to true will tie the cookie to the top-level site for
210 | | a cross-site context. Partitioned cookies are accepted by the browser
211 | | when flagged "secure" and the Same-Site attribute is set to "none".
212 | |
213 | */
214 |
215 | 'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
216 |
217 | ];
218 |
--------------------------------------------------------------------------------
/resources/js/Pages/Dashboard.jsx:
--------------------------------------------------------------------------------
1 | import DeleteIcon from '@/Components/DeleteIcon'
2 | import Notification from '@/Components/Notification'
3 | import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
4 | import { Head, router } from '@inertiajs/react'
5 | import {
6 | Card,
7 | CardHeader,
8 | CardBody,
9 | Image,
10 | Link,
11 | CardFooter,
12 | Button
13 | } from '@nextui-org/react'
14 | import { AnimatePresence, motion } from 'framer-motion'
15 | import { useState } from 'react'
16 |
17 | export default function Dashboard({ auth, articles }) {
18 | const [articleList, setArticleList] = useState(articles)
19 | const [notifications, setNotifications] = useState([])
20 |
21 | const notifAnimation = {
22 | hidden: { opacity: 0, x: '100%' },
23 | visible: { opacity: 1, x: 0 },
24 | exit: { opacity: 0, x: '100%' }
25 | }
26 |
27 | const notifCardAnimation = {
28 | hidden: { opacity: 0 },
29 | visible: { opacity: 1 },
30 | exit: { opacity: 0 }
31 | }
32 |
33 | const handleDelete = article => {
34 | router.post(
35 | 'delete-article-request/',
36 | {
37 | id: article.id,
38 | user_id: auth.user.id
39 | },
40 | {
41 | preserveScroll: true
42 | }
43 | )
44 |
45 | setNotifications(prevNotifs => [...prevNotifs, article])
46 | }
47 |
48 | // Handle the simple pagination navigation.
49 | const handlePageChange = url => {
50 | if (url) {
51 | router.get(url)
52 | }
53 | }
54 |
55 | const handleCloseNotif = article => {
56 | setNotifications(prevNotifs =>
57 | prevNotifs.filter(notif => notif.id !== article.id)
58 | )
59 | }
60 |
61 | const handleRemoveArticle = id => {
62 | setArticleList(prevArticleList => ({
63 | ...prevArticleList,
64 | data: prevArticleList.data.filter(item => item.id !== id)
65 | }))
66 | }
67 |
68 | return (
69 |
73 | {auth.user.role === 'chief-editor'
74 | ? 'The Glorified Chief 🤴🏼'
75 | : 'The Guy Who Do Most of the Work 😩'}
76 |
77 | }
78 | removeArticle={handleRemoveArticle}
79 | >
80 |
81 |
82 |