Browse Source

when unlogged, suggest to login

master
idoctnef 8 years ago
parent
commit
3190627291
2 changed files with 12 additions and 2 deletions
  1. +11
    -2
      www/js/controllers.js
  2. +1
    -0
      www/templates/login.html

+ 11
- 2
www/js/controllers.js

@ -1,6 +1,6 @@
var urlapi="http://localhost:3000/api/";
//var urlapi="https://collectivecar.paas.primustech.io/api/";
//var urlapi="http://localhost:3000/api/";
var urlapi="https://collectivecar.paas.primustech.io/api/";
//localStorage.setItem("c_username", "user2");
@ -177,6 +177,15 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
localStorage.removeItem("c_userdata");
$window.location.reload(true);
};
/* if no logged, suggest to login */
if(localStorage.getItem('c_token')){// adding token to the headers
$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('c_token');
}else{
setTimeout(function(){
$scope.login();
},1000);
}
})

+ 1
- 0
www/templates/login.html

@ -2,6 +2,7 @@
<ion-header-bar>
<h1 class="title">{{'Login' | translate}}</h1>
<div class="buttons">
<button class="button button-balanced" ng-click="signup()">{{'Signup' | translate}}</button>
<button class="button button-dark" ng-click="closeLogin()">{{'Close' | translate}}</button>
</div>
</ion-header-bar>

Loading…
Cancel
Save