Exemple #1
0
def app():
    as_api = os.environ.get('HTTP_ACCEPT', '') == 'application/json'

    if not user.is_authenticated:
        if as_api:
            return '{"message": "not logged in"}'
        else:
            warning('You are not logged in')
    else:

        # save these because they are about to get wiped out
        username = user.username
        user_id = user.id

        user.logout()

        if as_api:
            logger.info('user %(username)s successfully logged out via api' %
                        locals())
            return '{}'
        else:
            msg = '<a href="/users/%(user_id)s">%(username)s</a> logged out' % locals(
            )
            logger.activity('session', msg)
            logger.info('user %(username)s successfully logged out' % locals())
    return redirect_to('/')
Exemple #2
0
def app():
    if not user.is_authenticated:
        warning('You are not logged in')
    else:
        username = user.username
        user_id = user.id
        user.logout()
        logger.info('user %(username)s successfully logged out' % locals())
        msg = '<a href="/users/%(user_id)s">%(username)s</a> logged out' % locals()
        logger.activity('session', msg)
    return redirect_to('/')
Exemple #3
0
def app():
    as_api = os.environ.get('HTTP_ACCEPT','') == 'application/json'

    if not user.is_authenticated:
        if as_api:
            return '{"message": "not logged in"}'
        else:
            warning('You are not logged in')
    else:

        # save these because they are about to get wiped out
        username = user.username
        user_id = user.id

        user.logout()

        if as_api:
            logger.info('user %(username)s successfully logged out via api' % locals())
            return '{}'
        else:
            msg = '<a href="/users/%(user_id)s">%(username)s</a> logged out' % locals()
            logger.activity('session', msg)
            logger.info('user %(username)s successfully logged out' % locals())
    return redirect_to('/')