-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
executable file
·35 lines (30 loc) · 1.14 KB
/
script.js
File metadata and controls
executable file
·35 lines (30 loc) · 1.14 KB
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
angular.module('CarreExample', ['ngCookies'])
.config(function($locationProvider) {
$locationProvider.html5Mode(true);
})
.controller('ExampleController', function($scope, $cookies, $location,$http) {
//set up the urls
var CARRE_DEVICES = 'https://devices.carre-project.eu/devices/accounts';
var API = 'https://devices.carre-project.eu/ws/';
//clean up the browser url
$location.url('/').replace();
var baseUrl = $location.absUrl();
$scope.loginUrl = CARRE_DEVICES + '/login?next=' + baseUrl;
$scope.logoutUrl = CARRE_DEVICES + '/logout?next=' + baseUrl;
// Retrieving a cookie and set initial user object
var TOKEN = $cookies.get('CARRE_USER') || '';
$scope.user = {};
//validate cookie token with userProfile api function and get username userGraph
if (TOKEN.length > 0) {
$http.get(API + 'userProfile?token=' + TOKEN).then(function(res) {
$scope.user = {
oauth_token: TOKEN,
username: res.data.username,
email: res.data.email
};
}, function(err) {
$scope.user = {};
console.log(err);
});
}
});