Merge branch 'kerl/clean_username' into 'master'
Normalise les logins CAS Closes #10 See merge request klub-dev-ens/authens!7
This commit is contained in:
commit
75fd8f4581
1 changed files with 7 additions and 3 deletions
|
@ -52,14 +52,18 @@ class ENSCASBackend:
|
||||||
|
|
||||||
def authenticate(self, request, ticket=None):
|
def authenticate(self, request, ticket=None):
|
||||||
cas_client = get_cas_client(request)
|
cas_client = get_cas_client(request)
|
||||||
uid, attributes, _ = cas_client.verify_ticket(ticket)
|
cas_login, attributes, _ = cas_client.verify_ticket(ticket)
|
||||||
|
|
||||||
if not uid:
|
if cas_login is None:
|
||||||
# Authentication failed
|
# Authentication failed
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
cas_login = self.clean_cas_login(cas_login)
|
||||||
year = get_entrance_year(attributes)
|
year = get_entrance_year(attributes)
|
||||||
return self._get_or_create(uid, year)
|
return self._get_or_create(cas_login, year)
|
||||||
|
|
||||||
|
def clean_cas_login(self, cas_login):
|
||||||
|
return cas_login.strip().lower()
|
||||||
|
|
||||||
def get_free_username(self, cas_login):
|
def get_free_username(self, cas_login):
|
||||||
"""Find an available username for a new user.
|
"""Find an available username for a new user.
|
||||||
|
|
Loading…
Reference in a new issue