Created
December 30, 2017 04:26
-
-
Save uno-de-piera/24d54010b4afa032f8f306198751730a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Encryption = use('Encryption'); | |
class AuthController { | |
//.... | |
async revokeUserToken ({auth, response}) { | |
const user = await auth.getUser(); | |
const token = auth.getAuthHeader(); | |
await user | |
.tokens() | |
.where('type', 'api_token') | |
.where('token', Encryption.decrypt(token)) | |
.update({ is_revoked: true }); | |
return response.status(204).json(null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment