If a user fails to login with three attempts, I want that the administrator will be notified and the account blocked one day or the administrator unblock it.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
1
Odpowiedz
5756
Widoki
Hi, I think you can follow these steps
1. Create login attempts session value
You will increment this value each time the user fail to connect
2. Deactivate the user if the login attempts session value is great than three
When the value will be greater than three, you will disable the user.
You can write a cron to reactivate the user, if you want.
I tried to make something. It works for me
# -*- coding: utf-8 -*-
from odoo import http
from odoo.http import request
from odoo.addons.web.controllers.main import Home
class LoginAttempts(Home):
@http.route()
def web_login(self, redirect=None, **kw):
response = super(LoginAttempts, self).web_login(redirect=redirect, **kw)
if response.qcontext.get('error'):
# Get LoginAttempts in session
login_attempts = request.session.get('loginAttempts')
if not login_attempts:
login_attempts = 0
# If user have done more than three login attemps
if int(login_attempts) >= 2:
# We search the user
user = request.env['res.users'].search([('login','=',kw.get('login'))])
if user:
# If we found it, you desactive it
user.write({'active': False})
login_attempts = -1
response.qcontext['error'] = "%s . %s" %(response.qcontext.get('error'), 'Your account is deactivate. Please contact the administrator')
# ... Send here an email to the administrator
# ... And other action that you want to make
request.session['loginAttempts'] = login_attempts + 1
return response
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
1
lut 20
|
4655 | ||
|
1
lip 25
|
4154 | ||
|
1
maj 19
|
2700 | ||
Odoo 12 shows a blank page after login?
Rozwiązane
|
|
3
sty 24
|
12317 | |
|
1
paź 19
|
6938 |