Added the possibility to enable/disable REST APIs

This commit is contained in:
MatteoF96
2022-09-22 17:19:24 +02:00
parent 312861c854
commit 08e1355753
3 changed files with 12 additions and 0 deletions

View File

@ -139,6 +139,10 @@ class AdminController extends ActiveController
*/
public function checkAccess($action, $model = null, $params = [])
{
// Check if the REST APIs are enabled
if (!$this->module->enableRestApi) {
throw new NotFoundHttpException(Yii::t('usuario', 'The requested page does not exist.'));
}
// Access for admins only
if (!Yii::$app->user->can('admin')) {
throw new ForbiddenHttpException(Yii::t('usuario', 'User does not have sufficient permissions.'));