Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera
Created December 30, 2017 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uno-de-piera/24d54010b4afa032f8f306198751730a to your computer and use it in GitHub Desktop.
Save uno-de-piera/24d54010b4afa032f8f306198751730a to your computer and use it in GitHub Desktop.
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