Skip to content

Instantly share code, notes, and snippets.

@john5223
Created October 8, 2015 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john5223/66a18132c9c39b6e37eb to your computer and use it in GitHub Desktop.
Save john5223/66a18132c9c39b6e37eb to your computer and use it in GitHub Desktop.
Login.clean
try:
reg_fields = ['username', 'password', 'region', 'domain']
d = self.cleaned_data
extra = {k:v for k,v in d.iteritems() if k not in reg_fields }
self.user_cache = authenticate(request=self.request,
username=username,
password=password,
user_domain_name=domain,
auth_url=region,
**extra)
msg = 'Login successful for user "%(username)s".' % \
{'username': username}
LOG.info(msg)
except exceptions.KeystoneAuthException as exc:
msg = 'Login failed for user "%(username)s".' % \
{'username': username}
LOG.warning(msg)
raise forms.ValidationError(exc)
if hasattr(self, 'check_for_test_cookie'): # Dropped in django 1.7
self.check_for_test_cookie()
return self.cleaned_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment