Code Duplication    Length = 17-17 lines in 2 locations

api/v1/class.GroupsAPI.php 1 location

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

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
    {