|
1 | 1 | import angular from 'angular' |
| 2 | +import { loadUser } from '../services/userv3.service.js' |
2 | 3 |
|
3 | 4 | (function () { |
4 | 5 | 'use strict' |
5 | 6 |
|
6 | 7 | angular.module('tc.listings').controller('ListingsCtrl', ListingsCtrl) |
7 | 8 |
|
8 | | - ListingsCtrl.$inject = ['CONSTANTS', 'logger', '$q', |
9 | | - 'TcAuthService', 'UserService', 'UserStatsService', 'ProfileService', 'ChallengeService', 'ExternalAccountService', |
10 | | - 'ngDialog', '$anchorScroll' |
| 9 | + ListingsCtrl.$inject = ['CONSTANTS', 'logger', '$q','TcAuthService', 'UserService', |
| 10 | + 'UserStatsService', 'ProfileService', 'ChallengeService', |
| 11 | + 'ExternalAccountService', 'ngDialog', '$anchorScroll', '$scope' |
11 | 12 | ] |
12 | 13 |
|
13 | | - function ListingsCtrl(CONSTANTS, logger, $q, TcAuthService, UserService, UserStatsService, ProfileService, ChallengeService, ExternalAccountService, ngDialog, $anchorScroll) { |
| 14 | + function ListingsCtrl(CONSTANTS, logger, $q, TcAuthService, UserService, UserStatsService, ProfileService, |
| 15 | + ChallengeService, ExternalAccountService, ngDialog, $anchorScroll, $scope) { |
14 | 16 |
|
15 | 17 | activate() |
16 | 18 |
|
17 | 19 | function activate() { |
| 20 | + $scope.myChallenges = [] |
| 21 | + $scope.userProps = { isAuth: false } |
18 | 22 | logger.debug('Calling ListingsController activate()') |
19 | 23 |
|
| 24 | + loadUser().then(function(token) { |
| 25 | + // update auth flag |
| 26 | + if(TcAuthService.isAuthenticated()) { |
| 27 | + $scope.userProps = { isAuth: true } |
| 28 | + } |
| 29 | + }, function(error) { |
| 30 | + // do nothing, just show non logged in state of navigation bar |
| 31 | + }) |
20 | 32 | } |
| 33 | + |
21 | 34 | } |
22 | 35 |
|
23 | 36 | })() |
0 commit comments