Esempio n. 1
0
def create_or_login(resp):
	app.logger.debug(json.dumps(resp))
	#session['openid'] = resp.identity_url

	#user = User.query.filter_by(openid=resp.identity_url).first()
	# if user is not None:
	#     flash(u'Successfully signed in')
	#     g.user = user
	#     return redirect(oid.get_next_url())
	return redirect(url_for('user_profile', next=oid.get_next_url(),
							name=resp.fullname or resp.nickname,
							email=resp.email))
Esempio n. 2
0
def login():
	"""
	show login page
	"""
	try:
		if request.args.get("openid_identifier") is not None:
			openid = request.args.get("openid_identifier")
			return oid.try_login(openid, ask_for=['email', 'fullname',
												  'nickname', 'language', 'image', 'timezone'])
		else:
			return render_template("login.html", next=oid.get_next_url(), error = oid.fetch_error())
	except TemplateNotFound:
		app.logger.error("template user/login.html not found")
		abort(404)
Esempio n. 3
0
def login():
    """
	show login page
	"""
    try:
        if request.args.get("openid_identifier") is not None:
            openid = request.args.get("openid_identifier")
            return oid.try_login(openid,
                                 ask_for=[
                                     'email', 'fullname', 'nickname',
                                     'language', 'image', 'timezone'
                                 ])
        else:
            return render_template("login.html",
                                   next=oid.get_next_url(),
                                   error=oid.fetch_error())
    except TemplateNotFound:
        app.logger.error("template user/login.html not found")
        abort(404)
Esempio n. 4
0
def after_login(resp):
    if resp.email is None or resp.email == "":
        flash('Invalid login. Please try again.')
        return redirect(url_for('login'))

    if resp.email not in allowed_emails:
        flash('Not valid email')
        return redirect(url_for('login'))

    user = User()
    user.id = resp.email
    user.email = resp.email

    remember_me = False
    if 'remember_me' in session:
        remember_me = session['remember_me']
        session.pop('remember_me', None)
    login_user(user, remember=remember_me)

    return redirect(oid.get_next_url() or url_for('home'))