Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
1894 Vizualizări

I have a PHP site where I want to login with the Odoo Credintials. How to do it?

Imagine profil
Abandonează
Autor Cel mai bun răspuns

I could login with the following code:


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), '=')));
}

$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) // if true then login successful
​{
​​$password=$hash;
​return true;
​}
}
return false; // login failed

Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

You can refer this documentation:  https://www.odoo.com/documentation/16.0/developer/reference/external_api.html where it explains how to validate the odoo user credentials from different language.

$url = ;
$db = ;
$username = "admin";
$password = for your admin user (default: admin)>;
require_once('ripcord.php');
$info = ripcord::client('https://demo.odoo.com/start')->start();
list($url, $db, $username, $password) = array($info['host'], $info['database'], $info['user'], $info['password']);
$common = ripcord::client("$url/xmlrpc/2/common");
$common->version();

  $uid = $common->authenticate($db, $username, $password, array());



Thanks

Imagine profil
Abandonează