13 lines
542 B
Python
13 lines
542 B
Python
from authens.backends import ENSCASBackend as AuthENSBackend
|
|
from authens.utils import parse_entrance_year
|
|
|
|
|
|
class ENSCASBackend(AuthENSBackend):
|
|
# Override AuthENS backend user creation to implement the @<promo> logic
|
|
|
|
def get_free_username(self, cas_login, attributes):
|
|
entrance_year = parse_entrance_year(attributes.get("homeDirectory"))
|
|
if entrance_year is None:
|
|
return super().get_free_username(cas_login, attributes)
|
|
entrance_year %= 100
|
|
return "%s@%02d" % (cas_login, entrance_year)
|