- Extract business logic from controllers into Action classes: Post/, Workspace/, Hashtag/, Label/, Invite/, ApiKey/ - Create subdomain routing: app.trypost.test (Inertia dashboard), api.trypost.test (REST API with token auth) - Add ApiToken model with tp_ prefix, token_lookup/hash auth - Add AuthenticateApiToken middleware for API authentication - Create Api controllers with JSON Resources for all entities - Create App controllers that use Actions + Inertia responses - Organize Form Requests into Api/ and App/ directories - Add api_tokens migration - Update all route names with app. prefix - Update all tests to use new route names (684 passing)
38 lines
1,003 B
PHP
38 lines
1,003 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\App\Settings;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Validation\Rules\Password;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class PasswordController extends Controller
|
|
{
|
|
public function edit(): Response
|
|
{
|
|
return Inertia::render('settings/Password');
|
|
}
|
|
|
|
public function update(Request $request): RedirectResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'current_password' => ['required', 'current_password'],
|
|
'password' => ['required', Password::defaults(), 'confirmed'],
|
|
]);
|
|
|
|
$request->user()->update([
|
|
'password' => Hash::make($validated['password']),
|
|
]);
|
|
|
|
session()->flash('flash.banner', __('settings.flash.password_updated'));
|
|
session()->flash('flash.bannerStyle', 'success');
|
|
|
|
return back();
|
|
}
|
|
}
|