-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADD][bio_login]add new module for login whit finger #81
base: 9.0
Are you sure you want to change the base?
Changes from 5 commits
b657380
0c6524e
c72db9b
8b71a6d
56731ea
6750f84
66ba167
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
# coding: utf-8 | ||
# Copyright 2017, Jarsa Sistemas, S.A. de C.V. | ||
|
||
from . import models |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. first line must be the coding |
||
# -*- coding: utf-8 -*- | ||
# Copyright 2017, Jarsa Sistemas, S.A. de C.V. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
'name': 'Bio Login', | ||
'version': '9.0.0.1.0', | ||
'category': 'Initial Data', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'category': 'biometric', |
||
'author': 'Jarsa Sistemas', | ||
'description': 'Bio Login', | ||
'depends': [], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this module depends on base? or another module |
||
'data': [ | ||
'data/config_parameter_data.xml', | ||
'views/res_user_view.xml', | ||
], | ||
'installable': True, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data noupdate="1"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove data tag... ose |
||
<record id="ngrok_url_parameter" model="ir.config_parameter"> | ||
<field name="key">ngrok_url</field> | ||
<field name="value">http://0d0b113c.ngrok.io/BioEngineClientWS/BioEngineClient.asmx?WSDL</field> | ||
</record> | ||
</data> | ||
</odoo> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. first line must be the coding |
||
# coding: utf-8 | ||
# Copyright 2017, Jarsa Sistemas, S.A. de C.V. | ||
|
||
from . import res_users |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017, Jarsa Sistemas, S.A. de C.V. | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from zeep import Client | ||
from openerp import _, api, fields, models, registry, SUPERUSER_ID | ||
from openerp.exceptions import ValidationError | ||
from openerp.http import request | ||
|
||
|
||
class ResUsers(models.Model): | ||
_inherit = 'res.users' | ||
|
||
biokey = fields.Char( | ||
string='Biokey', | ||
) | ||
|
||
@api.multi | ||
def fingerprint(self): | ||
self.ensure_one() | ||
client = Client( | ||
'http://0d0b113c.ngrok.io/BioEngineClientWS' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where did you use the ir.config.parameter? |
||
'/BioEngineClient.asmx?WSDL') | ||
token = client.service.GetToken()['outToken'] | ||
transaction = client.service.GetTmpTransNum(token)['outTmpTransNum'] | ||
client.service.CaptureFinger( | ||
inToken=token, | ||
inTmpTransNum=transaction, | ||
inFlat=True, | ||
inRoll=False, | ||
inThumbR=False, | ||
inIndexR=True, | ||
inMiddleR=False, | ||
inRingR=False, | ||
inLittleR=False, | ||
inThumbL=False, | ||
inIndexL=False, | ||
inMiddleL=False, | ||
inRingL=False, | ||
inLittleL=False, | ||
) | ||
client.service.SendToServer(token, transaction) | ||
biokey = client.service.ServerFind(transaction, '')['outBioKey'] | ||
if biokey: | ||
appkey = client.service.GetAppKey(biokey, 'Odoo')['outAppKey'] | ||
if appkey: | ||
res_user = self.browse(int(appkey)) | ||
if self.id != res_user.id: | ||
raise ValidationError( | ||
_('This exits for user %s', res_user.name)) | ||
else: | ||
client.service.ServerSave(transaction, 'Odoo', appkey) | ||
else: | ||
biokey = client.service.ServerSave( | ||
transaction, 'Odoo', self.id)['outBioKey'] | ||
self.biokey = biokey | ||
|
||
def _login(self, db, login, password): | ||
user_id = super(ResUsers, self)._login(db, login, password) | ||
if not user_id: | ||
return user_id | ||
if user_id == SUPERUSER_ID: | ||
return user_id | ||
with registry(db).cursor() as cr: | ||
cr.execute("SELECT biokey FROM res_users WHERE id = %s" % ( | ||
user_id,)) | ||
user_biokey = cr.fetchone() | ||
if request.session.login: | ||
return user_id | ||
ngrok_url = self.pool.get('ir.config_parameter').get_param( | ||
'ngrok_url_parameter') | ||
client = Client(ngrok_url) | ||
token = client.service.GetToken()['outToken'] | ||
transaction = client.service.GetTmpTransNum( | ||
token)['outTmpTransNum'] | ||
client.service.CaptureFinger( | ||
inToken=token, | ||
inTmpTransNum=transaction, | ||
inFlat=True, | ||
inRoll=False, | ||
inThumbR=False, | ||
inIndexR=True, | ||
inMiddleR=False, | ||
inRingR=False, | ||
inLittleR=False, | ||
inThumbL=False, | ||
inIndexL=False, | ||
inMiddleL=False, | ||
inRingL=False, | ||
inLittleL=False, | ||
) | ||
client.service.SendToServer(token, transaction) | ||
biokey = client.service.ServerFind( | ||
transaction, user_biokey[0])['outBioKey'] | ||
if not biokey: | ||
user_id = False | ||
return user_id |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<data> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove data |
||
<record id="res_users_bio_login" model="ir.ui.view"> | ||
<field name="name">res_users_bio_login</field> | ||
<field name="model">res.users</field> | ||
<field name="inherit_id" ref="base.view_users_form"/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//header" position="inside"> | ||
<button class="oe_highlight" icon="fa-hand-o-up" name="fingerprint" string="Fingerprint" type="object"/> | ||
</xpath> | ||
</field> | ||
</record> | ||
</data> | ||
</odoo> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
conekta | ||
zeep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first line must be the coding