add github support, fix redirect on oauth
This commit is contained in:
parent
4fede50136
commit
4375db4f8c
|
@ -17,6 +17,16 @@ providers = {
|
|||
authorize_url='https://api.twitter.com/oauth/authenticate',
|
||||
access_token_method='GET'),
|
||||
'button': '<a href="/login/oauth/twitter" class="btn btn-default"><i class="fa fa-twitter"></i> Twitter</a>'
|
||||
},
|
||||
'github': {
|
||||
'oauth': dict(
|
||||
request_token_params={'scope': 'user:email'},
|
||||
base_url='https://api.github.com/',
|
||||
request_token_url=None,
|
||||
access_token_method='POST',
|
||||
access_token_url='https://github.com/login/oauth/access_token',
|
||||
authorize_url='https://github.com/login/oauth/authorize'),
|
||||
'button': '<a href="/login/oauth/github" class="btn btn-default"><i class="fa fa-github"></i> Github</a>'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,8 +79,8 @@ class User(BaseUser):
|
|||
|
||||
@staticmethod
|
||||
def login_form():
|
||||
buttons = ''
|
||||
buttons = []
|
||||
for k, v in providers.items():
|
||||
buttons += v.get('button')
|
||||
buttons.append(v.get('button'))
|
||||
|
||||
return buttons
|
||||
return " ".join(buttons)
|
||||
|
|
|
@ -16,7 +16,7 @@ def login(provider):
|
|||
|
||||
@blueprint.route('/login/oauth/<provider>/callback')
|
||||
def callback(provider):
|
||||
next_url = request.args.get('next') or current_app.config['ROOT_ENDPOINT']
|
||||
next_url = request.args.get('next') or url_for(current_app.config['ROOT_ENDPOINT'])
|
||||
try:
|
||||
resp = User.get_app(provider).authorized_response()
|
||||
if resp is None:
|
||||
|
|
Loading…
Reference in a new issue