Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var push = new Ionic.Push({
- "debug": true
- });
- push.register(function(token) {
- console.log("My Device token:",token.token);
- push.saveToken(token); // persist the token in the Ionic Platform
- });
- $scope.login = function () {
- $http({
- method: "post",
- url: "http://200.189.253.200:8081/employee-connect/oauth/token",
- 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",
- withCredentials: true,
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- }
- })
- .success(function (data){
- window.localStorage.setItem("token_type", data.token_type);
- window.localStorage.setItem("token", data.access_token);
- $state.go('tabsController.home');
- })
- .error(function(data) {
- var alertPopup = $ionicPopup.alert({
- title: 'Login failed!',
- template: 'Please check your credentials!'
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement