Beispiel #1
0
def logout_json():
    """Logs the user out and returns an ok message"""
    authapi.logout()

    resp = make_response( msg.ok(_(u'User loged out')) )
    resp.set_cookie('connect_type', '')
    return resp
Beispiel #2
0
def logout_json():
    """Logs the user out and returns an ok message"""
    authapi.logout()

    resp = make_response( msg.ok(_(u'User loged out')) )
    resp.set_cookie('connect_type', '')
    return resp
Beispiel #3
0
def logout():
    """Logs the user out and returns """
    if not authapi.is_authenticated():
        return redirect(url_for("index"))
    authapi.logout()
    next = request.values.get("next")
    app = request.values.get("app")
    menus = fromcache("menuprincipal") or tocache(
        "menuprincipal", wordpress.exapi.getMenuItens(menu_slug="menu-principal")
    )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    if next:
        print "NEXTT=", next
        return redirect(next)
    else:
        return render_template(
            "logout.html",
            menu=menus,
            app=app,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
            voltar=request.referrer or "/",
            sidebar=wordpress.getSidebar,
        )
Beispiel #4
0
def profile_json():
    """Validate the request of the update of a profile.

    This method will not operate in any user instance but the
    authenticated one. If there's nobody authenticated, there's no way
    to execute it successfuly.
    """
    form = social(ProfileForm, False)
    if not form.validate_on_submit():
        # This field is special, it must be validated before anything. If it
        # doesn't work, the action must be aborted.
        if not form.csrf_is_valid:
            return msg.error(_('Invalid csrf token'), 'InvalidCsrfToken')

        # Usual validation error
        return utils.format_csrf_error(form, form.errors, 'ValidationError')

    # Let's save the authenticated user's meta data
    mget = form.meta.get
    try:
        user = authapi.authenticated_user()
    except authapi.NobodyHome:
        return redirect(url_for('index'))

    # First, the specific ones
    email = mget('email')
    redologin = False
    if user.username == user.email and user.username != email \
       and not (user.get_meta('twitteruser') or user.get_meta('facebookuser')):
        flash(_(u'You changed your email, please relogin.'))
        redologin = True
        user.username = email
    user.name = mget('name')
    user.email = email

    # Saving the thumbnail
    form.meta.pop('avatar')
    if bool(form.avatar.file):
        flike = form.avatar.file
        thumb = utils.thumbnail(flike, (48, 48))
        form.meta['avatar'] = Upload.imageset.save(
            FileStorage(thumb, flike.filename, flike.name),
            'thumbs/%s' % user.name[0].lower())

    # And then, the meta ones, stored in `UserMeta'
    for key, val in form.meta.items():
        user.set_meta(key, val)

    # return msg.ok({
    #     'data': _('User profile updated successfuly'),
    #     'csrf': form.csrf.data,
    # })
    flash(_(u'Profile update successful'), 'alert-success')
    if redologin:
        authapi.logout()
        return redirect(url_for('auth.login'))
    else:
        return redirect(url_for('.profile'))
Beispiel #5
0
def profile_json():
    """Validate the request of the update of a profile.

    This method will not operate in any user instance but the
    authenticated one. If there's nobody authenticated, there's no way
    to execute it successfuly.
    """
    form = social(ProfileForm, False)
    if not form.validate_on_submit():
        # This field is special, it must be validated before anything. If it
        # doesn't work, the action must be aborted.
        if not form.csrf_is_valid:
            return msg.error(_('Invalid csrf token'), 'InvalidCsrfToken')

        # Usual validation error
        return utils.format_csrf_error(form, form.errors, 'ValidationError')

    # Let's save the authenticated user's meta data
    mget = form.meta.get
    try:
        user = authapi.authenticated_user()
    except authapi.NobodyHome:
        return redirect(url_for('index'))

    # First, the specific ones
    email = mget('email')
    redologin = False
    if user.username == user.email and user.username != email \
       and not (user.get_meta('twitteruser') or user.get_meta('facebookuser')):
        flash(_(u'You changed your email, please relogin.'))
        redologin = True
        user.username = email
    user.name = mget('name')
    user.email = email

    # Saving the thumbnail
    form.meta.pop('avatar')
    if bool(form.avatar.file):
        flike = form.avatar.file
        thumb = utils.thumbnail(flike, (48, 48))
        form.meta['avatar'] = Upload.imageset.save(
            FileStorage(thumb, flike.filename, flike.name),
            'thumbs/%s' % user.name[0].lower())

    # And then, the meta ones, stored in `UserMeta'
    for key, val in form.meta.items():
        user.set_meta(key, val)

    # return msg.ok({
    #     'data': _('User profile updated successfuly'),
    #     'csrf': form.csrf.data,
    # })
    flash(_(u'Profile update successful'), 'alert-success')
    if redologin:
        authapi.logout()
        return redirect(url_for('auth.login'))
    else:
        return redirect(url_for('.profile'))
Beispiel #6
0
def logout():
    """Logs the user out and returns """
    if not authapi.is_authenticated():
        return redirect(url_for('index'))
    authapi.logout()
    next = request.values.get('next')
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    if next:
        print "NEXTT=", next
        return redirect(next)
    else:
        return render_template('logout.html',
            menu=menus,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
            voltar=request.referrer or "/"
            )
Beispiel #7
0
def logout():
    """Logs the user out and returns """
    if not authapi.is_authenticated():
        return redirect(url_for('index'))
    authapi.logout()
    next = request.values.get('next')
    app = request.values.get('app')
    menus = fromcache('menuprincipal') or tocache('menuprincipal', wordpress.exapi.getMenuItens(menu_slug='menu-principal') )
    try:
        twitter_hash_cabecalho = utils.twitts()
    except KeyError:
        twitter_hash_cabecalho = ""

    if next:
        print "NEXTT=", next
        return redirect(next)
    else:
        return render_template('logout.html',
            menu=menus,
            app=app,
            twitter_hash_cabecalho=twitter_hash_cabecalho,
            voltar=request.referrer or "/",
            sidebar=wordpress.getSidebar,
            )
Beispiel #8
0
def logout():
    """Calls the logout API function and redirects to the login form"""
    auth.logout()
    return redirect(url_for('.login'))
Beispiel #9
0
def logout():
    """Calls the logout API function and redirects to the login form"""
    auth.logout()
    return redirect(url_for('.login'))