-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.run.js
31 lines (24 loc) · 876 Bytes
/
app.run.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
(function () {
"use strict";
angular
.module("calendarApp")
.run(appRun);
function appRun(GAuth, GApi, $state, $transitions, $q) {
var CLIENT = "576434137862-eb52i5mrh8lag6tpnsrpviqjfntprnq3.apps.googleusercontent.com";
GApi.load("calendar", "v3")
.catch(function (api, version) {
console.log("error occured", api, version);
});
GAuth.setClient(CLIENT);
GAuth.setScope("https://www.googleapis.com/auth/calendar");
$transitions.onBefore({ to: "calendar" }, function () {
var deferred = $q.defer();
GAuth.checkAuth().then(function () {
deferred.resolve(true);
}, function () {
deferred.resolve($state.target("login"));
});
return deferred.promise;
});
}
})();