Session api token validation

This commit is contained in:
2026-06-23 11:20:01 +10:00
parent cd1538ba12
commit fcba639bae
25 changed files with 491 additions and 235 deletions
+1 -63
View File
@@ -9,74 +9,12 @@ use App\Settings\SettingsRegistry;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Gate;
use Inertia\Inertia;
class UserController extends Controller
{
public function follow(User $user): JsonResponse
{
abort_if($user->id === auth()->id(), 403);
$existing = Followee::where('user_id', auth()->id())
->where('followee_id', $user->id)
->first();
if ($existing) {
$existing->delete();
return response()->json(['status' => 'none']);
}
$canView = Gate::allows('viewProfileData', $user);
Followee::create([
'user_id' => auth()->id(),
'followee_id' => $user->id,
'verified' => $canView,
]);
Notification::create([
'user_id' => $user->id,
'title' => $canView ? 'New follower' : 'Follow request',
'body' => $canView
? auth()->user()->name . ' is now following you.'
: auth()->user()->name . ' wants to follow you.',
'is_achievement' => false,
'url' => $canView ? '/u/' . auth()->user()->name : '/follow-requests',
]);
return response()->json(['status' => $canView ? 'following' : 'requested']);
}
public function approveRequest(User $follower): JsonResponse
{
$followee = Followee::where('user_id', $follower->id)
->where('followee_id', auth()->id())
->pending()
->firstOrFail();
$followee->update(['verified' => true]);
Notification::create([
'user_id' => $follower->id,
'title' => 'Follow request accepted',
'body' => auth()->user()->name . ' accepted your follow request.',
'is_achievement' => false,
'url' => '/u/' . auth()->user()->name,
]);
return response()->json(['approved' => true]);
}
public function denyRequest(User $follower): JsonResponse
{
Followee::where('user_id', $follower->id)
->where('followee_id', auth()->id())
->pending()
->delete();
return response()->json(['denied' => true]);
}
public function settings(?string $category = null){
$allowedTabs = ['general', 'followers'];