-
-
Save iamonuwa/3566423025ce441b76c7084541bfa9e6 to your computer and use it in GitHub Desktop.
Cross Origin Request Blocked. What's wrong with thes codes???
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('app', ['satellizer', 'ngRoute','ui.router', 'paystack', 'chieffancypants.loadingBar','truncate', 'homeModule', 'videoModule', 'packageModule', 'eventManagerModule', 'userManagerModule', 'upload', 'event']) | |
app.config(function($routeProvider, $locationProvider, $authProvider, $httpProvider){ | |
$routeProvider | |
.when('/home', { | |
templateUrl: 'partials/home.html', | |
controller: 'HomeCtrl' | |
}) | |
.when('/pricing', { | |
templateUrl: 'partials/pricing.html' | |
}) | |
.when('/events', { | |
templateUrl : 'partials/home.html', | |
controller: 'HomeCtrl' | |
}) | |
.when('/event', { | |
templateUrl : 'partials/event.html', | |
controller: 'EventCtrl' | |
}) | |
.when('/digitaltv', { | |
templateUrl : 'partials/home.html', | |
controller: 'HomeCtrl' | |
}) | |
.when('/blog', { | |
templateUrl : 'partials/home.html', | |
controller: 'HomeCtrl' | |
}) | |
.when('/article', { | |
templateUrl : 'partials/article.html' | |
}) | |
.when('/trending', { | |
templateUrl : 'partials/home.html', | |
controller: 'HomeCtrl' | |
}) | |
.when('/statistics', { | |
templateUrl: 'partials/statistics.html' | |
}) | |
.when('/more', { | |
templateUrl : 'partials/about.html' | |
}) | |
.when('/about', { | |
templateUrl : 'partials/about.html' | |
}) | |
.when('/contact', { | |
templateUrl : 'partials/contact.html' | |
}) | |
.when('/terms', { | |
templateUrl : 'partials/terms.html' | |
}) | |
.when('/channel', { | |
templateUrl: 'partials/channel.html', | |
controller: 'HomeCtrl' | |
}) | |
.when('/search/:id', { | |
templateUrl: 'partials/searchPage.html', | |
controller: 'HomeCtrl' | |
}) | |
.when('/video/:id', { | |
templateUrl: 'partials/video.html', | |
controller: 'VideoCtrl' | |
}) | |
.when('/live_stream', { | |
templateUrl : 'partials/live_stream.html' | |
}) | |
.when('/upload', { | |
templateUrl: 'partials/upload.html', | |
controller: 'UploadCtrl', | |
}) | |
.when('/manage_packages', { | |
templateUrl : 'partials/manage_packages.html', | |
controller: 'PackageCtrl' | |
}) | |
.when('/manage_feeds', { | |
templateUrl: 'partials/manage_feeds.html' | |
}) | |
.when('/manage_events', { | |
templateUrl: 'partials/manage_events.html', | |
controller: 'EventManagerCtrl' | |
}) | |
.when('/manage_events/create', { | |
templateUrl: 'partials/addEvent.html', | |
controller: 'EventManagerCtrl' | |
}) | |
.when('/manage_users', { | |
templateUrl : 'partials/manage_users.html', | |
controller: 'UserManagerCtrl' | |
}) | |
.otherwise({redirectTo: '/home'}) | |
// $locationProvider.html5Mode(true); | |
$authProvider.twitter({ | |
url: '/auth/twitter', | |
authorizationEndpoint: 'https://api.twitter.com/oauth/authenticate', | |
redirectUri: window.location.origin, | |
oauthType: '1.0', | |
popupOptions: { width: 495, height: 645 } | |
}); | |
}) | |
app.config(['$compileProvider', function ($compileProvider) { | |
$compileProvider.debugInfoEnabled(false); | |
}]); | |
app.constant('API', 'http://35.165.38.70/api/v1/') | |
app.config(['$paystackProvider', function ($paystackProvider) { | |
$paystackProvider.configure({ | |
key: 'pk_test_2da80a7ebd7b680aad762bfda430fbeb0b957446' | |
}); | |
}]); | |
app.config(['$httpProvider', function($httpProvider) { | |
// $httpProvider.defaults.withCredentials = true; | |
$httpProvider.defaults.useXDomain = true; | |
delete $httpProvider.defaults.headers.common['X-Requested-With']; | |
// $httpProvider.defaults.headers.common["Content-Type"] = "application/json"; | |
$httpProvider.defaults.headers.common = {}; | |
$httpProvider.defaults.headers.post = {}; | |
$httpProvider.defaults.headers.put = {}; | |
$httpProvider.defaults.headers.patch = {}; | |
}]); | |
app.filter('trustUrl', function ($sce) { | |
return function(url) { | |
return $sce.trustAsResourceUrl(url); | |
} | |
}) | |
app.filter('escape', function() { | |
return function(input) { | |
if(input) { | |
return window.encodeURIComponent(input) | |
} | |
return "" | |
} | |
}) | |
function authInterceptor(API, auth) { | |
return { | |
request: function (config) { | |
var token = auth.getToken(); | |
if (config.url.indexOf(API) === 0 && token) { | |
config.headers.Authorization = 'Bearer ' + token; | |
} | |
return config; | |
}, | |
response: function (res) { | |
if (res.config.url.indexOf(API) === 0 && res.data.token) { | |
auth.saveToken(res.data.token); | |
} | |
return res; | |
} | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.user = { | |
auth: '', | |
type : 'standard', | |
authenticate: function(email, password){ | |
this.email = email; | |
this.password = password; | |
account.login(this.email, this.password) | |
.then(handleRequest, handleRequest) | |
}, | |
createUser: function (username, email, password) { | |
this.username = username; | |
this.email = email; | |
this.password = password; | |
this.password_confirmation = password; | |
account.register(this.username,this.email, this.password) | |
.then(handleRequest, handleRequest) | |
}, | |
logout: function () { | |
auth.logout && auth.logout(); | |
} | |
}; | |
$scope.$watch(function() { return isLoggedin() }, | |
function(newValue, oldValue) { | |
$scope.user.auth = newValue; | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by su on 1/6/17. | |
*/ | |
angular.module('userService', []).factory('account', function ($http, API, $q, auth) { | |
// $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded"; | |
// delete $http.defaults.headers.common['X-Requested-With']; | |
var config = { | |
headers : { | |
'Content-Type': 'application/json' | |
} | |
} | |
self.register = function(name, email, password) { | |
return $http.post(API + 'register', { | |
name: name, | |
email: email, | |
password: password, | |
password_confirmation: password | |
}, config) | |
}; | |
self.login = function (email, password) { | |
this.email = email; | |
this.password = password; | |
return $http.post(API + 'login', { | |
email: this.email, | |
password: this.password | |
},config) | |
// return $http({ | |
// method: 'POST', | |
// type: 'jsonp', | |
// url: API + 'login', | |
// data: { | |
// email: this.email, | |
// password: this.password | |
// } | |
// }); | |
}; | |
self.getUserName = function () { | |
}; | |
self.getUsers = function () { | |
} | |
return { | |
register: register, | |
login: login, | |
getUsers: getUsers | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment