You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

43 lines
1.6 KiB

"""this python function is to log in as any user without password authentication"""
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Nihala KP (<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# 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
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
import odoo
from odoo.modules.registry import Registry
from odoo.tools._vendor import sessions
def authenticate_without_password(self, dbname, login, env):
"""function for login without password"""
registry = Registry(dbname)
pre_uid = env['res.users'].search([("login", '=', login)]).id
self.uid = None
self.pre_login = login
self.pre_uid = pre_uid
with registry.cursor() as cr:
env = odoo.api.Environment(cr, pre_uid, {})
user = env['res.users'].browse(pre_uid)
if not user._mfa_url():
self.finalize()
return pre_uid
sessions.Session.authenticate_without_password = authenticate_without_password