]> git.mxchange.org Git - friendica.git/commitdiff
Get rid of "api_user()" function
authorMichael <heluecht@pirati.ca>
Tue, 8 Jun 2021 20:41:46 +0000 (20:41 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 8 Jun 2021 20:41:46 +0000 (20:41 +0000)
src/Module/BaseApi.php

index adad7636a775ed5ce8bbc2fdd5bafbc85e5f5e7a..af5298cce62856c1b5bd622d303b99c272e2a6cc 100644 (file)
@@ -61,52 +61,44 @@ class BaseApi extends BaseModule
 
        public static function delete(array $parameters = [])
        {
-               if (!api_user()) {
-                       throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
-               }
+               self::checkAllowedScope(self::SCOPE_WRITE);
 
                $a = DI::app();
 
-               if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) {
+               if (!empty($a->user['uid']) && $a->user['uid'] != self::getCurrentUserID()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
        }
 
        public static function patch(array $parameters = [])
        {
-               if (!api_user()) {
-                       throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
-               }
+               self::checkAllowedScope(self::SCOPE_WRITE);
 
                $a = DI::app();
 
-               if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) {
+               if (!empty($a->user['uid']) && $a->user['uid'] != self::getCurrentUserID()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
        }
 
        public static function post(array $parameters = [])
        {
-               if (!api_user()) {
-                       throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
-               }
+               self::checkAllowedScope(self::SCOPE_WRITE);
 
                $a = DI::app();
 
-               if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) {
+               if (!empty($a->user['uid']) && $a->user['uid'] != self::getCurrentUserID()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
        }
 
        public static function put(array $parameters = [])
        {
-               if (!api_user()) {
-                       throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
-               }
+               self::checkAllowedScope(self::SCOPE_WRITE);
 
                $a = DI::app();
 
-               if (!empty($a->user['uid']) && $a->user['uid'] != api_user()) {
+               if (!empty($a->user['uid']) && $a->user['uid'] != self::getCurrentUserID()) {
                        throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
                }
        }