コード例 #1
0
    def post(self):
        """Verify login data and respond with a new timed auth token."""
        # TODO: current user object or at least user-id
        # should be stored in session to decrease db access
        # Response should probably also include timeout (for cookie info)
        username = request.authorization.username
        try:
            user = Ctrl.get_user_with_name(username)
        except Ctrl.AdminControlException as err:
            return JSendResponse.new_error(err.message).jsonify()

        token = user.generate_auth_token()
        return JSendResponse.new_success(token.decode('ascii')).jsonify()
コード例 #2
0
def handle_500(err):
    if hasattr(err, 'data') and err.data.get('rest', False):
        return JSendResponse.new_error(str(err)).jsonify(), 500
    else:
        return render_template('500.html', title='Internal Server Error'), 500