(function() {
    'use strict';

    angular
        .module('app')
        .service('auth2Service', auth2Service);

    auth2Service.$inject = ['$cookies', '$http'];

    function auth2Service($cookies, $http) {
        this.checkAuthByResponse = checkAuthByResponse;
        this.checkAuthByCookie = checkAuthByCookie;

        function checkAuthByResponse(response) {
            if (response.status == 501) {
                window.location = "/home";
            }
        }

        function checkAuthByCookie() {
            return $cookies.user != "" || $cookies.user != undefined;
        }
    }
})();