From 158e944f2718a6691e6ce39ec058da639f18dfdc Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Tue, 19 Sep 2017 17:40:47 +0200
Subject: [PATCH] [enh] Add new button 'authenticate' in the top-right popover
 - fix #550

---
 www/js/controllers/app-controllers.js                     | 8 ++++++++
 .../es/templates/common/popover_profile_extend.html       | 2 +-
 www/templates/common/popover_profile.html                 | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js
index 26323640c..9689b00ba 100644
--- a/www/js/controllers/app-controllers.js
+++ b/www/js/controllers/app-controllers.js
@@ -317,6 +317,14 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $
       .catch(UIUtils.onError());
   };
 
+  // Login and go to a state (or wallet if not)
+  $scope.doAuth = function() {
+    return $scope.loadWallet({auth: true})
+      .then(function() {
+        UIUtils.loading.hide();
+      });
+  };
+
   // If connected and same pubkey
   $scope.isUserPubkey = function(pubkey) {
     return csWallet.isUserPubkey(pubkey);
diff --git a/www/plugins/es/templates/common/popover_profile_extend.html b/www/plugins/es/templates/common/popover_profile_extend.html
index 730189522..33d61e3d5 100644
--- a/www/plugins/es/templates/common/popover_profile_extend.html
+++ b/www/plugins/es/templates/common/popover_profile_extend.html
@@ -1,5 +1,5 @@
     <!-- profile -->
-    <button ng-if="enable"
+    <button ng-if="enable && auth"
             class="button button-positive button-small ink"
             ng-click="showEditUserProfile()">
       {{'PROFILE.BTN_EDIT' | translate}}
diff --git a/www/templates/common/popover_profile.html b/www/templates/common/popover_profile.html
index cb4db06ac..f21b01bbe 100644
--- a/www/templates/common/popover_profile.html
+++ b/www/templates/common/popover_profile.html
@@ -22,6 +22,13 @@
     <div class="row" ng-show="login">
       <div class="col col-66 col-offset-33">
 
+        <!-- auth -->
+        <button ng-show="!auth"
+                class="button button-assertive button-small ink"
+                ng-click="doAuth()">
+          {{'AUTH.BTN_AUTH' | translate}}
+        </button>
+
         <!-- Allow extension here -->
         <cs-extension-point name="profile-popover-user"></cs-extension-point>
       </div>
-- 
GitLab