@ -0,0 +1,50 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
||||
|
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
User Login Alert |
||||
|
================ |
||||
|
This module will help to send the notification to users on successful login to his account. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
- www.odoo.com/documentation/17.0/setup/install.html |
||||
|
- Install our custom addon |
||||
|
- Set outgoing mail server, The Email will be send to Users related partners Email ID. |
||||
|
So, give an email for user related partner and also make sure he has "Receive Login Notification" user group. |
||||
|
- Also install the "httpagentparser" python package, sudo pip install httpagentparser |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
License |
||||
|
------- |
||||
|
AFFERO General Public License, Version 3 (AGPL v3). |
||||
|
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
Developer: |
||||
|
(V17) Mohammed Dilshad Tk, |
||||
|
(V18) Nandakishore M, |
||||
|
Contact: odoo@cybrosys.com |
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
For support and more information, please visit https://www.cybrosys.com |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,23 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Nandakishore M (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU Affero General Public License (AGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from . import controllers |
||||
|
from . import models |
@ -0,0 +1,46 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Nandakishore M (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU Affero General Public License (AGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
{ |
||||
|
'name': 'User Login Alert', |
||||
|
'version': '18.0.1.0.0', |
||||
|
'category': 'Extra Tools', |
||||
|
'summary': """Secure Odoo account by alerts user about any login |
||||
|
happened from any systems""", |
||||
|
'description': """Secure your Odoo account by alerts at right time. If any |
||||
|
successful login to user's account happens, an alert mail will be send to |
||||
|
user with the browser and IP details.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer ': 'Cybrosys Techno Solutions', |
||||
|
'website': 'https://www.cybrosys.com', |
||||
|
'depends': ['mail'], |
||||
|
'data': [ |
||||
|
'security/user_login_alert_groups.xml', |
||||
|
'views/res_users_views.xml', |
||||
|
], |
||||
|
'external_dependencies': {'python': ['httpagentparser']}, |
||||
|
'images': ['static/description/banner.png'], |
||||
|
'license': 'AGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Nandakishore M (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU Affero General Public License (AGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from . import home |
@ -0,0 +1,114 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Nandakishore M (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU Affero General Public License (AGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from time import gmtime, strftime |
||||
|
import odoo |
||||
|
import odoo.modules.registry |
||||
|
|
||||
|
try: |
||||
|
import httpagentparser |
||||
|
except ImportError: |
||||
|
pass |
||||
|
from odoo import http |
||||
|
from odoo.tools.translate import _ |
||||
|
from odoo.http import request |
||||
|
from odoo.addons.web.controllers import home |
||||
|
|
||||
|
|
||||
|
class Home(home.Home): |
||||
|
"""Inherit Home to add features login page""" |
||||
|
|
||||
|
@http.route(route='/web/login', type='http', auth="public") |
||||
|
def web_login(self, redirect=None, **kw): |
||||
|
"""Method that check if user login in any system firstly, |
||||
|
an email will send to user related partner's mail. """ |
||||
|
home.ensure_db() |
||||
|
request.params['login_success'] = False |
||||
|
if (request.httprequest.method == 'GET' and redirect |
||||
|
and request.session.uid): |
||||
|
return request.redirect(redirect) |
||||
|
if not request.uid: |
||||
|
request.uid = odoo.SUPERUSER_ID |
||||
|
values = request.params.copy() |
||||
|
try: |
||||
|
values['databases'] = http.db_list() |
||||
|
except odoo.exceptions.AccessDenied: |
||||
|
values['databases'] = None |
||||
|
if request.httprequest.method == 'POST': |
||||
|
credential = {'login': request.params['login'], 'password': request.params['password'], 'type': 'password'} |
||||
|
uid = request.session.authenticate(request.session.db, credential) |
||||
|
uid = uid.get('uid') |
||||
|
if uid is not False: |
||||
|
user_rec = request.env['res.users'].sudo().browse(uid) |
||||
|
request.params['login_success'] = True |
||||
|
if user_rec.partner_id.email and user_rec.has_group( |
||||
|
'user_login_alert.receive_login_notification'): |
||||
|
agent_details = httpagentparser.detect(request.httprequest. |
||||
|
environ.get( |
||||
|
'HTTP_USER_AGENT')) |
||||
|
user_os = agent_details['os']['name'] |
||||
|
browser_name = agent_details['browser']['name'] |
||||
|
ip_address = request.httprequest.environ['REMOTE_ADDR'] |
||||
|
if (user_rec.last_logged_ip and user_rec.last_logged_browser |
||||
|
and user_rec.last_logged_os): |
||||
|
if (user_rec.last_logged_ip != ip_address or |
||||
|
user_rec.last_logged_browser != browser_name or |
||||
|
user_rec.last_logged_os != user_os): |
||||
|
send_mail = 1 |
||||
|
user_rec.last_logged_ip = ip_address |
||||
|
user_rec.last_logged_browser = browser_name |
||||
|
user_rec.last_logged_os = user_os |
||||
|
else: |
||||
|
send_mail = 0 |
||||
|
else: |
||||
|
send_mail = 1 |
||||
|
user_rec.last_logged_ip = ip_address |
||||
|
user_rec.last_logged_browser = browser_name |
||||
|
user_rec.last_logged_os = user_os |
||||
|
if send_mail == 1: |
||||
|
request.env['mail.mail'].sudo().create( |
||||
|
{'subject': 'Login Alert : ' + |
||||
|
strftime("%Y-%m-%d %H:%M:%S", |
||||
|
gmtime()), |
||||
|
'body_html': ('Hi ' + user_rec.name + |
||||
|
' , Your account has been ' |
||||
|
'accessed successfully. The ' |
||||
|
'details of the system from which' |
||||
|
' the account is accessed ..., ' |
||||
|
'<table border="1" width="100%" ' |
||||
|
'cellpadding="0" ' |
||||
|
'bgcolor="#ededed"> <tr><td>' + |
||||
|
'OS' + '</td><td>' + user_os + |
||||
|
'</td></tr><tr><td>' + 'Browser' + |
||||
|
'</td><td>' + browser_name + |
||||
|
'</td></tr><tr><td>' + 'IP Address' |
||||
|
+ '</td><td>' + ip_address |
||||
|
+ '</td></tr> </table> Thank you'), |
||||
|
'email_from': request.env.user.company_id.email, |
||||
|
'email_to': user_rec.partner_id.email |
||||
|
} |
||||
|
).send() |
||||
|
if not redirect: |
||||
|
redirect = '/web' |
||||
|
return request.redirect( |
||||
|
self._login_redirect(uid, redirect=redirect)) |
||||
|
values['error'] = _("Wrong login/password") |
||||
|
return request.render('web.login', values) |
@ -0,0 +1,7 @@ |
|||||
|
## Module <user_login_alert> |
||||
|
|
||||
|
#### 19.03.2024 |
||||
|
#### Version 17.0.1.0.0 |
||||
|
#### ADD |
||||
|
|
||||
|
- Initial commit for User Login Alert |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Nandakishore M (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU Affero General Public License (AGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from . import res_users |
@ -0,0 +1,34 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
################################################################################ |
||||
|
# |
||||
|
# Cybrosys Technologies Pvt. Ltd. |
||||
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
||||
|
# Author: Nandakishore M (odoo@cybrosys.com) |
||||
|
# |
||||
|
# This program is free software: you can modify |
||||
|
# it under the terms of the GNU Affero General Public License (AGPL) as |
||||
|
# published by the Free Software Foundation, either version 3 of the |
||||
|
# License, or (at your option) any later version. |
||||
|
# |
||||
|
# This program is distributed in the hope that it will be useful, |
||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
# GNU Affero General Public License for more details. |
||||
|
# |
||||
|
# You should have received a copy of the GNU Affero General Public License |
||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
||||
|
# |
||||
|
################################################################################ |
||||
|
from odoo import fields, models |
||||
|
|
||||
|
|
||||
|
class ResUsers(models.Model): |
||||
|
"""Inherits 'res.users' to add fields""" |
||||
|
_inherit = 'res.users' |
||||
|
|
||||
|
last_logged_ip = fields.Char(string='IP', help="User lastly login Ip " |
||||
|
"address") |
||||
|
last_logged_browser = fields.Char(string='Browser', |
||||
|
help="User lastly login browser") |
||||
|
last_logged_os = fields.Char(string='OS', |
||||
|
help="User lastly login Operating system") |
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0"?> |
||||
|
<odoo> |
||||
|
<data> |
||||
|
<!-- Receive login notification groups--> |
||||
|
<record id="receive_login_notification" model="res.groups"> |
||||
|
<field name="name">Receive Login Notification</field> |
||||
|
</record> |
||||
|
</data> |
||||
|
</odoo> |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 912 KiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 71 KiB |
After Width: | Height: | Size: 260 KiB |
After Width: | Height: | Size: 286 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 9.5 KiB |
@ -0,0 +1,24 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8" ?> |
||||
|
<odoo> |
||||
|
<!-- Res users view form--> |
||||
|
<record id="view_users_form" model="ir.ui.view"> |
||||
|
<field name="name">res.users.view.form.inherit.User.login.alert</field> |
||||
|
<field name="model">res.users</field> |
||||
|
<field name="inherit_id" ref="base.view_users_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<xpath expr="//page[1]" position='after'> |
||||
|
<page string="Logged In details" groups="base.group_no_one"> |
||||
|
<group> |
||||
|
<group> |
||||
|
<field name="last_logged_ip"/> |
||||
|
</group> |
||||
|
<group> |
||||
|
<field name="last_logged_browser"/> |
||||
|
<field name="last_logged_os"/> |
||||
|
</group> |
||||
|
</group> |
||||
|
</page> |
||||
|
</xpath> |
||||
|
</field> |
||||
|
</record> |
||||
|
</odoo> |