File size: 1,633 Bytes
597ee18 | 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 | (function () {
'use strict';
angular
.module('app', ['satellizer'])
.controller('HomeCtrl', HomeCtrl)
.config(config);
HomeCtrl.$inject = ['$auth','$scope','$http', '$location','$window'];
function HomeCtrl($auth, $scope, $http, $location, $window){
$scope.twitter_submitted = false;
$scope.linked = false;
$scope.bothSubmitted = false;
$scope.phonenumber = "";
$scope.submitNumber = function() {
var data = {
phone_number: $scope.phonenumber,
token: $window.localStorage['token']
}
$http.post('/post/phonenum', data)
.then(function () {
console.log('submitted');
$scope.linked = !$scope.linked;
$scope.bothSubmitted = !$scope.bothSubmitted;
console.log($scope.linked);
$location.path('/');
});
}
$scope.oauth2 = function(provider) {
$auth.authenticate(provider)
.then(function(data) {
$scope.twitter_submitted = !$scope.twitter_submitted;
$scope.linked = !$scope.linked;
console.log(data.data.token);
$window.localStorage['token'] = data.data.token;
$location.path('/');
})
.catch(function(error) {
console.log(error);
});
};
}
config.$inject = ['$authProvider'];
function config($authProvider) {
$authProvider.twitter({
url: '/auth/twitter'
});
}
})();
|