Odoo is an opensource ERP system developed with python and postgres as backeend database. There may be a need to have some of the applications outside Odoo which willl require to use the same login used by Odoo. This can be achieved in PHPRunner by following the below method.
in the project select the table res_users as the user table and set the username as res_users.login field and password as res_users.password field. Dont use any hash for the password( under the Registration and Password). Add a custom file in the editor page and name it as newpage.php and put the following code.
<?php
function create_passlib_pbkdf2($algo, $password, $salt, $iterations)
{
$hash = hash_pbkdf2($algo, $password, base64_decode(str_replace(".", "+", $salt)), $iterations, 64, true);
return sprintf("\$pbkdf2-%s\$%d\$%s\$%s", $algo, $iterations, $salt, str_replace("+", ".", rtrim(base64_encode($hash), '=')));
}
?>
Now Add the following code in the Before Login Event.
include("newpage.php");
$rs = DB::Query("select password from res_users where login='".$username."'");
$data=$rs->fetchAssoc();
if($data)
{
$parts = explode('$', $data['password']);
if (!array_key_exists(4, $parts)) return false;
$t = explode('-', $parts[1]);
if (!array_key_exists(1, $t)) return false;
$algo = $t[1];
$iterations = (int) $parts[2];
$salt = $parts[3];
$orghash = $parts[4];
$hash = create_passlib_pbkdf2($algo, $password, $salt, $iterations);
if($data['password'] == $hash)
{
$password=$hash;
return true;
}
}
return false;
Now you can login in the PHPRunner generated web application using the Odoo credentials