Prompt: Make sure registration/login works. At the moment I try to login and register, but see no progress, form is getting reset, I am not being redirected anywhere and I don't see any error messages on the UI. I should be moved to dashboard and be logged in after registration and log in if it was successsfull and be presented with an error message if registration or login is unsuccessful.
Session Total cost: $6.58 (costs may be inaccurate due to usage of unknown models) Total duration (API): 57m 34s Total duration (wall): 1h 27m 51s Total code changes: 3043 lines added, 209 lines removed Usage by model: qwen/qwen3.6-35b-a3b: 356.4k input, 80.7k output, 14.1m cache read, 0 cache write ($6.51) claude-haiku-4-5: 9.4k input, 13.3k output, 8.3k cache read, 0 cache write ($0.0767) Runtime: llamacpp Model: Qwen 3.6 35B A3B Q4 K M Coding Agent: ClaudeCode
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\OrganizationController;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
// Homepage
|
||||
@@ -13,18 +17,46 @@ Route::get('/login', function () {
|
||||
return view('auth.login');
|
||||
})->name('login');
|
||||
|
||||
Route::post('/login', function () {
|
||||
// TODO: Implement login logic
|
||||
return redirect()->route('login');
|
||||
Route::post('/login', function (Request $request) {
|
||||
$validated = $request->validate([
|
||||
'email' => ['required', 'email'],
|
||||
'password' => ['required'],
|
||||
]);
|
||||
|
||||
if (Auth::attempt(['email' => $validated['email'], 'password' => $validated['password']], $request->boolean('remember'))) {
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
|
||||
return back()->withErrors([
|
||||
'email' => 'The provided credentials do not match our records.',
|
||||
])->onlyInput('email');
|
||||
})->name('login.post');
|
||||
|
||||
Route::get('/register', function () {
|
||||
return view('auth.register');
|
||||
})->name('register');
|
||||
|
||||
Route::post('/register', function () {
|
||||
// TODO: Implement registration logic
|
||||
return redirect()->route('register');
|
||||
Route::post('/register', function (Request $request) {
|
||||
$validated = $request->validate([
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', 'max:255', 'unique:users,email'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'name' => $validated['first_name'].' '.$validated['last_name'],
|
||||
'email' => $validated['email'],
|
||||
'password' => Hash::make($validated['password']),
|
||||
'has_organization' => false,
|
||||
]);
|
||||
|
||||
Auth::login($user);
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->route('dashboard');
|
||||
})->name('register.post');
|
||||
|
||||
// Organization CRUD
|
||||
@@ -36,14 +68,16 @@ Route::middleware('auth')->group(function () {
|
||||
|
||||
// Dashboard (redirects to organizations if user has any, else login)
|
||||
Route::get('/dashboard', function () {
|
||||
if (!auth()->check()) {
|
||||
if (! auth()->check()) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
$user = auth()->user();
|
||||
if ($user->has_organization && $user->organizations()->exists()) {
|
||||
$org = $user->organizations()->first();
|
||||
|
||||
return redirect()->route('organizations.show', $org);
|
||||
}
|
||||
|
||||
return view('home');
|
||||
})->name('dashboard');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user