Commit 37e3a8a5 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Improve third party login methods messages

parent f1006a6d
......@@ -150,5 +150,6 @@ AUTH_PROVIDER_NOT_ACTIVE_FOR_CREATE = "Signup using '%(provider)s' is
AUTH_PROVIDER_NOT_ACTIVE_FOR_ADD = "'%(provider)s is disabled"
AUTH_PROVIDER_ADDED = "Your new login method has been added"
AUTH_PROVIDER_ADD_FAILED = "Failed to add new login method"
AUTH_PROVIDER_ADD_EXISTS = "Account already assigned to another user."
AUTH_PROVIDER_LOGIN_TO_ADD = "Please login now to your existing account."
......@@ -107,7 +107,7 @@ def login(
affiliation = tokens.get(Tokens.SHIB_EP_AFFILIATION, '')
email = tokens.get(Tokens.SHIB_MAIL, '')
provider_info = {'eppn': eppn, 'email': email}
provider_info = {'eppn': eppn, 'email': email, 'name': realname}
# an existing user accessed the view
if request.user.is_authenticated():
......@@ -118,12 +118,14 @@ def login(
user = request.user
if not request.user.can_add_auth_provider('shibboleth',
identifier=eppn):
messages.error(request, 'Account already exists.')
messages.error(request, _(astakos_messages.AUTH_PROVIDER_ADD_FAILED) +
u' ' + _(astakos_messages.AUTH_PROVIDER_ADD_EXISTS))
return HttpResponseRedirect(reverse('edit_profile'))
user.add_auth_provider('shibboleth', identifier=eppn,
affiliation=affiliation)
messages.success(request, 'Account assigned.')
affiliation=affiliation,
provider_info=provider_info)
messages.success(request, astakos_messages.AUTH_PROVIDER_ADDED)
return HttpResponseRedirect(reverse('edit_profile'))
try:
......
......@@ -128,13 +128,14 @@ def authenticated(
user = request.user
if not request.user.can_add_auth_provider('twitter',
identifier=userid):
messages.error(request, 'Account already exists.')
messages.error(request, _(astakos_messages.AUTH_PROVIDER_ADD_FAILED) +
u' ' + _(astakos_messages.AUTH_PROVIDER_ADD_EXISTS))
return HttpResponseRedirect(reverse('edit_profile'))
user.add_auth_provider('twitter', identifier=userid,
affiliation=affiliation,
provider_info=provider_info)
messages.success(request, 'Account assigned.')
messages.success(request, astakos_messages.AUTH_PROVIDER_ADDED)
return HttpResponseRedirect(reverse('edit_profile'))
try:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment