Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ionic 1.1.0 works with Angular 1.4.3 #222

Closed
gouroujo opened this issue Oct 6, 2015 · 6 comments
Closed

Ionic 1.1.0 works with Angular 1.4.3 #222

gouroujo opened this issue Oct 6, 2015 · 6 comments

Comments

@gouroujo
Copy link

gouroujo commented Oct 6, 2015

Hi there,
Thanks for you're very useful package.
As you probably know Ionic 1.1 is now released with Angular 1.4.3
but in your bower.json you specified that angular should be at least at 1.4.4. There is a reason to specified this version instead of 1.4.3?
Thanks

@AdamQuadmon
Copy link
Contributor

I'm also blocked to v0.0.27 because I'm using angular 1.3.8
It's really needed to force angular 1.4.x?

@2624789
Copy link

2624789 commented Oct 16, 2015

Hi, I'm using Ionic 1.1.0 with ng-token-auth 0.0.28 and I'm having problems because when I test the app from ionic view it does not send any of the headers access-token, client and uid.

I don't know if this is a problem because of the version or something related with ionic configuration

angular.version
Object {full: "1.4.3", major: 1, minor: 4, dot: 3, codeName: "foam-acceleration"}
ionic.version
"1.1.0"

bower.json

 "devDependencies": {
    "ionic": "driftyco/ionic-bower#1.1.0",
    "ionic-platform-web-client": "~0.1.0"
  },
  "dependencies": {
    "ng-token-auth": "~0.0.28"
  }

@2624789
Copy link

2624789 commented Oct 16, 2015

Hi, I keep trying to configure ng-token-auth 0.0.28 with ionic 1.1.0, the problem is that the Ionic app does not send ng-token-auth headers, so I wrote an Http Interceptor using $auth.retrieveData('auth_headers') for getting the headers from the cookies (I saw it here), but it did not work.

app.factory('authInterceptor', function($injector) {
  var authInterceptor = {
    request: function(config) {
      $injector.invoke(['$http', '$auth', function($http, $auth) {
        if (config.url.match($auth.apiUrl())) {
          var headers = $auth.retrieveData('auth_headers')
          for (property in headers) {
            if (headers.hasOwnProperty(property)) {
              config.headers[property] = headers[property]
            }
          }
        }
      }])
      config.headers['header_estatico'] = 'valor'
      console.log(config.headers)
      return config;
    }
  }
  return authInterceptor;
})

app.config(['$httpProvider', function($httpProvider) {
  $httpProvider.interceptors.push('authInterceptor')
}])

I added an additional header for testing the behaviour and found that the static header is sent in the Ionic App, but not the ones obtained wit $auth.retrieveData(), so I think the problem could be with this function, maybe the way how it get the info from the cookies does not work well on the ionic app.

I'm not sure if these headers exist in the cookies of the ionic app, I can't see the console using Ionic View, I'm using wireshark to see the headers sent from the ionic view app, so I know what is sent, but no what is stored in the cookies.

@2624789
Copy link

2624789 commented Oct 17, 2015

Hi, the only problem I have found using ng-token-auth 0.0.28 with ionic 1.1.0 and angular 1.4.3 is that ipCookie, the library that uses ng-token-auth does not work in Ionic, maybe because Ionic uses ng-cookies instead for handling cookies.

So, the solution is simple, not using cookies for storage headers, instead set the config option storage to localStorage. It uses window.localStorage instead of cookies and it works.

hope it helps.

@gouroujo
Copy link
Author

Yes I already use localStorage. My problem was mainly with bower's resolution which didn't want to install ng-token with angular 1.4.3 so during the page load I've got the error "unable to fin the module ng-token". The error is resolved when I manually downgrade the package dependencies.

@gouroujo
Copy link
Author

This issue is resolved by c0a7783

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants