blob: 51fd9f4410eb63cdb3c0a4e9e341825aeb24819f [file] [log] [blame]
Fatih Degirmencic2a46012019-09-30 12:07:45 +02001from flask import jsonify, g
2from app import db
3from app.api import bp
4from app.api.auth import basic_auth, token_auth
5
6@bp.route('/tokens', methods=['POST'])
7@basic_auth.login_required
8def get_token():
9 token = g.current_user.get_token()
10 db.session.commit()
11 return jsonify({'token': token})
12
13@bp.route('/tokens', methods=['DELETE'])
14@token_auth.login_required
15def revoke_token():
16 g.current_user.revoke_token()
17 db.session.commit()
18 return '', 204