Code Duplication    Length = 17-17 lines in 2 locations

api/v1/class.GroupsAPI.php 1 location

@@ 21-37 (lines=17) @@
18
        }
19
    }
20
21
    public function validateIsAdmin($request, $nonFatal = false)
22
    {
23
        $this->user = $request->getAttribute('user');
24
        if($this->user === false)
25
        {
26
            throw new Exception('Must be logged in', \Http\Rest\ACCESS_DENIED);
27
        }
28
        if(!$this->user->isInGroupNamed('LDAPAdmins'))
29
        {
30
            if($nonFatal)
31
            {
32
                return false;
33
            }
34
            throw new Exception('Must be Admin', \Http\Rest\ACCESS_DENIED);
35
        }
36
        return true;
37
    }
38
39
    public function getGroups($request, $response, $args)
40
    {

api/v1/class.UsersAPI.php 1 location

@@ 21-37 (lines=17) @@
18
        $app->post('/Actions/remind_uid[/]', array($this, 'remindUid'));
19
    }
20
21
    public function validateIsAdmin($request, $nonFatal = false)
22
    {
23
        $this->user = $request->getAttribute('user');
24
        if($this->user === false)
25
        {
26
            throw new Exception('Must be logged in', \Http\Rest\ACCESS_DENIED);
27
        }
28
        if(!$this->user->isInGroupNamed('LDAPAdmins'))
29
        {
30
            if($nonFatal)
31
            {
32
                return false;
33
            }
34
            throw new Exception('Must be Admin', \Http\Rest\ACCESS_DENIED);
35
        }
36
        return true;
37
    }
38
39
    public function listUsers($request, $response, $args)
40
    {