mirror of
https://github.com/cydrobolt/polr.git
synced 2024-11-15 06:32:30 +01:00
49 lines
1.0 KiB
PHP
49 lines
1.0 KiB
PHP
<?php
|
|
namespace App\Http\Controllers;
|
|
|
|
use Laravel\Lumen\Routing\Controller as BaseController;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
|
class Controller extends BaseController {
|
|
protected static function currIsAdmin() {
|
|
$role = session('role');
|
|
if ($role == 'admin') {
|
|
return true;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
protected static function isLoggedIn() {
|
|
$username = session('username');
|
|
if (!isset($username)) {
|
|
return false;
|
|
}
|
|
else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
protected static function checkRequiredArgs($required_args=[]) {
|
|
array_push($required_args, NULL);
|
|
|
|
if (count(array_unique($required_args)) < count($required_args)) {
|
|
return false;
|
|
}
|
|
else {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
protected static function ensureAdmin() {
|
|
if (!self::currIsAdmin()) {
|
|
abort(401, 'User not admin.');
|
|
}
|
|
return true;
|
|
}
|
|
}
|