Summary of completed work: - Complete buyer portal (browse, cart, checkout, orders, invoices) - Complete seller portal (orders, manifests, fleet, picking) - Business onboarding wizards (buyer 4-step, seller 5-step) - Email verification and registration flows - Notification system for buyers and sellers - Payment term surcharges and pickup/delivery workflows - Filament admin resources (Business, Brand, Product, Order, Invoice, User) - 51 migrations executed successfully Renamed Company -> Business throughout codebase for consistency. Unified authentication flows with password reset. Added audit trail and telescope for debugging. Next: Week 4 Data Migration (Days 22-28) - Product migration (883 products from cannabrands_crm) - Company migration (81 buyer companies) - User migration (preserve password hashes) - Order history migration
69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Auth;
|
|
|
|
use Auth;
|
|
use Illuminate\Validation\ValidationException;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Events\PasswordReset;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Password;
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Validation\Rules;
|
|
use Illuminate\View\View;
|
|
|
|
class NewPasswordController extends Controller
|
|
{
|
|
/**
|
|
* Display the password reset view.
|
|
*/
|
|
public function create(Request $request): View
|
|
{
|
|
return view('auth.reset-password', ['request' => $request]);
|
|
}
|
|
|
|
/**
|
|
* Handle an incoming new password request.
|
|
*
|
|
* @throws ValidationException
|
|
*/
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$request->validate([
|
|
'token' => ['required'],
|
|
'email' => ['required', 'email'],
|
|
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
|
]);
|
|
|
|
// 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.
|
|
$status = Password::reset(
|
|
$request->only('email', 'password', 'password_confirmation', 'token'),
|
|
function (User $user) use ($request) {
|
|
$user->forceFill([
|
|
'password' => Hash::make($request->password),
|
|
'remember_token' => Str::random(60),
|
|
])->save();
|
|
|
|
event(new PasswordReset($user));
|
|
}
|
|
);
|
|
|
|
if ($status == Password::PASSWORD_RESET) {
|
|
$user = User::where('email', $request->email)->first();
|
|
if ($user) {
|
|
Auth::login($user);
|
|
// Redirect to main dashboard after password reset
|
|
return redirect(dashboard_url());
|
|
}
|
|
}
|
|
|
|
return back()->withInput($request->only('email'))
|
|
->withErrors(['email' => __($status)]);
|
|
}
|
|
}
|