Skip to content

Commit

Permalink
Check if mail is verified for login
Browse files Browse the repository at this point in the history
  • Loading branch information
bguillot committed Sep 24, 2024
1 parent 5ea75ac commit b7069de
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions fastapi_auth_partner/models/fastapi_auth_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class FastApiAuthDirectory(models.Model):
groups="fastapi_auth_partner.group_partner_auth_manager",
)
sliding_session = fields.Boolean()
force_verified_email = fields.Boolean(
help="If checked, email must be verified to be able to log in"
)

def _compute_count_partner(self):
data = self.env["fastapi.auth.partner"].read_group(
Expand Down
2 changes: 1 addition & 1 deletion fastapi_auth_partner/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _login(self, directory, data):
.sudo()
.log_in(directory, data.login.lower(), data.password)
)
if partner_auth:
if partner_auth and (not directory.force_verified_email or partner_auth.mail_verified):
return partner_auth
else:
raise AccessError(_("Invalid Login or Password"))
Expand Down
1 change: 1 addition & 0 deletions fastapi_auth_partner/views/fastapi_auth_directory_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<field name="cookie_duration" />
<field name="sliding_session" />
<field name="set_password_token_duration" />
<field name="force_verified_email" />
</group>
<group
name="impersonate"
Expand Down

0 comments on commit b7069de

Please sign in to comment.