Skip to Content
Menu
This question has been flagged

I tried inheritance controller from web/login. This function is successfully installed and run. When User 2 login with the session from pos.config in used with User 1 then it displays an error "Cant login. User 1 not closing pos ". After when trying to login with User 1 then Page 400 bad request  will appear.

Below snippet code

classHomeInherit(Home):
    # @http.route('/web/login', type='http', auth="none")
    def web_login_00(self,*args,**kw):
        ensure_db()
        res=super(HomeInherit,self).web_login(*args,**kw)
        print('direct logins check session')
        values = {k: v for k, v in request.params.items() if k in SIGN_UP_REQUEST_PARAMS}
        if request.session.uid:
            user=request.env['res.users'].browse(request.session.uid)
            if user.pos_config_id and user.direct_login and user.check_session:
                pos_not_closing=request.env['pos.session'].search([('state','!=','closed'),
                ('config_id','=',user.pos_config_id.id),('rescue','=',False)])
                if len(pos_not_closing)>0 and pos_not_closing.user_id.id!=user.id:
                    res.qcontext['error']=f"Tidak bisa login. {pos_not_closing.user_id.display_name} belum closing"
                    res.headers['X-Frame-Options']='DENY'
        return res

This make Bad Request 400 appears because when the code  

res.qcontext['error']=f"Tidak bisa login. {pos_not_closing.user_id.display_name} belum closing"
res.headers['X-Frame-Options']='DENY'

is executed and there is a change in the response. Temporarily counter so the application is closed and reopened.


Do you have any code examples web/login inheritance with an error display on the login page without a bad request?

Avatar
Discard
Related Posts Replies Views Activity
1
Feb 21
1963
2
Aug 20
9527
0
Sep 16
2915
1
Aug 24
424
2
Nov 24
761