﻿"use strict";

// error controller
app.controller("errorController", ["$scope", "localStorageService", "ngAuthSettings", "$location", function ($scope, localStorageService, ngAuthSettings, $location) {
    $scope.init = function () {
        $scope.location = $scope.isLoggedIn() ? "Dashboard" : "Login";
    };
    $scope.backToLocation = function () {
        if ($scope.isLoggedIn()) {
            $location.path("/ballotDashboard");
        }
        else {
            $location.path("/login");
        }
    };

    $scope.isLoggedIn = function () {
        var authData = localStorageService.get(ngAuthSettings.authDataKey);
        if (authData)
            return true;
        return false;
    };

    $scope.init();
}]);