Skip to content
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

Open
wants to merge 7 commits into
base: 9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bio_login/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Copy link
Contributor

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

# coding: utf-8
# Copyright 2017, Jarsa Sistemas, S.A. de C.V.

from . import models
18 changes: 18 additions & 0 deletions bio_login/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

Copy link
Contributor

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

# -*- 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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'category': 'biometric',

'author': 'Jarsa Sistemas',
'description': 'Bio Login',
'depends': [],
Copy link
Contributor

Choose a reason for hiding this comment

The 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,
}
9 changes: 9 additions & 0 deletions bio_login/data/config_parameter_data.xml
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">
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
5 changes: 5 additions & 0 deletions bio_login/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

Copy link
Contributor

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

# coding: utf-8
# Copyright 2017, Jarsa Sistemas, S.A. de C.V.

from . import res_users
96 changes: 96 additions & 0 deletions bio_login/models/res_users.py
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'
Copy link
Contributor

Choose a reason for hiding this comment

The 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
15 changes: 15 additions & 0 deletions bio_login/views/res_user_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
Copy link
Contributor

Choose a reason for hiding this comment

The 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>
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
conekta
zeep