From 8a59a2e014ba8c053492952e87fefa42cf594e69 Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Mon, 5 Nov 2018 11:12:51 +0100
Subject: [PATCH] [enh] Login: when login by pubkey, after a lookup search, use
  the select 'uid'

---
 www/js/controllers/login-controllers.js | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/www/js/controllers/login-controllers.js b/www/js/controllers/login-controllers.js
index 7145a319..541c2deb 100644
--- a/www/js/controllers/login-controllers.js
+++ b/www/js/controllers/login-controllers.js
@@ -188,6 +188,7 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils,
     // Pubkey
     else if (method === 'PUBKEY') {
       var pubkey = $scope.formData.pubkey && $scope.formData.pubkey.trim();
+      var uid = $scope.formData.uid && $scope.formData.uid.trim() || undefined;
       if (!pubkey) return;
       var matches = BMA.regexp.PUBKEY.exec(pubkey);
       // valid pubkey: use it
@@ -195,7 +196,8 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils,
         promise = UIUtils.loading.show()
           .then(function() {
             return {
-              pubkey: pubkey
+              pubkey: pubkey,
+              uid : uid
             };
           });
       }
@@ -216,7 +218,8 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils,
             promise = UIUtils.loading.show()
               .then(function() {
                 return {
-                  pubkey: pubkey
+                  pubkey: pubkey,
+                  uid : uid
                 };
               });
           }
@@ -415,6 +418,7 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils,
 
     console.debug("[login] method is: " + method);
     $scope.formData.method = method;
+    $scope.formData.uid = null;
 
     if ($scope.form) {
       // hide form's fields errors on the form
@@ -425,6 +429,7 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils,
     if (method == 'SCRYPT_DEFAULT' || method == 'SCRYPT_ADVANCED') {
       $scope.pubkey = null;
 
+
       // Search scrypt object
       var scrypt;
       if (params) {
@@ -580,6 +585,7 @@ function LoginModalController($scope, $timeout, $q, $ionicPopover, CryptoUtils,
       .then(function(res){
         if (res && res.pubkey) {
           $scope.formData.pubkey = res.pubkey;
+          $scope.formData.uid = res.uid || undefined;
           return $timeout($scope.doLogin, 300);
         }
       });
-- 
GitLab