61 lines
No EOL
1.5 KiB
PHP
61 lines
No EOL
1.5 KiB
PHP
<?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");
|
|
}
|
|
} |