2 * Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 define(['angularAMD', 'jquery', 'common/authentification/auth.module', 'ocLazyLoad'], function (ng, $) {
10 var login = angular.module('app.common.login', ['app.common.auth', 'ui.router.state']);
12 login.config(function ($stateProvider, $httpProvider) {
18 templateUrl: 'src/common/login/login.tpl.html',
19 controller: 'LoginCtrl'
23 loadController: ['$ocLazyLoad', function ($ocLazyLoad) {
24 return $ocLazyLoad.load({
25 files: ['src/common/login/login.controller.js']
31 $httpProvider.interceptors.push('NbInterceptor');
34 login.run(function ($rootScope, $location, Auth) {
36 // to avoid recursive loop
37 var publicPath = ['/login'];
39 var isPublicPath = function (route) {
41 $.each(publicPath, function (key, value) {
42 found = found || route.match('^' + value);
47 $rootScope.$on('$stateChangeStart', function () {
48 if (!isPublicPath($location.url()) && !Auth.isAuthed()) {
49 $location.path('/login');