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

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