Handle some of the error cases with github login.
This commit is contained in:
parent
bb5fea6a5f
commit
87ff939ad2
5 changed files with 86 additions and 24 deletions
|
@ -72,13 +72,8 @@ def create_user_api():
|
|||
send_confirmation_email(new_user.username, new_user.email, code.code)
|
||||
return make_response('Created', 201)
|
||||
except model.DataModelException as ex:
|
||||
message = ex.message
|
||||
m = re.search('column ([a-zA-Z]+) is not unique', message)
|
||||
if m and m.group(1):
|
||||
message = m.group(1) + ' already exists'
|
||||
|
||||
error_resp = jsonify({
|
||||
'message': message,
|
||||
'message': ex.message,
|
||||
})
|
||||
error_resp.status_code = 400
|
||||
return error_resp
|
||||
|
|
|
@ -135,14 +135,18 @@ def github_oauth_callback():
|
|||
to_login = model.verify_federated_login('github', github_id)
|
||||
if not to_login:
|
||||
# try to create the user
|
||||
to_login = model.create_federated_user(username, found_email, 'github',
|
||||
github_id)
|
||||
|
||||
try:
|
||||
to_login = model.create_federated_user(username, found_email, 'github',
|
||||
github_id)
|
||||
except model.DataModelException, ex:
|
||||
return render_template('githuberror.html', error_message=ex.message)
|
||||
|
||||
if common_login(to_login):
|
||||
return redirect(url_for('index'))
|
||||
|
||||
# TODO something bad happened, we need to tell the user somehow
|
||||
return redirect(url_for('signin'))
|
||||
return render_template('githuberror.html')
|
||||
|
||||
|
||||
@app.route('/confirm', methods=['GET'])
|
||||
|
|
Reference in a new issue