Code Duplication    Length = 40-40 lines in 2 locations

src/Middleware/OAuthClientOwnerMiddleware.php 1 location

@@ 23-62 (lines=40) @@
20
 *
21
 * @author Vincent Klaiber <[email protected]>
22
 */
23
class OAuthClientOwnerMiddleware
24
{
25
    /**
26
     * The Authorizer instance.
27
     *
28
     * @var \LucaDegasperi\OAuth2Server\Authorizer
29
     */
30
    protected $authorizer;
31
32
    /**
33
     * Create a new oauth client middleware instance.
34
     *
35
     * @param \LucaDegasperi\OAuth2Server\Authorizer $authorizer
36
     */
37
    public function __construct(Authorizer $authorizer)
38
    {
39
        $this->authorizer = $authorizer;
40
    }
41
42
    /**
43
     * Handle an incoming request.
44
     *
45
     * @param \Illuminate\Http\Request $request
46
     * @param \Closure $next
47
     *
48
     * @throws \League\OAuth2\Server\Exception\AccessDeniedException
49
     *
50
     * @return mixed
51
     */
52
    public function handle($request, Closure $next)
53
    {
54
        $this->authorizer->setRequest($request);
55
56
        if ($this->authorizer->getResourceOwnerType() !== 'client') {
57
            throw new AccessDeniedException();
58
        }
59
60
        return $next($request);
61
    }
62
}
63

src/Middleware/OAuthUserOwnerMiddleware.php 1 location

@@ 23-62 (lines=40) @@
20
 *
21
 * @author Vincent Klaiber <[email protected]>
22
 */
23
class OAuthUserOwnerMiddleware
24
{
25
    /**
26
     * The Authorizer instance.
27
     *
28
     * @var \LucaDegasperi\OAuth2Server\Authorizer
29
     */
30
    protected $authorizer;
31
32
    /**
33
     * Create a new oauth user middleware instance.
34
     *
35
     * @param \LucaDegasperi\OAuth2Server\Authorizer $authorizer
36
     */
37
    public function __construct(Authorizer $authorizer)
38
    {
39
        $this->authorizer = $authorizer;
40
    }
41
42
    /**
43
     * Handle an incoming request.
44
     *
45
     * @param \Illuminate\Http\Request $request
46
     * @param \Closure $next
47
     *
48
     * @throws \League\OAuth2\Server\Exception\AccessDeniedException
49
     *
50
     * @return mixed
51
     */
52
    public function handle($request, Closure $next)
53
    {
54
        $this->authorizer->setRequest($request);
55
56
        if ($this->authorizer->getResourceOwnerType() !== 'user') {
57
            throw new AccessDeniedException();
58
        }
59
60
        return $next($request);
61
    }
62
}
63