Update SpaController, add username redirect method

This commit is contained in:
Daniel Supernault 2021-12-26 00:08:18 -07:00
parent 8c2c69c3aa
commit 5c65e2b761
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 10 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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', '.*');