Exemple #1
0
def logout(context, request):
    mt = getToolByName(context, 'portal_membership')
    p = get_cas_plugin(context)
    # forget user on logout
    mt.logoutUser(REQUEST=request)

    #if request.has_key('portal_skin'):
    #    context.portal_skins.clearSkinCookie()
    #request.RESPONSE.expireCookie('__ac', path='/')

    session = request.SESSION
    if p.session_var in session.keys():
        session[p.session_var] = None
    # let cas finnish the logout
    portal = quote(
        getToolByName(
            context, 'portal_url'
        ).getPortalObject().absolute_url()
    )
    IStatusMessage(request).addStatusMessage(
        _(u'You are now logged out.'),
        type='info'
    )
    return request.RESPONSE.redirect(
        '%s?service=%s' % (p.logout_url, portal)
    )
Exemple #2
0
def login_URL(context):
    base = login_URL_base(context)
    if base is None:
        request = context.REQUEST
        IStatusMessage(request).addStatusMessage(
            _(u"CAS Login is not available. Please configure CAS"),
            type="warning"
        )
        return None
    return '%s%s' % (base, login_query_string(context))