Browse Source

APR 15: [FIX] Bug fixed 'restrict_logins'

pull/331/merge
Cybrosys Technologies 2 weeks ago
parent
commit
d94d2f919c
  1. 4
      restrict_logins/__manifest__.py
  2. 6
      restrict_logins/doc/RELEASE_NOTES.md
  3. 1
      restrict_logins/models/__init__.py
  4. 5
      restrict_logins/models/ir_http.py
  5. 8
      restrict_logins/models/res_config_settings.py
  6. 5
      restrict_logins/models/res_users.py
  7. BIN
      restrict_logins/static/description/assets/screenshots/restrct_17_1.png
  8. BIN
      restrict_logins/static/description/assets/screenshots/restrct_17_2.png
  9. BIN
      restrict_logins/static/description/assets/screenshots/restrict_17_3.png
  10. 78
      restrict_logins/static/description/index.html
  11. 23
      restrict_logins/views/res_config_settings_views.xml

4
restrict_logins/__manifest__.py

@ -21,7 +21,7 @@
###############################################################################
{
'name': 'Restrict Concurrent User Login',
'version': '17.0.1.0.0',
'version': '17.0.1.1.0',
'category': 'Extra Tools',
'summary': """Ensures restricted concurrent sessions, enforces user force
logout, and automates session expiry for enhanced security.""",
@ -33,10 +33,12 @@
'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions',
'website': 'https://www.cybrosys.com',
'depends':['base_setup'],
'data': [
'data/ir_cron_data.xml',
'views/res_users_views.xml',
'views/login_clear_session_template.xml',
'views/res_config_settings_views.xml',
],
'images': ['static/description/banner.jpg'],
'license': 'LGPL-3',

6
restrict_logins/doc/RELEASE_NOTES.md

@ -3,3 +3,9 @@
#### Version 17.0.1.0.0
##### ADD
- Initial Commit for Restrict Concurrent User Login
#### 07.04.2025
#### Version 17.0.1.1.0
##### UPDT
- Added option inside settings to set session expiration time limit in minutes

1
restrict_logins/models/__init__.py

@ -20,5 +20,6 @@
#
###############################################################################
from . import ir_http
from . import res_config_settings
from . import res_users

5
restrict_logins/models/ir_http.py

@ -61,7 +61,10 @@ class IrHttp(models.AbstractModel):
sid = request.session.sid
last_update = user_pool.last_update
now = datetime.now()
exp_date = datetime.now() + timedelta(minutes=45)
session_time_limit = int(
request.env['ir.config_parameter'].sudo().get_param(
'restrict_logins.session_expire_time'))
exp_date = datetime.now() + timedelta(minutes=session_time_limit)
# Check that the authentication contains bus_inactivity
# request_params = request.params.copy()
# if 'options' in request_params and 'bus_inactivity' in \

8
restrict_logins/models/res_config_settings.py

@ -0,0 +1,8 @@
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
session_expire_time = fields.Integer('Session Expire time In Minutes',
config_parameter='restrict_logins.session_expire_time')

5
restrict_logins/models/res_users.py

@ -98,7 +98,10 @@ class ResUsers(models.Model):
def _save_session(self):
""" Function for saving session details of the corresponding user."""
exp_date = datetime.utcnow() + timedelta(minutes=45)
session_time_limit = int(
self.env['ir.config_parameter'].sudo().get_param(
'restrict_logins.session_expire_time'))
exp_date = datetime.utcnow() + timedelta(minutes=session_time_limit)
sid = request.session.sid
self.with_user(SUPERUSER_ID).write({
'sid': sid,

BIN
restrict_logins/static/description/assets/screenshots/restrct_17_1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

BIN
restrict_logins/static/description/assets/screenshots/restrct_17_2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
restrict_logins/static/description/assets/screenshots/restrict_17_3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

78
restrict_logins/static/description/index.html

@ -116,8 +116,7 @@
<div>
<p style="color: #1A202C;font-weight: 600;
font-size: 1.2rem; margin-bottom: 2px;">
Automatic Session Expiration After 45
Minutes.</p>
Option to set the session expiration time in settings.</p>
</div>
</div>
</div>
@ -205,6 +204,60 @@
</div>
</div>
</div>
<div class="col-lg-12 py-2"
style="padding: 1rem 4rem !important;">
<div
style="border: 1px solid #d8d6d6; border-radius: 4px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
<div class="row justify-content-center p-3 w-100 m-0">
<img src="assets/screenshots/restrct_17_1.png"
class="img-thumbnail" width="100%"
height="auto">
</div>
<div class="px-3">
<h4 class="mt-2"
style=" font-weight:600 !important; color:#282F33 !important; font-size:1.3rem !important">
Inside the Settings, we have an option to set the session expiration time limit in minutes.
</h4>
</div>
</div>
</div>
<div class="col-lg-12 py-2"
style="padding: 1rem 4rem !important;">
<div
style="border: 1px solid #d8d6d6; border-radius: 4px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
<div class="row justify-content-center p-3 w-100 m-0">
<img src="assets/screenshots/restrct_17_2.png"
class="img-thumbnail" width="100%"
height="auto">
</div>
<div class="px-3">
<h4 class="mt-2"
style=" font-weight:600 !important; color:#282F33 !important; font-size:1.3rem !important">
The session expiration time will be automatically set for users based on the time limit configured in the Settings.
</h4>
</div>
</div>
</div>
<div class="col-lg-12 py-2"
style="padding: 1rem 4rem !important;">
<div
style="border: 1px solid #d8d6d6; border-radius: 4px; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
<div class="row justify-content-center p-3 w-100 m-0">
<img src="assets/screenshots/restrict_17_3.png"
class="img-thumbnail" width="100%"
height="auto">
</div>
<div class="px-3">
<h4 class="mt-2"
style=" font-weight:600 !important; color:#282F33 !important; font-size:1.3rem !important">
The session expiration time will update automatically when the system is used continuously. However, if the system remains idle, it will automatically log out once the session expiration time is reached.
</h4>
</div>
</div>
</div>
</div>
<div id="tab2" class="tab-pane fade">
<div class="col-mg-12" style="padding: 1rem 4rem;">
@ -244,9 +297,9 @@
<span style="margin-right: 12px;"><img
src="assets/misc/star (1) 2.svg"
alt=""
width="16px"></span>Automatic Session Expiration
width="16px"></span>Set Expiration time limit.
<ul style="list-style: none;font-weight: 400; color:#718096">
<li>Automatic Session Expiration After 45 Minutes.
<li>Option to set session expiration time limit inside settings.
</li>
</ul>
</li>
@ -270,6 +323,23 @@
</p>
</div>
</div>
<div class="col-mg-12 active"
style="padding: 1rem 4rem;">
<div class="py-3"
style="font-weight: 500;background-color: #fff; border-radius: 4px; padding: 1rem; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);">
<div class="d-flex mb-3"
style="font-size: 0.8rem; font-weight: 500;"><span>Version
17.0.1.1.0</span><span
class="px-2">|</span><span
style="color: #714B67;font-weight: 600;">Released on:7th April 2025</span>
</div>
<p class="m-0"
style=" color:#718096!important; font-size:1rem !important;line-height: 28px;">
Added option inside settings to set session expiration time limit in minutes
</p>
</div>
</div>
</div>
</div>
</div>

23
restrict_logins/views/res_config_settings_views.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!-- Settings view -->
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.restrict_logins
</field>
<field name="model">res.config.settings</field>
<field name="inherit_id"
ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//setting[@id='feedback_motivate_setting']"
position="after">
<setting class="col-12 col-lg-6 o_setting_box" id="allow_import">
<label string="Session Expire Time" for="session_expire_time"/>
<div class="text-muted">
Allow users to set the Session Expiration time in Minutes
<field name="session_expire_time"/> Minutes
</div>
</setting>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save