Skip to content
Snippets Groups Projects
Select Git revision
  • a32288465b5c931cd1abbe50e19a3bd817ad7872
  • main default protected
  • issue-56
  • testing-systems
4 results

users.php

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    users.php 757 B
    <?php
    final class UsersController extends TracToGitlab\EventController
    {
        const SECRET_USER_CREATED = 'q<-%Y7Ys>h(@LHgg';
    
        public function created_action()
        {
            if (!Request::isPost()) {
                throw new MethodNotAllowedException();
            }
    
            if (
                !$this->verifySecret(self::SECRET_USER_CREATED)
                || !$this->verifyEventType('System Hook')
            ) {
                throw new AccessDeniedException();
            }
    
            if ($this->getFromPayload('event_name') === 'user_create') {
                $this->gitlab->projects()->addMember(
                    $this->gitlabProjectId,
                    $this->getFromPayload('user_id'),
                    10
                );
            }
    
            $this->render_nothing();
        }
    }