From 1fef46a41d48dacb7c141c72f4c654aca0ca7188 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 09 2018 16:36:54 +0000 Subject: Improve the info message when trying to setup an user with a known email Fixes https://pagure.io/pagure/issue/2983 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/ui/fas_login.py b/pagure/ui/fas_login.py index aed51f2..0d33cd0 100644 --- a/pagure/ui/fas_login.py +++ b/pagure/ui/fas_login.py @@ -35,9 +35,20 @@ def set_user(return_url): return flask.redirect(return_url) flask.session['_new_user'] = False - if not pagure.lib.search_user( - flask.g.session, username=flask.g.fas_user.username): + user = pagure.lib.search_user( + flask.g.session, username=flask.g.fas_user.username) + if not user: flask.session['_new_user'] = True + else: + user_email = pagure.lib.search_user( + flask.g.session, email=flask.g.fas_user.email) + if user_email and user_email.user != user.user: + flask.flash( + 'This email address seems to already be associated with ' + 'another account and thus can not be associated with yours', + 'error') + logout() + return flask.redirect(return_url) try: pagure.lib.set_up_user(