Update SpaController

This commit is contained in:
Daniel Supernault 2022-02-18 04:16:31 -07:00
parent 4c301a95ba
commit 1a7a4a052f
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -13,14 +13,10 @@ use App\Util\Localization\Localization;
class SpaController extends Controller class SpaController extends Controller
{ {
public function __construct() public function index(Request $req)
{
$this->middleware('auth');
}
public function index()
{ {
abort_unless(config('exp.spa'), 404); abort_unless(config('exp.spa'), 404);
if(!$req->user()) { return redirect('/login'); }
return view('layouts.spa'); return view('layouts.spa');
} }
@ -32,7 +28,7 @@ class SpaController extends Controller
} }
if(SnowflakeService::byDate(now()->subDays(30)) > $id) { if(SnowflakeService::byDate(now()->subDays(30)) > $id) {
abort(404); return redirect('/login');
} }
$post = StatusService::get($id); $post = StatusService::get($id);
@ -46,7 +42,7 @@ class SpaController extends Controller
return redirect($post['url']); return redirect($post['url']);
} }
abort(404); return redirect('/login');
} }
public function webProfile(Request $request, $id) public function webProfile(Request $request, $id)
@ -60,17 +56,19 @@ class SpaController extends Controller
return view('layouts.spa'); return view('layouts.spa');
} }
$account = AccountService::get($id); // $account = AccountService::get($id);
if($account && isset($account['url'])) { // if($account && isset($account['url'])) {
return redirect($account['url']); // return redirect($account['url']);
} // }
return redirect('404'); return redirect('/login');
} }
public function updateLanguage(Request $request) public function updateLanguage(Request $request)
{ {
abort_unless(config('exp.spa'), 404);
abort_unless($req->user(), 404);
$this->validate($request, [ $this->validate($request, [
'v' => 'required|in:0.1,0.2', 'v' => 'required|in:0.1,0.2',
'l' => 'required|alpha_dash|max:5' 'l' => 'required|alpha_dash|max:5'
@ -90,6 +88,7 @@ class SpaController extends Controller
public function getPrivacy() public function getPrivacy()
{ {
abort_unless($req->user(), 404);
$body = $this->markdownToHtml('views/page/privacy.md'); $body = $this->markdownToHtml('views/page/privacy.md');
return [ return [
'body' => $body 'body' => $body
@ -98,6 +97,7 @@ class SpaController extends Controller
public function getTerms() public function getTerms()
{ {
abort_unless($req->user(), 404);
$body = $this->markdownToHtml('views/page/terms.md'); $body = $this->markdownToHtml('views/page/terms.md');
return [ return [
'body' => $body 'body' => $body
@ -119,6 +119,7 @@ class SpaController extends Controller
public function usernameRedirect(Request $request, $username) public function usernameRedirect(Request $request, $username)
{ {
abort_unless($req->user(), 404);
$id = AccountService::usernameToId($username); $id = AccountService::usernameToId($username);
if(!$id) { if(!$id) {
return redirect('/i/web/404'); return redirect('/i/web/404');