no clue what im doing

This commit is contained in:
Jon Lambson 2017-08-24 16:51:19 -06:00
parent 0d67c0d10c
commit 20a25c38e3
3 changed files with 12 additions and 7 deletions

View File

@ -8,13 +8,13 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider
$urlRouterProvider.otherwise('/splash-page');
$stateProvider
.state('splash-page', {
data: { requiresLogin: false },
data: { requiresLogin: false, session: null },
url: '/splash-page',
templateUrl: '/templates/splash-page.html',
controller: 'loginCtrl as vm'
})
.state('app',{
data: { requiresLogin: true },
data: { requiresLogin: true, session: null },
url: '/',
controller: 'loginCtrl as vm',
views: {
@ -112,11 +112,12 @@ app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider
});
}]);
app.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) {
app.run(['$rootScope', '$state', 'Auth', '$location', function($rootScope, $state, Auth, $location) {
console.log('$location:', $location.search());
$rootScope.urlArray = [];
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
var requiresLogin = toState.data.requiresLogin;
toState.data.session = $location.search();
$rootScope.redirectedURL = toState.url;
$rootScope.urlArray.push($rootScope.redirectedURL);
if ($rootScope.urlArray.length > 1) {
@ -126,7 +127,11 @@ app.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) {
if (requiresLogin && !Auth.isLoggedIn()) {
event.preventDefault();
console.log('asdfasdfasdfasdfasdfasdfasdfasdf', toState);
$state.go('splash-page', { 'toState': toState.name });
} else {
// Auth.get(Auth.session);
}
});
}]);

View File

@ -1,6 +1,6 @@
app.controller('loginCtrl', [
'$scope', '$timeout', 'Auth', '$location', 'localStorageService', '$rootScope', 'azp@oauth3.org'
, function ($scope, $timeout, Auth, $location, localStorageService, $rootScope, Oauth3) {
'$scope', '$timeout', 'Auth', '$location', 'localStorageService', '$rootScope', 'azp@oauth3.org', '$stateParams'
, function ($scope, $timeout, Auth, $location, localStorageService, $rootScope, Oauth3, $stateParams) {
var vm = this;

View File

@ -1,7 +1,7 @@
<section class="col-md-offset-4 col-md-4 login-container" ng-init="vm.initListLoggedInProfiles()">
<form>
<h4 class="text-center">Sign in</h4>
<a href="#!/home" class="current-user-container" ng-repeat="profile in vm.sessions track by $index" ng-click="vm.selectSession(profile);">
<a ui-sref="app.home" class="current-user-container" ng-repeat="profile in vm.sessions track by $index" ng-click="vm.selectSession(profile);">
<div class="current-user-split"><i class="fa fa-user"></i></div>
<div class="current-user-text">Resume with {{ profile.email }}</div>
</a>