Advertisement
Guest User

Untitled

a guest
Jun 17th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. var push = new Ionic.Push({
  2. "debug": true
  3. });
  4.  
  5. push.register(function(token) {
  6. console.log("My Device token:",token.token);
  7. push.saveToken(token); // persist the token in the Ionic Platform
  8.  
  9. });
  10.  
  11. $scope.login = function () {
  12. $http({
  13. method: "post",
  14. url: "http://200.189.253.200:8081/employee-connect/oauth/token",
  15. data: "username="+$scope.username+"&password="+$scope.password+"&grant_type=password&scope=read write&client_secret=my-secret-token-to-change-in-production&client_id=employeeConnectapp2",
  16. withCredentials: true,
  17. headers: {
  18. 'Content-Type': 'application/x-www-form-urlencoded'
  19. }
  20. })
  21. .success(function (data){
  22. window.localStorage.setItem("token_type", data.token_type);
  23. window.localStorage.setItem("token", data.access_token);
  24. $state.go('tabsController.home');
  25. })
  26. .error(function(data) {
  27. var alertPopup = $ionicPopup.alert({
  28. title: 'Login failed!',
  29. template: 'Please check your credentials!'
  30. });
  31. });
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement