Selaa lähdekoodia

Update SpaController, add username redirect method

Daniel Supernault 3 vuotta sitten
vanhempi
commit
5c65e2b761
2 muutettua tiedostoa jossa 10 lisäystä ja 0 poistoa
  1. 9 0
      app/Http/Controllers/SpaController.php
  2. 1 0
      routes/web.php

+ 9 - 0
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);
+	}
 }

+ 1 - 0
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', '.*');