1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6namespace App\Http\Controllers\OAuth;
7
8use App\Http\Controllers\Controller;
9
10/**
11 * @group OAuth Tokens
12 */
13class TokensController extends Controller
14{
15 public function __construct()
16 {
17 parent::__construct();
18
19 $this->middleware('require-scopes:any', ['only' => ['destroyCurrent']]);
20 }
21
22 /**
23 * Revoke current token
24 *
25 * Revokes currently authenticated token.
26 *
27 * @response 204
28 */
29 public function destroyCurrent()
30 {
31 $token = oauth_token();
32
33 if ($token !== null) {
34 $token->revokeRecursive();
35 }
36
37 return response(null, 204);
38 }
39}