]> khamidou — GitHub mirrors - kite.git/commitdiff
redirect user to mailbox if he's already logged in
authorkarim hamidou <khamidou@gmail.com>
Sun, 11 May 2014 10:25:30 +0000 (12:25 +0200)
committerkarim hamidou <khamidou@gmail.com>
Sun, 11 May 2014 10:25:30 +0000 (12:25 +0200)
src/front/app/js/app.js

index 5da6de02b4eace13d9a97769ba27be3afdff8f86..78888e3be6952c74eaaa08888bd77d48dfa4a6b5 100644 (file)
@@ -10,12 +10,16 @@ angular.module('KiteMail', ['ngRoute', 'KiteMail.filters', 'KiteMail.services',
     $routeProvider.otherwise({redirectTo: '/login'});
   }]).run(['$rootScope', '$location', 'Auth', function($rootScope, $location, Auth) { 
    $rootScope.$on( "$routeChangeStart", function(event, next, current) {
-        console.log(Auth.loggedOn());
-        if (!Auth.loggedOn()) {
+        console.log(Auth.loggedIn());
+        if (!Auth.loggedIn()) {
             // no logged user, redirect to /login
             if (next.templateUrl != "partials/login.html") {
                 $location.path("/login");
             }
+        } else { // already loggedin
+            if (next.templateUrl == "partials/login.html") {
+                $location.path("/mail");
+            }
         }
     }); 
   }]);