(function() {
"use strict";
var app;
app = void 0;
app = angular.module("app", ["ngRoute", "ngAnimate", "ui.bootstrap",
"easypiechart", "mgo-angular-wizard", "textAngular", "ui.tree", "ngMap",
"ngTagsInput", "app.ui.ctrls", "app.ui.directives", "app.ui.services",
"app.controllers", "app.directives", "app.form.validation",
"app.ui.form.ctrls", "app.ui.form.directives", "app.tables", "app.map",
"app.task", "app.localization", "app.chart.ctrls", "app.chart.directives",
"app.page.ctrls"]);
app.config([
"$routeProvider", function($routeProvider) {
return $routeProvider.when("/", {
redirectTo: "/login"
}).when("/login", {
templateUrl: "views/pages/signin.html"
}).when("/dashboard", {
templateUrl: "views/dashboard.html"
}).when("/dispatch", {
templateUrl: "views/dynamic.html"
}).when("/pages/signin", {
templateUrl: "views/pages/signin.html"
}).when("/pages/blank", {
templateUrl: "views/pages/blank.html"
}).when("/dispatch", {
templateUrl: "views/tables/dynamic.html"
}).when("/management", {
templateUrl: "views/tables/management.html"
}).when("/addDriver", {
templateUrl: "views/forms/adddriver.html"
}).otherwise({
redirectTo: "/404"
});
}
]);
app.run(function(authentication, $rootScope, $location) {
return $rootScope.$on("$routeChangeStart", function(evt) {
if (!authentication.isAuthenticated) {
$location.url("/login");
}
return event.preventDefault();
});
});
app.controller("AppCtrl", function($scope, $location, authentication) {
var appId, authKey, params, secret, token;
appId = void 0;
authKey = void 0;
params = void 0;
secret = void 0;
$scope.templates = [
{
url: "/login"
}, {
url: "/dashboard"
}
];
appId = "10259";
authKey = "fshfsfwerj3443";
secret = "44j4fj3443lfkddkff";
token = void 0;
$scope.template = $scope.templates[0];
$scope.session = QB.init(appId, authKey, secret, true);
$scope.token = QB.createSession(function(err, result) {
if (err) {
return $scope.loginError = "Invalid username/password
combination";
} else {
return app.value("token", result.token);
}
});
return $scope.login = function(username, password) {
return QB.login({
login: username,
password: password
}, function(err, result) {
if (err) {
return $scope.loginError = "Invalid username/password
combination";
} else {
console.log(token);
authentication.isAuthenticated = true;
return $location.path("/dashboard");
}
});
};
});
return app.factory("authentication", function() {
return {
isAuthenticated: false,
user: null
};
});
}).call(this);
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.