Skip to content

Commit

Permalink
Merge pull request UnlockedLabs#32 from PThorpe92/cleanup
Browse files Browse the repository at this point in the history
feat: remove unnecessary pages + controller for auth, remove registration UN-209
  • Loading branch information
nokierae authored Dec 15, 2023
2 parents 1f2fbb8 + cb366bb commit b4c7b10
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 180 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@ The commands below assume you have a shell alias setup in your .bashrc or .zshrc
- Copy ‘.env.example’ to ‘.env’
- Run `composer install`
- Run `sail up`
- Run `sail artisan migrate`
- Run `sail artisan migrate:fresh --seed`
- Run `sail npm install`
- Run `sail npm run dev`
- Run `sail artisan db:seed --class=DefaultAdmin`
- Open http://localhost
- Login with `SuperAdmin` and password: `ChangeMe!`
- You will be prompted immediately to set a new password, and then you will be redirected to the dashboard.

#### NOTE:

- Run `sail artisan db:seed` to seed the database with test data for local development.
- Run `sail artisan db:seed --class=TestSeeder` to seed the database with test data for local UI development if you need tables populated with fake data.

## Style/Linting

- PHP: Run `./vendor/bin/pint` or adjust your editor to run it on save.
- TS: Run `npx prettier -w .` before committing, or adjust your editor to run it on save.

#### These commands _will_ run automatically before each commit, so you technically don't have to worry about it
#### These commands _will_ run automatically in a git hook before each commit, so you technically don't have to worry about it but if you run them beforehand, you will most likely not need to re-stage and amend your commit with the fixes will make. IF for some reason you need to skip the hooks, you can run `git commit --no-verify`but do not do this unless you know what you are doing and you understand the CI/CD will fail if you do.

# FAQ:

**Why is Mysql not starting properly:** (Sail)
**Why is Mysql not starting properly?:** (Sail)

- While still running `sail up` in the background, open a new terminal and run `docker-compose down --volumes`, then after it fully shuts down, run `./vendor/bin/sail up --build`

- Make sure you have a `.env` file in the root directory. In my environment, I have to have a `.env` with the DB_HOST set to the `IP` I get after running `docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' unlockedv2_mysql_1` (if `unlockedv2_mysql_1` is the name of the mysql container)
- Make sure you have a `.env` file in the root directory. In my environment, I have to have a `.env` with the DB_HOST set to the `IP` I get after running `docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' unlockedv2_mysql_1` (if `unlockedv2_mysql_1` is the name of the mysql container, you can find this out by running `docker ps`)

**Content isn't displaying, or the page is blank or receiving 500 errors?** (Sail)
**Why is the content not displaying, or the page is blank or receiving 500 errors?** (Sail)

_This could be any one of the following, or a combination_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,9 @@
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Inertia\Response;

class PasswordResetLinkController extends Controller
class StudentNewPasswordController extends Controller
{
/**
* Display the password reset link request view.
*/
public function create(): Response
{
return Inertia::render('Auth/ForgotPassword', [
'status' => session('status'),
]);
}

/**
* Handle an incoming password reset request
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations
*/
public function up(): void
{
Schema::table('password_reset_tokens', function (Blueprint $table) {
$table->drop();
});
}

/**
* Reverse the migrations
*/
public function down(): void
{
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
};

This file was deleted.

2 changes: 2 additions & 0 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// use Illuminate\Database\Console\Seeds\WithoutModelEvents;

use App\Enums\UserRole;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

Expand All @@ -22,6 +23,7 @@ public function run(): void
'username' => 'SuperAdmin',
'password' => bcrypt('ChangeMe!'),
'password_reset' => true,
'role' => UserRole::Admin,
]);
DB::table('categories')->insert([
'name' => 'Unlocked Labs',
Expand Down
2 changes: 2 additions & 0 deletions database/seeders/DefaultAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Database\Seeders;

use App\Enums\UserRole;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

Expand All @@ -19,6 +20,7 @@ public function run(): void
'username' => 'SuperAdmin',
'password' => bcrypt('ChangeMe!'),
'password_reset' => true,
'role' => UserRole::Admin,
]);
}
}
19 changes: 19 additions & 0 deletions database/seeders/TestSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Database\Seeders;

use App\Models\ProviderPlatform;
use App\Models\User;
use Illuminate\Database\Seeder;

class TestSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
User::factory()->create(10);
ProviderPlatform::factory()->create(10);
}
}
56 changes: 0 additions & 56 deletions resources/js/Pages/Auth/ForgotPassword.tsx

This file was deleted.

66 changes: 8 additions & 58 deletions resources/js/Pages/Auth/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@ export default function Register() {
name_first: "",
name_last: "",
username: "",
password: "",
password_confirmation: "",
});

useEffect(() => {
return () => {
reset("password", "password_confirmation");
};
reset("username", "name_first", "name_last");
}, []);

const submit: FormEventHandler = (e) => {
Expand All @@ -29,11 +24,11 @@ export default function Register() {

return (
<GuestLayout>
<Head title="Register" />
<Head title="Register a new Student" />

<form onSubmit={submit}>
<div>
<InputLabel htmlFor="username" value="Username" />
<InputLabel htmlFor="username" value="Student Username" />

<TextInput
id="username"
Expand All @@ -48,7 +43,10 @@ export default function Register() {
<InputError message={errors.username} className="mt-2" />
</div>
<div>
<InputLabel htmlFor="name_first" value="First Name" />
<InputLabel
htmlFor="name_first"
value="Student First Name"
/>

<TextInput
id="name_first"
Expand All @@ -65,7 +63,7 @@ export default function Register() {
</div>

<div>
<InputLabel htmlFor="name_last" value="Last Name" />
<InputLabel htmlFor="name_last" value="Student Last Name" />

<TextInput
id="name_last"
Expand All @@ -81,55 +79,7 @@ export default function Register() {
<InputError message={errors.name_last} className="mt-2" />
</div>

<div className="mt-4">
<InputLabel htmlFor="password" value="Password" />

<TextInput
id="password"
type="password"
name="password"
value={data.password}
className="mt-1 block w-full"
autoComplete="new-password"
onChange={(e) => setData("password", e.target.value)}
required
/>
<InputError message={errors.password} className="mt-2" />
</div>

<div className="mt-4">
<InputLabel
htmlFor="password_confirmation"
value="Confirm Password"
/>

<TextInput
id="password_confirmation"
type="password"
name="password_confirmation"
value={data.password_confirmation}
className="mt-1 block w-full"
autoComplete="new-password"
onChange={(e) =>
setData("password_confirmation", e.target.value)
}
required
/>

<InputError
message={errors.password_confirmation}
className="mt-2"
/>
</div>

<div className="flex items-center justify-end mt-4">
<Link
href={route("login")}
className="underline text-sm text-slate-600 dark:text-slate-400 hover:text-slate-900 dark:hover:text-slate-100 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-teal-500 dark:focus:ring-offset-slate-800"
>
Already registered?
</Link>

<PrimaryButton className="ms-4" disabled={processing}>
Register
</PrimaryButton>
Expand Down
15 changes: 7 additions & 8 deletions resources/js/Pages/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ export default function Welcome({ auth }: PageProps) {
Log in
</Link>
</NavbarItem>
<NavbarItem>
<Link
href={route("register")}
className="ms-4 font-semibold text-slate-600 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white focus:outline focus:outline-2 focus:rounded-sm focus:outline-teal-500"
>
Register
</Link>
</NavbarItem>
</NavbarContent>
) : (
<NavbarContent justify="end">
Expand Down Expand Up @@ -87,6 +79,13 @@ export default function Welcome({ auth }: PageProps) {
, out...
</div>
</div>
<div className="col-span-8 justify-center text-slate-200 text-3xl p-8">
A better justice system,{" "}
<span className="text-teal-200">
built from the inside
</span>
, out...
</div>
</CardBody>
</Card>
<Spacer y={20} />
Expand Down
9 changes: 3 additions & 6 deletions routes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use App\Http\Controllers\Auth\ConfirmablePasswordController;
use App\Http\Controllers\Auth\NewPasswordController;
use App\Http\Controllers\Auth\PasswordController;
use App\Http\Controllers\Auth\PasswordResetLinkController;
use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\Auth\StudentNewPasswordController;
use Illuminate\Support\Facades\Route;

Route::middleware('guest')->group(function () {
Expand All @@ -18,15 +18,12 @@
->name('login');

Route::post('login', [AuthenticatedSessionController::class, 'store']);

Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
->name('password.request');

Route::post('forgot-password', [PasswordResetLinkController::class, 'store']);
});

Route::middleware('auth')->group(function () {

Route::post('student-password', [StudentNewPasswordController::class, 'store']);

Route::get('confirm-password', [ConfirmablePasswordController::class, 'show'])
->name('password.confirm');

Expand Down
Loading

0 comments on commit b4c7b10

Please sign in to comment.