This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccount/app/Http/Controllers/GUI/AccessController.php

61 lines
1.5 KiB
PHP
Raw Normal View History

2019-04-25 15:33:15 +00:00
<?php
namespace App\Http\Controllers\GUI;
use App\Exceptions\HTTPException;
use App\Http\Controllers\Controller;
use App\Http\Resources\oAuth\AccessToken;
use App\Jobs\Mails\ValidateMailAddressJob;
use App\Models\App;
use App\Models\AppAccess;
use App\Models\AppCode;
use App\Models\Invite;
use App\Models\Mail;
use App\Models\RefreshToken;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class AccessController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//
}
public function listAccess() {
if(!Auth::check()) {
abort(401);
}
$access = AppAccess::query()->where("user_id", "=", Auth::user()->id)->get();
return view("access/list", ["access" => $access]);
}
public function removeAccess(Request $request) {
if(!Auth::check()) {
abort(401);
}
$access = AppAccess::query()->where("id", "=", $request->id)->firstOrFail();
if($access->user_id != Auth::user()->id) {
abort(401);
}
RefreshToken::query()->where("access_id", "=", $access->id)->delete();
\App\Models\AccessToken::query()->where("access_id", "=", $access->id)->delete();
AppCode::query()->where("access_id", "=", $access->id)->delete();
$access->delete();
return redirect("/gui/access");
}
}