mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[FIX] fix login controller, fix public & private endpoints, add cors
This commit is contained in:
committed by
Darío Lodeiros
parent
6f672029f5
commit
af960fcec3
@@ -26,9 +26,9 @@ class PmsPartnerService(Component):
|
||||
)
|
||||
],
|
||||
input_param=Datamodel("pms.api.rest.user.input", is_list=False),
|
||||
# output_param=Datamodel("pms.api.rest.user.output", is_list=False),
|
||||
output_param=Datamodel("pms.api.rest.user.output", is_list=False),
|
||||
)
|
||||
def aa(self, user):
|
||||
def login(self, user):
|
||||
|
||||
user_record = (
|
||||
self.env["res.users"].sudo().search([("login", "=", user.username)])
|
||||
@@ -36,12 +36,7 @@ class PmsPartnerService(Component):
|
||||
|
||||
if not user_record:
|
||||
ValidationError(_("user or password not valid"))
|
||||
try:
|
||||
user_record.with_user(user_record)._check_credentials(user.password, None)
|
||||
|
||||
except Exception as e:
|
||||
raise UserError("")
|
||||
|
||||
user_record.with_user(user_record)._check_credentials(user.password, None)
|
||||
PmsApiRestUserOutput = self.env.datamodels["pms.api.rest.user.output"]
|
||||
expiration_date = time.time() + 36660
|
||||
token = jwt.encode(
|
||||
@@ -55,62 +50,4 @@ class PmsPartnerService(Component):
|
||||
key="pms_secret_key_example",
|
||||
algorithm=jwt.ALGORITHMS.HS256,
|
||||
)
|
||||
# return PmsApiRestUserOutput(token=token)
|
||||
return token
|
||||
|
||||
def user_error(self):
|
||||
"""
|
||||
Simulate an odoo.exceptions.UserError
|
||||
Should be translated into BadRequest with a description into the json
|
||||
body
|
||||
"""
|
||||
raise UserError(_("UserError message"))
|
||||
|
||||
# Validator
|
||||
def _validator_user_error(self):
|
||||
return {}
|
||||
|
||||
def _validator_return_user_error(self):
|
||||
return {}
|
||||
|
||||
def _validator_validation_error(self):
|
||||
return {}
|
||||
|
||||
def _validator_return_validation_error(self):
|
||||
return {}
|
||||
|
||||
def _validator_session_expired(self):
|
||||
return {}
|
||||
|
||||
def _validator_return_session_expired(self):
|
||||
return {}
|
||||
|
||||
def _validator_missing_error(self):
|
||||
return {}
|
||||
|
||||
def _validator_return_missing_error(self):
|
||||
return {}
|
||||
|
||||
def _validator_access_error(self):
|
||||
return {}
|
||||
|
||||
def _validator_return_access_error(self):
|
||||
return {}
|
||||
|
||||
def _validator_access_denied(self):
|
||||
return {}
|
||||
|
||||
def _validator_return_access_denied(self):
|
||||
return {}
|
||||
|
||||
def _validator_http_exception(self):
|
||||
return {}
|
||||
|
||||
def _validator_return_http_exception(self):
|
||||
return {}
|
||||
|
||||
def _validator_bare_exception(self):
|
||||
return {}
|
||||
|
||||
def _validator_return_bare_exception(self):
|
||||
return {}
|
||||
return PmsApiRestUserOutput(token=token)
|
||||
|
||||
Reference in New Issue
Block a user