Merge pull request #3220 from expsa/dev_odex25_mobile

Dev odex25 mobile
This commit is contained in:
mohammed-alkhazrji 2025-05-18 17:08:52 +03:00 committed by GitHub
commit 2c851d17a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 41 additions and 13 deletions

View File

@ -111,20 +111,48 @@ class AuthenticationController(http.Controller):
@http.route(['/rest_api/reset'], type='http', auth='none', csrf=False, methods=['POST'])
def reset_email(self, **kw):
http_method, body, headers, token = http_helper.parse_request()
if not body.get('email'):
email =kw.get('email')
if not email:
return http_helper.response(code=400, message="Email must not be empty", success=False)
user = http.request.env['res.users'].sudo().search([('login', '=', kw.get('email'))])
if user:
if user:
try:
user.sudo().with_context(company_id=user.company_id.id).action_reset_password()
except Exception as e:
return http_helper.response(message=_(e.__str__()),
data={})
return http_helper.response(message=_("A verification link has been sent to you email account"),
data={})
else:
return http_helper.errcode(code=403, message="Password reset failed")
try:
users = http.request.env['res.users'].sudo().search([('login', '=', email)])
if users:
if len(users) > 1:
return http_helper.response(code=409, message="Multiple accounts found for this email",
success=False)
users.sudo().with_context(company_id=users.company_id.id).action_reset_password()
return http_helper.response(message="A verification link has been sent to your email account", data={})
employee = http.request.env['hr.employee'].sudo().search([('work_email', '=', email)], limit=1)
if employee:
if not employee.user_id:
return http_helper.response(code=404, message="This employee is not linked to any user",
success=False)
employee.user_id.sudo().with_context(company_id=employee.company_id.id).action_reset_password()
return http_helper.response(message="A verification link has been sent to your email account", data={})
return http_helper.response(code=403, message="Password reset failed", success=False)
except Exception as e:
return http_helper.response(code=500, message=str(e), success=False)
# def reset_email(self, **kw):
# http_method, body, headers, token = http_helper.parse_request()
# if not body.get('email'):
# return http_helper.response(code=400, message="Email must not be empty", success=False)
# user = http.request.env['res.users'].sudo().search([('login', '=', kw.get('email'))])
# if user:
# if user:
# try:
# user.sudo().with_context(company_id=user.company_id.id).action_reset_password()
# except Exception as e:
# return http_helper.response(message=_(e.__str__()),
# data={})
# return http_helper.response(message=_("A verification link has been sent to you email account"),
# data={})
# else:
# return http_helper.errcode(code=403, message="Password reset failed")
@http.route('/rest_api/get_language',type='http', auth='none', csrf=False ,methods=['GET'])
def get_language(self, **kw):