[FIX] fix api

This commit is contained in:
odex 2024-07-04 17:32:08 +03:00
parent f354f191da
commit 5cb3fbc3b5
3 changed files with 8 additions and 10 deletions

View File

@ -185,7 +185,6 @@ class AuthenticationController(http.Controller):
return http_helper.response(code=400,message=_('User account with login {} not found').format(login),success=False)
uid = http_helper.is_authentic(login,password)
if not uid:
return http_helper.errcode(code=400, message=_('Unable to Sign In. invalid user password'))
token = validator.create_token(request.env.user)

View File

@ -186,7 +186,6 @@ class AuthenticationController(http.Controller):
return http_helper.response(code=400,message=_('User account with login {} not found').format(login),success=False)
uid = http_helper.is_authentic(login,password)
if not uid:
return http_helper.errcode(code=400, message=_('Unable to Sign In. invalid user password'))
token = validator.create_token(request.env.user)

View File

@ -18,7 +18,7 @@ SENSITIVE_FIELDS = ['password', 'password_crypt', 'new_password', 'create_uid',
class AuthenticationController(http.Controller):
@http.route('/rest_api/login', type='http', auth='none', csrf=False, cors='*', methods=['POST'])
@http.route('/rest_api/web/login', type='http', auth='none', csrf=False, cors='*', methods=['POST'])
def login_phone(self, **kw):
login = kw.get('login')
password = kw.get('password')
@ -31,7 +31,7 @@ class AuthenticationController(http.Controller):
return http_helper.response(code=400, message=_('Device id is missing'), success=False)
# check fcm_token
if not kw.get('fcm_token'):
if not kw.get('fcm_token') or not kw.get('fcm_token_web'):
return http_helper.response(code=400, message=_('FCM Token is missing'), success=False)
user = request.env['res.users'].sudo().search([('login', '=', login)], limit=1)
@ -59,7 +59,7 @@ class AuthenticationController(http.Controller):
return http_helper.response(data=dic, message=_("User log in successfully"))
@http.route('/rest_api/validate',type='http', auth='none', csrf=False, cors='*',methods=['POST'])
@http.route('/rest_api/web/validate',type='http', auth='none', csrf=False, cors='*',methods=['POST'])
def validate_token(self, **kw):
http_method, body, headers, token = http_helper.parse_request()
@ -69,7 +69,7 @@ class AuthenticationController(http.Controller):
return http_helper.response(message="uploaded success",data=result['data'])
@http.route('/rest_api/refresh',type='http', auth='none', csrf=False, cors='*',methods=['POST'])
@http.route('/rest_api/web/refresh',type='http', auth='none', csrf=False, cors='*',methods=['POST'])
def refresh_token(self, **kw):
http_method, body, headers, token = http_helper.parse_request()
@ -80,7 +80,7 @@ class AuthenticationController(http.Controller):
return http_helper.response(message="uploaded success",data=result['data'])
# Reet password with email
@http.route(['/rest_api/reset'], type='http', auth='none', csrf=False, methods=['POST'])
@http.route(['/rest_api/web/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'):
@ -92,7 +92,7 @@ class AuthenticationController(http.Controller):
else:
return http_helper.errcode(code=403, message="Password reset failed")
@http.route('/rest_api/users/password',type='http', auth='none', csrf=False, cors='*',methods=['PUT'])
@http.route('/rest_api/web/users/password',type='http', auth='none', csrf=False, cors='*',methods=['PUT'])
def change_password(self, **kw):
http_method, body, headers, token = http_helper.parse_request()
if not body.get('old_password') or not body.get('new_password'):
@ -118,7 +118,7 @@ class AuthenticationController(http.Controller):
return http_helper.response(message=_("password changed successfully"),data={'id':user.id})
@http.route('/rest_api/logout', type='http', auth='none', csrf=False, cors='*', methods=['POST'])
@http.route('/rest_api/web/logout', type='http', auth='none', csrf=False, cors='*', methods=['POST'])
def logout(self, **kw):
http_method, body, headers, token = http_helper.parse_request()
result = validator.verify_token(token)
@ -128,7 +128,7 @@ class AuthenticationController(http.Controller):
http_helper.do_logout(token)
return http_helper.response()
@http.route('/rest_api/users', type='http', auth='none', csrf=False, cors='*', methods=['GET'])
@http.route('/rest_api/web/users', type='http', auth='none', csrf=False, cors='*', methods=['GET'])
def info(self, **kw):
http_method, body, headers, token = http_helper.parse_request()
result = validator.verify_token(token)