From 5c65e2b761a77265d6652f45a1b0315622f87037 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 26 Dec 2021 00:08:18 -0700 Subject: [PATCH] Update SpaController, add username redirect method --- app/Http/Controllers/SpaController.php | 9 +++++++++ routes/web.php | 1 + 2 files changed, 10 insertions(+) diff --git a/app/Http/Controllers/SpaController.php b/app/Http/Controllers/SpaController.php index d92cdc37a..a6939513b 100644 --- a/app/Http/Controllers/SpaController.php +++ b/app/Http/Controllers/SpaController.php @@ -116,4 +116,13 @@ class SpaController extends Controller return (string) $converter->convertToHtml($file); }); } + + public function usernameRedirect(Request $request, $username) + { + $id = AccountService::usernameToId($username); + if(!$id) { + return redirect('/i/web/404'); + } + return redirect('/i/web/profile/' . $id); + } } diff --git a/routes/web.php b/routes/web.php index 328823853..c48b2017a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -337,6 +337,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::post('warning', 'AccountInterstitialController@read'); Route::get('my2020', 'SeasonalController@yearInReview'); + Route::get('web/username/{id}', 'SpaController@usernameRedirect'); Route::get('web/post/{id}', 'SpaController@webPost'); Route::get('web/profile/{id}', 'SpaController@webProfile'); Route::get('web/{q}', 'SpaController@index')->where('q', '.*');