diff --git a/user_login_alert/README.rst b/user_login_alert/README.rst new file mode 100644 index 000000000..a0535c3f1 --- /dev/null +++ b/user_login_alert/README.rst @@ -0,0 +1,28 @@ +User Login Alert v12 +==================== + +This module will help to send the notification to users on successful login to his account. + + +Working +======= +if user is continuously using the same system the user will be notified only once. If he changes + the browser or the OS from same system he will receive the mail. +If user logged from another system and if he come back to his original system, for the first time +he will receive the email +Configuration +============= +For the working of this module, the outgoing mail configuration has to be configured . The Email will be send +to Users related partners Email ID. If the Email ID for the related partner of the user is not given, +then the notification mail will not send. + +Also install the "httpagentparser" python package, sudo pip install httpagentparser + +Credits +======= +Cybrosys Techno Solutions +Author + Niyas Raphy(v11) + Akshay Babu(v12) +------ +* Cybrosys Techno Solutions diff --git a/user_login_alert/__init__.py b/user_login_alert/__init__.py new file mode 100644 index 000000000..c4b265080 --- /dev/null +++ b/user_login_alert/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from . import controllers +from . import models diff --git a/user_login_alert/__manifest__.py b/user_login_alert/__manifest__.py new file mode 100644 index 000000000..10c6cdede --- /dev/null +++ b/user_login_alert/__manifest__.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy(v11) +# Akshay Babu(v12)() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': 'User Login Alert', + 'summary': """Secure your Odoo account by alerts at right time. If any successful login to your + account happens, an alert mail will be send to you with the browser and IP details.""", + 'version': '12.0.1.0.0', + 'description': """Secure your Odoo account by alerts at right time. If any successful login to your + account happens, an alert mail will be send to you with the browser and IP details.""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'category': 'Tools', + 'depends': ['base', 'mail'], + 'license': 'AGPL-3', + 'data': [ + 'security/notification_group.xml', + 'views/logged_details_view.xml', + ], + 'images': ['static/description/banner.jpg'], + 'demo': [], + 'installable': True, + 'auto_install': False, + 'external_dependencies': { + 'python': ['httpagentparser'], + }, + + +} + diff --git a/user_login_alert/controllers/__init__.py b/user_login_alert/controllers/__init__.py new file mode 100644 index 000000000..baaccd7d2 --- /dev/null +++ b/user_login_alert/controllers/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from . import main diff --git a/user_login_alert/controllers/main.py b/user_login_alert/controllers/main.py new file mode 100644 index 000000000..3be64ce2c --- /dev/null +++ b/user_login_alert/controllers/main.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +try: + import httpagentparser +except ImportError: + pass +from time import gmtime, strftime +from odoo.addons.web.controllers import main +from odoo.http import request +from odoo.exceptions import Warning +import odoo +import odoo.modules.registry +from odoo.tools.translate import _ +from odoo import http + + +class Home(main.Home): + + @http.route('/web/login', type='http', auth="public") + def web_login(self, redirect=None, **kw): + main.ensure_db() + request.params['login_success'] = False + if request.httprequest.method == 'GET' and redirect and request.session.uid: + return http.redirect_with_hash(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': + old_uid = request.uid + uid = request.session.authenticate(request.session.db, request.params['login'], request.params['password']) + if uid is not False: + user_rec = request.env['res.users'].sudo().search([('id', '=', uid)]) + if user_rec.partner_id.email and user_rec.has_group('user_login_alert.receive_login_notification'): + send_mail = 0 + agent = request.httprequest.environ.get('HTTP_USER_AGENT') + agent_details = httpagentparser.detect(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: + email_to = user_rec.partner_id.email + current_date_time = strftime("%Y-%m-%d %H:%M:%S", gmtime()) + message_body = 'Hi ' + user_rec.name + ' , Your account has been ' \ + 'accessed successfully. The details of the ' \ + 'system from which the account is accessed ...,' + message_body += '' + message_body += '' \ + '' \ + ''\ + '' \ + '' \ + ''\ + '' \ + '' \ + '' + message_body += '
' + 'OS' + '' + user_os + '
' + 'Browser' + '' + browser_name + '
' + 'IP Address' + '' + ip_address + '
' + message_body += 'Thank you' + template_obj = request.env['mail.mail'] + template_data = { + 'subject': 'Login Alert : ' + current_date_time, + 'body_html': message_body, + 'email_from': request.env.user.company_id.email, + 'email_to': email_to + } + template_id = template_obj.create(template_data) + template_obj.send(template_id) + request.params['login_success'] = True + if not redirect: + redirect = '/web' + return http.redirect_with_hash(redirect) + request.uid = old_uid + values['error'] = _("Wrong login/password") + return request.render('web.login', values) diff --git a/user_login_alert/models/__init__.py b/user_login_alert/models/__init__.py new file mode 100644 index 000000000..c57de03be --- /dev/null +++ b/user_login_alert/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from . import logged_details diff --git a/user_login_alert/models/logged_details.py b/user_login_alert/models/logged_details.py new file mode 100644 index 000000000..1f3bb6461 --- /dev/null +++ b/user_login_alert/models/logged_details.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from odoo import models, fields + + +class ResUsersInherit(models.Model): + _inherit = 'res.users' + + last_logged_ip = fields.Char(string='IP') + last_logged_browser = fields.Char(string='Browser') + last_logged_os = fields.Char(string='OS') diff --git a/user_login_alert/requirements.txt b/user_login_alert/requirements.txt new file mode 100644 index 000000000..55e961707 --- /dev/null +++ b/user_login_alert/requirements.txt @@ -0,0 +1 @@ +httpagentparser==1.8.1 \ No newline at end of file diff --git a/user_login_alert/security/notification_group.xml b/user_login_alert/security/notification_group.xml new file mode 100644 index 000000000..5867cb807 --- /dev/null +++ b/user_login_alert/security/notification_group.xml @@ -0,0 +1,8 @@ + + + + + Receive Login Notification + + + \ No newline at end of file diff --git a/user_login_alert/static/description/banner.jpg b/user_login_alert/static/description/banner.jpg new file mode 100644 index 000000000..91c8a6fa3 Binary files /dev/null and b/user_login_alert/static/description/banner.jpg differ diff --git a/user_login_alert/static/description/cybro_logo.png b/user_login_alert/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/user_login_alert/static/description/cybro_logo.png differ diff --git a/user_login_alert/static/description/icon.png b/user_login_alert/static/description/icon.png new file mode 100644 index 000000000..f5418fd92 Binary files /dev/null and b/user_login_alert/static/description/icon.png differ diff --git a/user_login_alert/static/description/index.html b/user_login_alert/static/description/index.html new file mode 100644 index 000000000..4f63fd8c3 --- /dev/null +++ b/user_login_alert/static/description/index.html @@ -0,0 +1,382 @@ + +
+
+

+ User Login Alert +

+

+ User will be notified on Successful login +

+
+ Cybrosys Technologies +
+ +
+ cybrosys technologies +
+
+
+
+
+
+

+ Overview +

+

+ This module will send a notification email to the users email. The notification email contains the IP + of the system, browser name and OS from which the account is accessed. +

+
+
+
+
+

+ Features +

+

+ + Email notification on Log in +

+

+ + Details of the system that accessed the account +

+

+ + IP, OS and browser as well as log in time will be there in the notification email +

+

+ + User will receive notification only if user exist in group receive login notification +

+ +
+
+
+
+

+ Screenshots +

+

+
+ + Adding user to the login notification group +
+ + + user will receive notification only if he is added in this group +

+ +
+ +
+

+
+ User received e-mail on successful login +
+

+
+ +
+
+
+
+

+ Working +

+

+ + If the user is logging in from the same system, user will be only notified for the first time +

+

+ + If the user changes the browser or OS from the same system, the notification email will be received +

+

+ + if user logged in from a new system , notification mail will send +

+

+ + Users IP, OS ad browser details will be stored in User form +

+

+ + Logging in from above IP ,browser and OS user wont be notified +

+

+ + This will get updated based on users latest login +

+

+ + This will details be visible only in developer mode +

+ +
+
+
+
+ cybrosys technologies +
+
+
+
+

+ Our Services +

+
+ + + +
+ +
+ + + +
+

+ + Odoo Support +

+ +
+ +
+
+
+
+
+

+ Our Industries +

+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Trading + +

+

+ Easily procure and sell your products. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Manufacturing +

+

+ Plan, track and schedule your operations. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Restaurant +

+

+ Run your bar or restaurant methodical. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + POS +

+

+ Easy configuring and convivial selling. +

+
+ +
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + E-commerce & Website +

+

+ Mobile friendly, awe-inspiring product pages. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Hotel Management +

+

+ An all-inclusive hotel management application. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Education +

+

+ A Collaborative platform for educational management. +

+
+
+
+ +
+
+ + Odoo Industry + +
+
+
+

+ + Service Management +

+

+ Keep track of services and invoice accordingly. +

+
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/user_login_alert/static/description/index.html~ b/user_login_alert/static/description/index.html~ new file mode 100644 index 000000000..7f747cbbb --- /dev/null +++ b/user_login_alert/static/description/index.html~ @@ -0,0 +1,82 @@ +
+
+

Birthday Notification By E-mail

+

This module will wish the employees on their birthday

+ +

Author : Cybrosys Techno Solutions , www.cybrosys.com

+
+

Features:

+
    +
  •    Adds a cron job to invoke email
  • +
  •    Adds an email template
  • +
+
+
+
+ +
+
+
+

Overview

+

+ HR departments need not worry to wish their employees for their Birthday. In this module we have included the feature to send an email Birthday notification to the employee. +

+
+
+
+ +
+
+

Employee Form

+
+

+ ☛ Give Date of Birth for employee.
+ ☛ Give work email.
+

+
+ +
+
+
+
+ +
+
+

Email Template

+
+

+ ☛ The cron job will invoke the email
+ ☛ Email template is very simple
+

+
+ +
+
+
+
+ +
+

Need Any Help?

+ +
diff --git a/user_login_alert/static/description/login-alert-cybrosys-1.png b/user_login_alert/static/description/login-alert-cybrosys-1.png new file mode 100644 index 000000000..0bc2d5e20 Binary files /dev/null and b/user_login_alert/static/description/login-alert-cybrosys-1.png differ diff --git a/user_login_alert/static/description/login-alert-cybrosys-2.png b/user_login_alert/static/description/login-alert-cybrosys-2.png new file mode 100644 index 000000000..468e2a4d9 Binary files /dev/null and b/user_login_alert/static/description/login-alert-cybrosys-2.png differ diff --git a/user_login_alert/views/logged_details_view.xml b/user_login_alert/views/logged_details_view.xml new file mode 100644 index 000000000..cf8b3c27a --- /dev/null +++ b/user_login_alert/views/logged_details_view.xml @@ -0,0 +1,25 @@ + + + + + res.users + res.users + + + + + + + + + + + + + + + + + + +