Help

3

How to pass connection parameters in the URL ?

Avatar
Semah Raddaoui

I am working with OpenERP 7. I want to know how can I log in the server by just passing connection parameters in the URL (db, login, password).

Any idea how can we do that ?

3 Comments
Avatar
Discard
Avatar
Anabela Damas
-

Hi, did you find the solution? I'm trying to do the same...

Avatar
Semah Raddaoui
-

not found yet

Avatar
Anabela Damas
-

I have this question too: http://help.openerp.com/question/39187/how-to-pass-login-and-password-parameters-to-user/ I will try do do this. If I have positive results I will share with you.

3 Answers
3
Avatar
Krishna
Best Answer

Here is the URL string for seamless login from another page to openerp.

localhost:8069/login?db=nas&login=&key=

4 Comments
Avatar
Discard
Avatar
vimal j
-

This is working. Thanks Krishna

Avatar
Semah Raddaoui
-

This works only if you have a single database in your server : add another database (nas2 for example) and try to connect to it .It will not work !!!

Avatar
Krishna
-

It will work. You have to select nas2 database first..

Avatar
Semah Raddaoui
-

I will connect to my OpenERP server from another website, it means that l WILL NOT not use the default login page so how can I select the database which I want to connect to

1
Avatar
Alcaline
Best Answer

hi

Do you have any idea how to restrict the login process? I want to disable the login process in openerp after working hours. any idea how to do that and where can i find the codes for this login button..

 

1 Comment
Avatar
Discard
Avatar
Wilbert Tan
-

If anyone know this, please post it. Need help doing this

1
Avatar
Gopakumar N G
Best Answer

Check the module web, it defines the login form and js files etc, check also the file res_users.py in module base/res/ and there is the login function defined.

def login(self, db, login, password):
    if not password:
        return False
    user_id = False
    cr = pooler.get_db(db).cursor()
    try:
        # autocommit: our single update request will be performed atomically.
        # (In this way, there is no opportunity to have two transactions
        # interleaving their cr.execute()..cr.commit() calls and have one
        # of them rolled back due to a concurrent access.)
        cr.autocommit(True)
        # check if user exists
        res = self.search(cr, SUPERUSER_ID, [('login','=',login)])
        if res:
            user_id = res[0]
            # check credentials
            self.check_credentials(cr, user_id, password)
            # We effectively unconditionally write the res_users line.
            # Even w/ autocommit there's a chance the user row will be locked,
            # in which case we can't delay the login just for the purpose of
            # update the last login date - hence we use FOR UPDATE NOWAIT to
            # try to get the lock - fail-fast
            # Failing to acquire the lock on the res_users row probably means
            # another request is holding it. No big deal, we don't want to
            # prevent/delay login in that case. It will also have been logged
            # as a SQL error, if anyone cares.
            try:
                cr.execute("SELECT id FROM res_users WHERE id=%s FOR UPDATE NOWAIT", (user_id,), log_exceptions=False)
                cr.execute("UPDATE res_users SET login_date = now() AT TIME ZONE 'UTC' WHERE id=%s", (user_id,))
            except Exception:
                _logger.debug("Failed to update last_login for db:%s login:%s", db, login, exc_info=True)
    except openerp.exceptions.AccessDenied:
        _logger.info("Login failed for db:%s login:%s", db, login)
        user_id = False
    finally:
        cr.close()

    return user_id

and check the methods authenticate, check and check_credentials also.

8 Comments
Avatar
Discard
Avatar
Semah Raddaoui
-

I want to connect directly from the url like this localhost:8089/?db=dbname(other arguments)

Avatar
Gopakumar N G
-

I am not sure that you can do that, check the file main.py in module web/controllers/main.py. The URL and sessions are handled in it.

Avatar
Semah Raddaoui
-

I asked a question ( help.openerp.com/question/36431/how-to-login-to-openerp-from-another-website/ ) and Fabien Pinckaers answered me " it's also possible to put login/pass in the url, but I don't remember what are the exact arguments"

Avatar
Semah Raddaoui
-

Thank you Gopakumar, If you find a solution please tell me.

Avatar
Gopakumar N G
-

Check the module "auth_oauth" it is used for sign in to OpenERP from other accounts.

Avatar
Semah Raddaoui
-

we want to pass connection parameters in the URL and not "sign in to OpenERP from other accounts."

Avatar
Krishna
-

I found it. This is the URL string http://localhost:8069/login?db=nas&login=&key=