1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-11-15 14:42:29 +01:00
polr/app/Http/Controllers/Controller.php

49 lines
1.0 KiB
PHP
Raw Normal View History

2015-11-03 05:13:32 +01:00
<?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;
}
2015-11-03 05:13:32 +01:00
}