Handle non-existing users in register_cas_account
This commit is contained in:
parent
1fc2a04040
commit
351b084419
1 changed files with 5 additions and 1 deletions
|
@ -59,7 +59,11 @@ def register_cas_account(user: User, cas_login: str) -> CASAccount:
|
||||||
if OldCASAccount.objects.filter(user=user).exists():
|
if OldCASAccount.objects.filter(user=user).exists():
|
||||||
raise ValueError("User '{}' has an old CAS account".format(user))
|
raise ValueError("User '{}' has an old CAS account".format(user))
|
||||||
|
|
||||||
entrance_year = fetch_cas_account(cas_login)["entrance_year"]
|
ldap_info = fetch_cas_account(cas_login)
|
||||||
|
if ldap_info is None:
|
||||||
|
raise ValueError("There is no LDAP user for id '{}'".format(cas_login))
|
||||||
|
|
||||||
|
entrance_year = ldap_info["entrance_year"]
|
||||||
return CASAccount.objects.create(
|
return CASAccount.objects.create(
|
||||||
user=user, cas_login=cas_login, entrance_year=entrance_year
|
user=user, cas_login=cas_login, entrance_year=entrance_year
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue