Beispiel #1
0
def logout():
    """Log the user out.  Redirect to the "next" param or to the login page
    regardless of whether or not the user was logged at all or not."""
    if not flask_login.current_user.is_authenticated():
        return redirect(request.args.get("next", url_for("auth.login")))
    user = flask_login.current_user
    flask_login.logout_user()
    return redirect(request.args.get("next", url_for("auth.login")))
Beispiel #2
0
def sign_out():
    #Remove tokens if they're present...
    session.pop('twitter_token', None)
    session.pop('linkedin_token', None)
    session.pop('facebook_access_token', None)   
    session.pop('facebook_code', None)    
    logout_user()
    return redirect(url_for('index', _external=True))
Beispiel #3
0
def logout():
    """Log the user out.  Redirect to the "next" param or to the login page
    regardless of whether or not the user was logged at all or not."""
    if not flask_login.current_user.is_authenticated():
        return redirect(request.args.get("next", url_for("auth.login")))
    user = flask_login.current_user
    flask_login.logout_user()
    return redirect(request.args.get("next", url_for("auth.login")))
Beispiel #4
0
def blog_delete(id):
    blog = current_user
    if id != blog.id:
        abort(403)
    db.session.delete(blog)
    db.session.commit()
    logout_user()
    return jsonify()
Beispiel #5
0
def logout():
    """ *logout* method
    
        Call logout_user() and redirect to index page.
    """
    logout_user()
    flash("Logged out.")
    return redirect(url_for("login"))
Beispiel #6
0
def logout():
	"""
		Log the user out.
	"""
	current_app.logger.debug('Logging out user')
	current_app.logger.debug('current user id:' + current_user.get_id())
	logout_user()
	flash(u"Logged out.")
	return redirect(url_for('index'))
Beispiel #7
0
def logout():
    '''
    Página para desloguear usuario.
    '''
    if current_user.is_authenticated():
        logout_user()
        logout_oauth()
        del(session["user"])

    return redirect(url_for('index.home',lang=None))
Beispiel #8
0
def logout():
    """
    Logs out current user

    """
    current_app.logger.info('{0} logout from {1}'.format(session['user'].username, request.remote_addr))
    session.pop('user')
    logout_user()
    flash(messages.LOGGED_OUT)
    return redirect(url_for('index'))
Beispiel #9
0
def logout():
    # Remove the user information from the session
    logout_user()
    # Remove session keys set by Flask-Principal
    for key in ('identity.name', 'identity.auth_type'):
        session.pop(key, None)
           
    identity_changed.send(current_app._get_current_object(),
                          identity=AnonymousIdentity())
    flash(u"你已登出。", "successfully")
    return redirect(request.args.get('next') or url_for('home.index'))
Beispiel #10
0
def logout():
    # Remove the user information from the session
    logout_user()
    # Remove session keys set by Flask-Principal
    for key in ('identity.name', 'identity.auth_type'):
        session.pop(key, None)

    identity_changed.send(current_app._get_current_object(),
                          identity=AnonymousIdentity())
    flash(u"你已登出。", "successfully")
    return redirect(request.args.get('next') or url_for('home.index'))
Beispiel #11
0
def resetpass():
    user = current_user
    if 'activation_key' in request.values and request.values['activation_key']:
        user = User.query.filter_by(
            activation_key=request.values['activation_key']).first()
    if user is None:
        abort(403)
    # setup new password
    form = ResetPasswordForm(activation_key=user.activation_key)
    if form.validate_on_submit():
        user.password = form.password.data
        user.activation_key = None
        user.save()
        flash(u"你的密码已成功重设。", "successfully")
        if current_user:
            logout_user()
        return redirect(url_for("account.login"))
    return render_template("account/resetpass.html", form=form)
Beispiel #12
0
def resetpass():
    user = current_user
    if 'activation_key' in request.values and request.values['activation_key']:
        user = User.query.filter_by(
            activation_key=request.values['activation_key']).first()
    if user is None:
        abort(403)
    # setup new password
    form = ResetPasswordForm(activation_key=user.activation_key)
    if form.validate_on_submit():
        user.password = form.password.data
        user.activation_key = None
        user.save()
        flash(u"你的密码已成功重设。", "successfully")
        if current_user:
            logout_user()
        return redirect(url_for("account.login"))
    return render_template("account/resetpass.html", form=form)
Beispiel #13
0
def logout():
    logout_user()
    flash('You are now logged out', 'success')
    return redirect(url_for('home'))
Beispiel #14
0
def logout():
    logout_user()
    return redirect('/')
Beispiel #15
0
def signout():
    login.logout_user()
    flask.flash(u'You have been signed out.')
    return flask.redirect(flask.url_for('welcome'))
Beispiel #16
0
def logout():
    logout_user()
    flash("You were logged out")
    return redirect(url_for("public.index"))
Beispiel #17
0
def logout():
    logout_user()
Beispiel #18
0
def logout():
    logout_user()
    return redirect(url_for("view_post"))
Beispiel #19
0
def logout():
    logout_user()
    flash('You have been logged out')
    return redirect(url_for('home'))
Beispiel #20
0
 def logout():
     logout_user()
     return redirect(url_for('index'))
Beispiel #21
0
def logout():
    current_user.lastauth = None
    db.session.add(current_user)
    db.session.commit()
    logout_user()
    return redirect(url_for('.index'))
Beispiel #22
0
def logout():
	logout_user()
	return redirect(url_for("mainPage"))
Beispiel #23
0
 def logout():
     logout_user()
     return u"Logged out"
Beispiel #24
0
def signout():
    logout_user()
    flash("You are now signed out", "success")
    return redirect(url_for("home"))
Beispiel #25
0
def logout():
	logout_user()
	return redirect(url_for("index"))
Beispiel #26
0
def logout():
    logout_user()
    flash("Logged out.")
    return redirect(url_for("index"))
Beispiel #27
0
def logout():
	logout_user()
	return redirect(url_for('login'))
Beispiel #28
0
def logout():
    logout_user()
    return redirect(request.args.get("next") or url_for("times.index"))
Beispiel #29
0
def logout():
    logout_user()
    flash('You have been successfully logged out!','event')
    return redirect('/')
Beispiel #30
0
def logout():
    bread = base_bread() + [('Login', url_for('.logout'))]
    logout_user()
    flask.flash("You are logged out now. Have a nice day!")
    return flask.redirect(
        request.args.get("next") or request.referrer or url_for('.info'))
Beispiel #31
0
 def logout():
     logout_user()
     redirect_url = find_redirect(POST_LOGOUT_VIEW_KEY, config)
     current_app.logger.debug(DEBUG_LOGOUT % redirect_url)
     return redirect(redirect_url)
Beispiel #32
0
def logout():
    logout_user()
    return redirect(url_for("login"))
Beispiel #33
0
def login():
    """ *login* method
    
        This method get username and password from request form and validate it.
        If they are valid create a ticket for the current user using a SECRET_KEY shared with plone. After
        is create a cookie with the ticket and domain linked to came_from.
        
        Return response.
    """
    error = None
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        domain = request.args.get("domain", "")

        if not username and not password:
            return render_template('login.html', error='Insert username and password!')

        else:
            validate_user = validate_username(username)
            validate_bt = validate_to_biomedtown(username, password)

            if validate_bt is False:
                return render_template('login.html', error='Invalid password!', username=username)
            else:
                if validate_user is not True:
                    ins = usersTable.insert().values(name=username).execute()
                    lastid = ins.last_inserted_ids()[0]
                    USERS[lastid] = User(username, lastid)
                    USER_NAMES[username] = USERS[lastid]

                # user_data = [ud for ud in validate_bt.values()]
                user_data = [validate_bt['nickname'],
                             validate_bt['fullname'],
                             validate_bt['email'],
                             validate_bt['language'],
                             validate_bt['country'],
                             validate_bt['postcode']
                ]
                remember = request.form.get("remember", "no") == "yes"
                if login_user(USER_NAMES[username], remember=remember):
                    flash("Logged in!")
                    cip = str(request.remote_addr)
                    validuntil = int(time.time()) + TIMEOUT
                    ticket = TICKET.createTkt(request.form['username'], tokens=(), user_data=user_data, cip=cip,
                                              validuntil=validuntil)

                    #ticket = createTicket(app.config['SECRET_KEY'], request.form['username'], tokens=(), user_data=user_data)
                    ticket_b64 = binascii.b2a_base64(ticket).rstrip()
                    if str(domain).lower().count("vphshare"):
                        # we have to retrive the user roles from the MI
                        validate_tkt_response = requests.get(
                            app.config['MASTERINTERFACE_VALIDATE_TKT_SERVICE'] % ticket_b64,
                            verify = False
                        )

                        mi_user_data = json.loads(validate_tkt_response.text)
                        tokens = mi_user_data.get('role', [])

                        ticket = TICKET.createTkt(validate_bt['nickname'], tokens=tokens, user_data=user_data, cip=cip, validuntil=validuntil)
                        ticket_b64 = binascii.b2a_base64(ticket).rstrip()

                    if request.args.get("came_from"):
                        came_from = request.args.get("came_from")

                        #iif came_from.count("physiomespace"):
                        came_from = "%s?ticket=%s" % ( came_from, ticket_b64 )
                        response = redirect(came_from, 302)
                    else:
                        response = app.make_response(render_template('index.html'))

                    response.set_cookie('bt-tkt', ticket_b64, domain='.biomedtown.org')
                    response.set_cookie('bt-tkt', ticket_b64, domain='.vph-share.eu')

                    return response

    elif request.method == 'GET' and request.args.get("came_from") and current_user.is_authenticated():
        # incoming request from mod auth ticket third party
        ticket_b64 = request.cookies.get('bt-tkt')
        ticket = binascii.a2b_base64(str(ticket_b64))
        domain = request.args.get("domain", "")
        #if validateTicket(app.config['SECRET_KEY'], ticket, timeout=app.config['TIME_OUT']) is not None:
        try:
            cip = str(request.remote_addr)
            if isinstance(TICKET, SignedTicket):
                data = ticket
            else:
                data = ticket, cip
            
            if TICKET.validateTkt(data) is not None:
                flash("Logged in!")
                userid, tocken, userdata, validuntil = TICKET.validateTkt(data)
                validuntil = int(time.time()) + TIMEOUT
                if str(domain).lower().count("vphshare"):
                    # we have to retrive the user roles from the MI
                    validate_tkt_response = requests.get(
                        app.config['MASTERINTERFACE_VALIDATE_TKT_SERVICE'] % ticket_b64,
                        verify = False
                    )

                    mi_user_data = json.loads(validate_tkt_response.text)
                    tokens = mi_user_data.get('role', [])

                    ticket = TICKET.createTkt(userid, tokens=tokens, user_data=userdata, cip=cip, validuntil=validuntil)
                    ticket_b64 = binascii.b2a_base64(ticket).rstrip()

                came_from = request.args.get("came_from")
                target_domain = ".%s" % ".".join(came_from.replace("http://", "").split(".")[1:]).split("/")[0]

                #if came_from.count("physiomespace"):
                came_from = "%s?ticket=%s" % (came_from, ticket_b64)

                # redirect return a response object
                response = redirect(came_from, 307)
                response.set_cookie('bt-tkt', ticket_b64, domain=target_domain)

                return response
            else:
                logout_user()
        except Exception, e:
            pass
Beispiel #34
0
def logout():
    logout_user()
    flash("You were logged out")
    return redirect(url_for("public.index"))
Beispiel #35
0
def logout():
    logout_user()
    return redirect(url_for("view_post"))
Beispiel #36
0
def logout():
    logout_user()
    return redirect(url_for('home'))
Beispiel #37
0
def logout():
    logout_user()
    flash('See you soon.', 'success')
    return redirect(url_for('index'))
Beispiel #38
0
def logout():
    logout_user()
    flash('See you soon.', 'success')
    return redirect(url_for('index'))
Beispiel #39
0
def logout():
    logout_user()
    return redirect(request.args.get("next") or url_for("index"))
Beispiel #40
0
def logout():
    logout_user()
    flash(u"你已退出后台管理界面,如需进行设置请登录")
    return redirect(url_for('frontend.index'))
Beispiel #41
0
def signout():
  login.logout_user()
  flask.flash(u'You have been signed out.')
  return flask.redirect(flask.url_for('welcome'))
Beispiel #42
0
def signout():
    logout_user()
    return redirect(url_for('home'))
Beispiel #43
0
def logout():
    logout_user()
    flash(u"你已退出后台管理界面,如需进行设置请登录")
    return redirect(url_for('account.login'))
Beispiel #44
0
def signout():
    logout_user()
    flash('You are now signed out', 'success')
    return redirect(url_for('home'))
Beispiel #45
0
def logout():
    logout_user()
    return redirect(url_for('web.index'))
Beispiel #46
0
def logout():
    current_user.authenticated = False
    db.session.commit()
    logout_user()
    flash("Logout succeeded.")
    return redirect(url_for("home"))