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.
 
 
 
 
 

62 lines
2.3 KiB

# -*- coding: utf-8 -*-
###############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions (odoo@cybrosys.com)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
from odoo.addons.auth_signup.controllers.main import AuthSignupHome
from odoo import http
from odoo.http import request
class PasswordHint(AuthSignupHome):
"""
A class that handles password hints during user signup and retrieval.
Inherits from AuthSignupHome, a class that provides authentication and
signup functionality for web users in the Odoo web application
framework.
"""
def web_auth_signup(self, **kw):
""" Handle user signup and set password hint if provided.
Args:
**kw: Keyword arguments.
Returns:
Result of calling the parent method.
"""
res = super(PasswordHint, self).web_auth_signup()
if kw.get('hint'):
user = request.env['res.users'].sudo().search(
[('login', '=', kw['login'])])
user.password_hint = kw.get('hint')
return res
@http.route('/website/password/hint', type='json', auth='public',
website=True)
def button_password_hint(self, params):
"""Retrieve password hint for a given user login.
Args:
params: JSON object containing user login.
Returns:
JSON response containing password hint.
"""
user = request.env['res.users'].sudo().search(
[('login', '=', params)])
value = user.password_hint
return value