Skip to content
Snippets Groups Projects
Commit 50d2c91a authored by Emmanuel Viennet's avatar Emmanuel Viennet
Browse files

Connexion CAS / non CAS: correctif

parent d98eb7dc
No related branches found
No related tags found
No related merge requests found
...@@ -180,7 +180,7 @@ class User(UserMixin, ScoDocModel): ...@@ -180,7 +180,7 @@ class User(UserMixin, ScoDocModel):
def set_password(self, password): def set_password(self, password):
"Set password" "Set password"
current_app.logger.info(f"set_password({self})") log(f"set_password({self})")
if password: if password:
self.password_hash = generate_password_hash(password) self.password_hash = generate_password_hash(password)
else: else:
...@@ -213,10 +213,21 @@ class User(UserMixin, ScoDocModel): ...@@ -213,10 +213,21 @@ class User(UserMixin, ScoDocModel):
# if CAS activated and cas_id, allow only super-user and users with cas_allow_scodoc_login # if CAS activated and cas_id, allow only super-user and users with cas_allow_scodoc_login
cas_enabled = ScoDocSiteConfig.is_cas_enabled() cas_enabled = ScoDocSiteConfig.is_cas_enabled()
if cas_enabled: if cas_enabled and not self.is_administrator():
if ScoDocSiteConfig.get("cas_force") and not self.is_administrator(): if not self.cas_allow_scodoc_login:
return False # si CAS forcé, n'accepte que super-admin # CAS activé et compte non autorisé à se logguer sur ScoDoc
if self.cas_id and not self.cas_allow_scodoc_login: log(
f"""auth: login attempt for user {self.user_name}: scodoc login not allowed
"""
)
return False
# si CAS activé et forcé et cas_id renseigné, on ne peut pas se logguer
if self.cas_id and ScoDocSiteConfig.get("cas_force"):
log(
f"""auth: login attempt for user {self.user_name
} (cas_id='{
self.cas_id}'): cas forced and cas_id set: scodoc login not allowed"""
)
return False return False
if not self.password_hash: # user without password can't login if not self.password_hash: # user without password can't login
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"Infos sur version ScoDoc" "Infos sur version ScoDoc"
SCOVERSION = "9.7.41" SCOVERSION = "9.7.42"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment