Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
9997 Lượt xem

Hello,

I have created a Android Mobile app for pushing some data in my database. Now before pushing the data I want the user to login through the credentials he use to login in odoo. I can get the email/login field but there is a problem with password as odoo save the encrypted form of password. So I have created a separate field in res.users for a mobile application password. 

That is not supposed to be ethical as I have access to read and view their passwords in database. So is there a way that I can make the user login with the same username password in mobile app with which he login his odoo account?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Mian,

    You can compare the encrypted password using the CryptContext package in python. So you can ask the user to enter his Odoo password, then you can compare it with encrypted password stored in 'res.users'.


from passlib.context import CryptContext
compare_password = CryptContext(['pbkdf2_sha512']).verify(password, password_crypt)
if compare_password:
    print("Login Approved")
else:
    print("Invalid username/password")

Hope this helps you!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can do the authentication from the mobile app like this,

request = urllib2.Request(
server_url+'/web/session/authenticate',
json.dumps({
'jsonrpc': '2.0',
'params': {
'db': db,
'login': user,
'password': password,
},
}),
{'Content-type': 'application/json'})
result = urllib2.urlopen(request).read()
result = json.loads(result)


Then in the result you will get the session_id if the authentication is success. You can use this session_id as authentication for the database operation.

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I think you just need to refer to the origin code of the odoo login function,  use the same encrypted method to completed the login process, there are not any differents I think.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 23
2239
0
thg 7 20
3442
0
thg 9 18
3233
0
thg 10 17
9920
2
thg 7 24
10266