itpp-labs / access-addons

Odoo Addons for extended access control
https://itpp.dev
114 stars 260 forks source link

auth_quick: error when there is no built_login in the database provided in request #326

Open trojikman opened 3 years ago

trojikman commented 3 years ago

Steps to reproduce the error:

Let's say we run using this link: /auth_quick/login?build_login=admin But we haven't such login as admin in the database. After this code: https://github.com/itpp-labs/access-addons/blob/28c61ac28e0330efed07b2413095ff0ebbd5fbd3/auth_quick/controllers/main.py#L34-L35 we'll have this error:

ValueError

ValueError: invalid literal for int() with base 10: 'False'
Traceback (most recent call last)

  File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py",      line 142,      in application  
return application_unproxied(environ, start_response)
  File "/usr/lib/python3/dist-packages/odoo/service/wsgi_server.py",      line 117,      in application_unproxied  
result = odoo.http.root(environ, start_response)
  File "/usr/lib/python3/dist-packages/odoo/http.py",      line 1281,      in __call__  
return self.dispatch(environ, start_response)
  File "/usr/lib/python3/dist-packages/odoo/http.py",      line 1251,      in __call__  
return self.app(environ, start_wrapped)
  File "/usr/lib/python3/dist-packages/werkzeug/middleware/shared_data.py",      line 220,      in __call__  
return self.app(environ, start_response)
  File "/usr/lib/python3/dist-packages/odoo/http.py",      line 1450,      in dispatch  
result = ir_http._dispatch()
  File "/usr/lib/python3/dist-packages/odoo/addons/website_sale/models/ir_http.py",      line 15,      in _dispatch  
return super(IrHttp, cls)._dispatch()
  File "/usr/lib/python3/dist-packages/odoo/addons/website/models/ir_http.py",      line 172,      in _dispatch  
response = super(Http, cls)._dispatch()
  File "/usr/lib/python3/dist-packages/odoo/addons/auth_signup/models/ir_http.py",      line 19,      in _dispatch  
return super(Http, cls)._dispatch()
  File "/usr/lib/python3/dist-packages/odoo/addons/web_editor/models/ir_http.py",      line 22,      in _dispatch  
return super(IrHttp, cls)._dispatch()
  File "/usr/lib/python3/dist-packages/odoo/addons/utm/models/ir_http.py",      line 29,      in _dispatch  
response = super(IrHttp, cls)._dispatch()
  File "/usr/lib/python3/dist-packages/odoo/addons/http_routing/models/ir_http.py",      line 516,      in _dispatch  
result = super(IrHttp, cls)._dispatch()
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py",      line 233,      in _dispatch  
return cls._handle_exception(e)
  File "/usr/lib/python3/dist-packages/odoo/addons/utm/models/ir_http.py",      line 34,      in _handle_exception  
response = super(IrHttp, cls)._handle_exception(exc)
  File "/usr/lib/python3/dist-packages/odoo/addons/http_routing/models/ir_http.py",      line 607,      in _handle_exception  
return super(IrHttp, cls)._handle_exception(exception)
  File "/usr/lib/python3/dist-packages/odoo/addons/bae/models/ir_http.py",      line 198,      in _handle_exception  
raise exceptio
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py",      line 229,      in _dispatch  
result = request.dispatch()
  File "/usr/lib/python3/dist-packages/odoo/http.py",      line 803,      in dispatch  
r = self._call_function(**self.params)
  File "/usr/lib/python3/dist-packages/odoo/http.py",      line 345,      in _call_function  
return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/service/model.py",      line 93,      in wrapper  
return f(dbname, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/http.py",      line 338,      in checked_call  
result = self.endpoint(*a, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py",      line 909,      in __call__  
return self.method(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py",      line 510,      in response_wrap  
response = f(*args, **kw)
  File "/mnt/addons/saas-addons/auth_quick_master/controllers/main.py",      line 21,      in get_token  
'build_user_id': build_user_id,
  File "<decorator-gen-123>",      line 2,      in create  
  File "/usr/lib/python3/dist-packages/odoo/api.py",      line 322,      in _model_create_single  
return create(self, arg)
  File "/mnt/addons/saas-addons/saas/models/auth_quick_master_token.py",      line 11,      in create  
res = super(Token, self).create(vals)
  File "<decorator-gen-3>",      line 2,      in create  
  File "/usr/lib/python3/dist-packages/odoo/api.py",      line 343,      in _model_create_multi  
return create(self, [arg])
  File "/usr/lib/python3/dist-packages/odoo/models.py",      line 3732,      in create  
records = self._create(data_list)
  File "/usr/lib/python3/dist-packages/odoo/models.py",      line 3804,      in _create  
col_val = field.convert_to_column(val, self, stored)
  File "/usr/lib/python3/dist-packages/odoo/fields.py",      line 1135,      in convert_to_column  
return int(value or 0)
  ValueError: invalid literal for int() with base 10: 'False'

Expected behavior:

Don't get such an error, but get a response that there is no such login