Esempio n. 1
0
def do_post(**kwargs):
    """
    Logout user
    """

    _db = get_db()
    dbc = _db.cursor()

    request = kwargs['request_handler']

    tk = request.auth_token

    dbuser = get_user_by_token(_db, tk)

    if not close_session_by_token(dbc, tk):
        log.warning("Closing session with token {}".format(tk))
        return base_common.msg.error(msgs.CLOSE_USER_SESSION)

    _db.commit()

    apphooks.action_log_hook(dbuser.id_user, kwargs['r_ip'], 'logout', 'user {} successfuly logged out'.format(dbuser.username))
    return base_common.msg.post_ok()
Esempio n. 2
0
def do_post(request, *args, **kwargs):
    """
    User logout
    :param Auth: authorization token in header, string, True
    :return:  200, OK
    :return:  400
    """

    log = request.log

    _db = get_db()
    dbc = _db.cursor()

    tk = request.auth_token
    if not authorized_by_token(dbc, tk, log):
        return base_common.msg.error(msgs.UNAUTHORIZED_REQUEST)

    if not close_session_by_token(dbc, tk, log):
        log.warning("Clossing session with token {}".format(tk))
        return base_common.msg.error(msgs.CLOSE_USER_SESSION)

    _db.commit()

    return base_common.msg.post_ok()