From 56731eaaf1a42e08fc925471a303b1d02d05f8ff Mon Sep 17 00:00:00 2001 From: SaraiOsorio Date: Fri, 1 Dec 2017 13:36:20 -0600 Subject: [PATCH] [ADD][bio_login]-system parameter --- bio_login/__openerp__.py | 1 + bio_login/data/config_parameter_data.xml | 9 ++++ bio_login/models/res_users.py | 57 ++++++++++++------------ 3 files changed, 39 insertions(+), 28 deletions(-) create mode 100644 bio_login/data/config_parameter_data.xml diff --git a/bio_login/__openerp__.py b/bio_login/__openerp__.py index d6009d8..7729867 100644 --- a/bio_login/__openerp__.py +++ b/bio_login/__openerp__.py @@ -11,6 +11,7 @@ 'description': 'Bio Login', 'depends': [], 'data': [ + 'data/config_parameter_data.xml', 'views/res_user_view.xml', ], 'installable': True, diff --git a/bio_login/data/config_parameter_data.xml b/bio_login/data/config_parameter_data.xml new file mode 100644 index 0000000..78edfdf --- /dev/null +++ b/bio_login/data/config_parameter_data.xml @@ -0,0 +1,9 @@ + + + + + ngrok_url + http://0d0b113c.ngrok.io/BioEngineClientWS/BioEngineClient.asmx?WSDL + + + \ No newline at end of file diff --git a/bio_login/models/res_users.py b/bio_login/models/res_users.py index 90b622d..4215d03 100644 --- a/bio_login/models/res_users.py +++ b/bio_login/models/res_users.py @@ -64,32 +64,33 @@ def _login(self, db, login, password): cr.execute("SELECT biokey FROM res_users WHERE id = %s" % ( user_id,)) user_biokey = cr.fetchone() - if not request.session.login: - client = Client( - 'http://0d0b113c.ngrok.io/BioEngineClientWS' - '/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, user_biokey[0])['outBioKey'] - if not biokey: - user_id = False + 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