-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
app.js
121 lines (106 loc) · 2.86 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
angular.module('MyApp', ['ngResource', 'ngMessages', 'ngAnimate', 'toastr', 'ui.router', 'satellizer'])
.config(function($stateProvider, $urlRouterProvider, $authProvider) {
/**
* Helper auth functions
*/
var skipIfLoggedIn = ['$q', '$auth', function($q, $auth) {
var deferred = $q.defer();
if ($auth.isAuthenticated()) {
deferred.reject();
} else {
deferred.resolve();
}
return deferred.promise;
}];
var loginRequired = ['$q', '$location', '$auth', function($q, $location, $auth) {
var deferred = $q.defer();
if ($auth.isAuthenticated()) {
deferred.resolve();
} else {
$location.path('/login');
}
return deferred.promise;
}];
/**
* App routes
*/
$stateProvider
.state('home', {
url: '/',
controller: 'HomeCtrl',
templateUrl: 'partials/home.html'
})
.state('login', {
url: '/login',
templateUrl: 'partials/login.html',
controller: 'LoginCtrl',
resolve: {
skipIfLoggedIn: skipIfLoggedIn
}
})
.state('signup', {
url: '/signup',
templateUrl: 'partials/signup.html',
controller: 'SignupCtrl',
resolve: {
skipIfLoggedIn: skipIfLoggedIn
}
})
.state('logout', {
url: '/logout',
template: null,
controller: 'LogoutCtrl'
})
.state('profile', {
url: '/profile',
templateUrl: 'partials/profile.html',
controller: 'ProfileCtrl',
resolve: {
loginRequired: loginRequired
}
});
$urlRouterProvider.otherwise('/');
/**
* Satellizer config
*/
$authProvider.facebook({
clientId: '603122136500203'
});
$authProvider.google({
clientId: 'YOUR_GOOGLE_CLIENT_ID'
});
$authProvider.github({
clientId: 'YOUR_GITHUB_CLIENT_ID'
});
$authProvider.linkedin({
clientId: 'YOUR_LINKEDIN_CLIENT_ID'
});
$authProvider.instagram({
clientId: 'YOUR_INSTAGRAM_CLIENT_ID'
});
$authProvider.yahoo({
clientId: 'YOUR_YAHOO_CLIENT_ID'
});
$authProvider.live({
clientId: 'YOUR_MICROSOFT_CLIENT_ID'
});
$authProvider.twitch({
clientId: 'YOUR_TWITCH_CLIENT_ID'
});
$authProvider.bitbucket({
clientId: 'YOUR_BITBUCKET_CLIENT_ID'
});
$authProvider.spotify({
clientId: 'YOUR_SPOTIFY_CLIENT_ID'
});
$authProvider.twitter({
url: '/auth/twitter'
});
$authProvider.oauth2({
name: 'foursquare',
url: '/auth/foursquare',
clientId: 'MTCEJ3NGW2PNNB31WOSBFDSAD4MTHYVAZ1UKIULXZ2CVFC2K',
redirectUri: window.location.origin || window.location.protocol + '//' + window.location.host,
authorizationEndpoint: 'https://foursquare.com/oauth2/authenticate'
});
});