本文整理汇总了Python中util.get_next_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_next_url函数的具体用法?Python get_next_url怎么用?Python get_next_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_next_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: yahoo_authorized
def yahoo_authorized(resp):
if resp is None:
flask.flash(u'You denied the request to sign in.')
return flask.redirect(util.get_next_url())
flask.session['oauth_token'] = (
resp['oauth_token'],
resp['oauth_token_secret'],
)
try:
yahoo_guid = yahoo.get(
'/v1/me/guid', data={'format': 'json', 'realm': 'yahooapis.com'}
).data['guid']['value']
profile = yahoo.get(
'/v1/user/%s/profile' % yahoo_guid,
data={'format': 'json', 'realm': 'yahooapis.com'}
).data['profile']
except:
flask.flash(
'Something went wrong with Yahoo! sign in. Please try again.',
category='danger',
)
return flask.redirect(util.get_next_url())
user_db = retrieve_user_from_yahoo(profile)
return signin_user_db(user_db)
示例2: signin_twitter
def signin_twitter():
flask.session.pop('oauth_token', None)
try:
return twitter.authorize(
callback=flask.url_for('twitter_authorized', next=util.get_next_url()),
)
except:
flask.flash(
'Something went terribly wrong with Twitter sign in. Please try again.',
category='danger',
)
return flask.redirect(flask.url_for('signin', next=util.get_next_url()))
示例3: signin
def signin():
next_url = util.get_next_url()
form = None
if config.CONFIG_DB.has_email_authentication:
form = form_with_recaptcha(SignInForm())
save_request_params()
if form.validate_on_submit():
result = get_user_db_from_email(form.email.data, form.password.data)
if result:
cache.reset_auth_attempt()
return signin_user_db(result)
if result is None:
form.email.errors.append('Email or Password do not match')
if result is False:
return flask.redirect(flask.url_for('welcome'))
if not form.errors:
form.next_url.data = next_url
if form and form.errors:
cache.bump_auth_attempt()
return flask.render_template(
'auth/auth.html',
title='Sign in',
html_class='auth',
next_url=next_url,
form=form,
form_type='signin' if config.CONFIG_DB.has_email_authentication else '',
**urls_for_oauth(next_url)
)
示例4: signin
def signin():
next_url = util.get_next_url()
if flask.url_for('signin') in next_url:
next_url = flask.url_for('welcome')
bitbucket_signin_url = flask.url_for('signin_bitbucket', next=next_url)
dropbox_signin_url = flask.url_for('signin_dropbox', next=next_url)
facebook_signin_url = flask.url_for('signin_facebook', next=next_url)
github_signin_url = flask.url_for('signin_github', next=next_url)
google_signin_url = flask.url_for('signin_google', next=next_url)
linkedin_signin_url = flask.url_for('signin_linkedin', next=next_url)
twitter_signin_url = flask.url_for('signin_twitter', next=next_url)
vk_signin_url = flask.url_for('signin_vk', next=next_url)
windowslive_signin_url = flask.url_for('signin_windowslive', next=next_url)
return flask.render_template(
'signin.html',
title='Please sign in',
html_class='signin',
bitbucket_signin_url=bitbucket_signin_url,
dropbox_signin_url=dropbox_signin_url,
facebook_signin_url=facebook_signin_url,
github_signin_url=github_signin_url,
google_signin_url=google_signin_url,
linkedin_signin_url=linkedin_signin_url,
twitter_signin_url=twitter_signin_url,
vk_signin_url=vk_signin_url,
windowslive_signin_url=windowslive_signin_url,
next_url=next_url,
)
示例5: login
def login():
next_url = util.get_next_url()
if flask.url_for("auth.login") in next_url:
next_url = flask.url_for("pages.index")
google_login_url = flask.url_for("auth.login_google", next=next_url)
twitter_login_url = flask.url_for("auth.login_twitter", next=next_url)
facebook_login_url = flask.url_for("auth.login_facebook", next=next_url)
vk_login_url = flask.url_for("auth.login_vk", next=next_url)
yandex_login_url = flask.url_for("auth.login_yandex", next=next_url)
mailru_login_url = flask.url_for("auth.login_mailru", next=next_url)
odnoklassniki_login_url = flask.url_for("auth.login_odnoklassniki", next=next_url)
return flask.render_template(
"auth/login.html",
title="Login",
html_class="login",
google_login_url=google_login_url,
twitter_login_url=twitter_login_url,
facebook_login_url=facebook_login_url,
vk_login_url=vk_login_url,
yandex_login_url=yandex_login_url,
mailru_login_url=mailru_login_url,
odnoklassniki_login_url=odnoklassniki_login_url,
next_url=next_url,
)
示例6: signin_user_db
def signin_user_db(user_db):
if not user_db:
return flask.redirect(flask.url_for('welcome'))
flask_user_db = FlaskUser(user_db)
if login.login_user(flask_user_db):
user_db.put_async()
flask.flash('Hello %s, welcome to %s!!!' % (
user_db.name, config.CONFIG_DB.brand_name,
), category='success')
return flask.redirect(util.get_next_url())
else:
flask.flash('Sorry, but you could not sign in.', category='danger')
return flask.redirect(flask.url_for('welcome'))
#def get_or_create_google_plus_user(google_id, access_token, expires_at, refresh_token, **params):
# user = model.User.retrieve_one_by('username', google_id['name'])
# if user is None:
# user = current_user_db()
# user.google_display_name = google_id['name']
# user.google_plus_id = google_id['id']
# if google_id.has_key('picture'):
# user.google_public_profile_url = google_id['picture']
# user.access_token = access_token
# user.expires_at = expires_at
# user.refresh_token = refresh_token
#
# user.put()
# return user
示例7: signup
def signup():
next_url = util.get_next_url()
form = None
if config.CONFIG_DB.has_email_authentication:
form = form_with_recaptcha(SignUpForm())
save_request_params()
if form.validate_on_submit():
user_db = model.User.get_by('email', form.email.data)
if user_db:
form.email.errors.append('This email is already taken.')
if not form.errors:
user_db = create_user_db(
None,
util.create_name_from_email(form.email.data),
form.email.data,
form.email.data,
)
user_db.put()
task.activate_user_notification(user_db)
cache.bump_auth_attempt()
return flask.redirect(flask.url_for('welcome'))
if form and form.errors:
cache.bump_auth_attempt()
title = 'Sign up' if config.CONFIG_DB.has_email_authentication else 'Sign in'
return flask.render_template(
'auth/auth.html',
title=title,
html_class='auth',
next_url=next_url,
form=form,
**urls_for_oauth(next_url)
)
示例8: login_twitter
def login_twitter():
flask.session.pop("oauth_token", None)
try:
return twitter.authorize(callback=flask.url_for("auth.twitter_oauth_authorized", next=util.get_next_url()))
except:
flask.flash("Something went terribly wrong with Twitter login. Please try again.", category="danger")
return flask.redirect(flask.url_for("auth.login", next=util.get_next_url()))
示例9: signin_github
def signin_github():
return github.authorize(
callback=flask.url_for('github_authorized',
next=util.get_next_url(),
_external=True
)
)
示例10: signin_bitbucket
def signin_bitbucket():
flask.session['oauth_token'] = None
return bitbucket.authorize(
callback=flask.url_for('bitbucket_authorized',
next=util.get_next_url(),
_external=True,
)
)
示例11: signin_twitter
def signin_twitter():
flask.session.pop("oauth_token", None)
save_request_params()
try:
return twitter.authorize(callback=flask.url_for("twitter_authorized"))
except:
flask.flash("Something went wrong with Twitter sign in. Please try again.", category="danger")
return flask.redirect(flask.url_for("signin", next=util.get_next_url()))
示例12: google_authorized
def google_authorized():
google_user = users.get_current_user()
if google_user is None:
flask.flash(u'Вы отвергли запрос на вход.')
return flask.redirect(util.get_next_url())
user_db = retrieve_user_from_google(google_user)
return signin_user_db(user_db)
示例13: google_authorized
def google_authorized():
google_user = users.get_current_user()
if google_user is None:
flask.flash(u"You denied the request to sign in.")
return flask.redirect(util.get_next_url())
user_db = retrieve_user_from_google(google_user)
return login_user_db(user_db)
示例14: login_yandex
def login_yandex():
params = dict(yandex.request_token_params)
params["client_id"] = yandex.consumer_key
params["response_type"] = "code"
params["state"] = util.get_next_url()
flask.session[yandex.name + "_oauthredir"] = flask.url_for("auth.yandex_authorized")
url = add_query(yandex.expand_url(yandex.authorize_url), params)
return flask.redirect(url)
示例15: gae_authorized
def gae_authorized():
gae_user = users.get_current_user()
if gae_user is None:
flask.flash('You denied the request to sign in.')
return flask.redirect(util.get_next_url())
user_db = retrieve_user_from_gae(gae_user)
return auth.signin_user_db(user_db)