public function delete()
    {
        $userService = $this->getServiceLocator()->get(tao_models_classes_UserService::class);
        // Csrf token validation
        $tokenService = $this->getServiceLocator()->get(TokenService::SERVICE_ID);
        $tokenName = $tokenService->getTokenName();
        $token = $this->getRequestParameter($tokenName);
        if (! $tokenService->checkToken($token)) {
            $this->logWarning('Xsrf validation failed');
            $this->returnJson([
                'success' => false,
                'message' => 'Not authorized to perform action'
            ]);
            return;
        } else {
            $tokenService->revokeToken($token);
            $newToken = $tokenService->createToken();
            $this->setCookie($tokenName, $newToken, null, '/');
        }

        $deleted = false;
        $message = __('An error occurred during user deletion');
        if (ApplicationHelper::isDemo()) {
            $message = __('User deletion not permitted on a demo instance');
        } elseif ($this->hasRequestParameter('uri')) {
            $user = $this->getResource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
            $this->checkUser($user->getUri());

            if ($userService->removeUser($user)) {
                $deleted = true;
                $message = __('User deleted successfully');
            }
        }
        $this->returnJson(array(
            'success' => $deleted,
            'message' => $message
        ));
    }
public function delete()
    {
        $userService = $this->getServiceLocator()->get(tao_models_classes_UserService::class);
        // Csrf token validation
        $tokenService = $this->getServiceLocator()->get(TokenService::SERVICE_ID);
        $tokenName = $tokenService->getTokenName();
        $token = $this->getRequestParameter($tokenName);
        if (! $tokenService->checkToken($token)) {
            $this->logWarning('Xsrf validation failed');
            $this->returnJson([
                'success' => false,
                'message' => 'Not authorized to perform action'
            ]);
            return;
        } else {
            $tokenService->revokeToken($token);
            $newToken = $tokenService->createToken();
            $this->setCookie($tokenName, $newToken, null, '/');
        }

        $deleted = false;
        $message = __('An error occurred during user deletion');
        if (ApplicationHelper::isDemo()) {
            $message = __('User deletion not permitted on a demo instance');
        } elseif ($this->hasRequestParameter('uri')) {
            $user = $this->getResource(tao_helpers_Uri::decode($this->getRequestParameter('uri')));
            $this->checkUser($user->getUri());

            if ($userService->removeUser($user)) {
                $deleted = true;
                $message = __('User deleted successfully');
            }
        }
        $this->returnJson(array(
            'success' => $deleted,
            'message' => $message
        ));
    }
public function delete ( ) { $ userService = $ this -> getServiceLocator ( ) -> get ( tao_models_classes_UserService :: class ) ; // Csrf token validation $ tokenService = $ this -> getServiceLocator ( ) -> get ( TokenService :: SERVICE_ID ) ; $ tokenName = $ tokenService -> getTokenName ( ) ; $ token = $ this -> getRequestParameter ( $ tokenName ) ; if ( ! $ tokenService -> checkToken ( $ token ) ) { $ this -> logWarning ( 'Xsrf validation failed' ) ; $ this -> returnJson ( [ 'success' => false , 'message' => 'Not authorized to perform action' ] ) ; return ; } else { $ tokenService -> revokeToken ( $ token ) ; $ newToken = $ tokenService -> createToken ( ) ; $ this -> setCookie ( $ tokenName , $ newToken , null , '/' ) ; } $ deleted = false ; $ message = __ ( 'An error occurred during user deletion' ) ; if ( ApplicationHelper :: isDemo ( ) ) { $ message = __ ( 'User deletion not permitted on a demo instance' ) ; } elseif ( $ this -> hasRequestParameter ( 'uri' ) ) { $ user = $ this -> getResource ( tao_helpers_Uri :: decode ( $ this -> getRequestParameter ( 'uri' ) ) ) ; $ this -> checkUser ( $ user -> getUri ( ) ) ; if ( $ userService -> removeUser ( $ user ) ) { $ deleted = true ; $ message = __ ( 'User deleted successfully' ) ; } } $ this -> returnJson ( array ( 'success' => $ deleted , 'message' => $ message ) ) ; }
Remove a user
The request must contains the user's login to remove
@return void
@throws Exception
@throws common_exception_Error
Remove a user The request must contains the user s login to remove