def post(self): parser = reqparse.RequestParser() parser.add_argument('password', help='This field cannot be blank', required=True) args = parser.parse_args() current_user = UserModel.find_by_username(get_jwt_identity()) if not current_user or not UserModel.verify_hash( args['password'], current_user.password): return {'message': 'Wrong credentials', 'success': False} del_logs = LogModel.delete_by_user(get_jwt_identity()) del_bins = DnsModel.delete_by_user(get_jwt_identity()) del_user = UserModel.delete_user(get_jwt_identity()) jti = get_raw_jwt()['jti'] try: revoked_token = RevokedTokenModel(jti=jti) revoked_token.add() return { 'message': 'Access token has been revoked', 'total_deleted_rows': { "logs": del_logs, "bins": del_bins, "user": del_user }, 'success': True } except: return {'message': 'Something went wrong', 'success': False}
def delete(self, id): return UserModel.delete_user(id)