Have user setup use a cookie to determine which section to have open by default

This commit is contained in:
Joseph Schorr 2013-12-11 18:27:35 -05:00
parent 9dbbd33afc
commit 242f844055
2 changed files with 13 additions and 3 deletions

View file

@ -90,7 +90,7 @@ function getMarkedDown(string) {
// Start the application code itself.
quayApp = angular.module('quay', ['ngRoute', 'restangular', 'angularMoment', 'angulartics', 'angulartics.mixpanel', '$strap.directives', 'ngCookies'], function($provide) {
$provide.factory('UserService', ['Restangular', function(Restangular) {
$provide.factory('UserService', ['Restangular', '$cookies', function(Restangular, $cookies) {
var userResponse = {
verified: false,
anonymous: true,
@ -102,6 +102,10 @@ quayApp = angular.module('quay', ['ngRoute', 'restangular', 'angularMoment', 'an
var userService = {}
userService.hasEverLoggedIn = function() {
return $cookies.loggedIn == 'true';
};
userService.load = function(opt_callback) {
var userFetch = Restangular.one('user/');
userFetch.get().then(function(loadedUser) {
@ -117,6 +121,8 @@ quayApp = angular.module('quay', ['ngRoute', 'restangular', 'angularMoment', 'an
mixpanel.people.set_once({
'$created': new Date()
})
$cookies.loggedIn = 'true';
}
if (opt_callback) {
@ -661,6 +667,10 @@ quayApp.directive('userSetup', function () {
$scope.sent = false;
});
};
$scope.hasSignedIn = function() {
return UserService.hasEverLoggedIn();
};
}
};
return directiveDefinitionObject;