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

What If my api doesn't use .data #12

Closed
amrnt opened this issue Aug 14, 2014 · 6 comments
Closed

What If my api doesn't use .data #12

amrnt opened this issue Aug 14, 2014 · 6 comments

Comments

@amrnt
Copy link
Contributor

amrnt commented Aug 14, 2014

In your code when sign in you return data of resp.data. My API returned object doesn't have data attr. And it would be a night mare (somehow) to implement it. Temporarily, I'm hacking your code to make it works with me.

As well as this method: https://github.com/lynndylanhurley/ng-token-auth/blob/master/src/ng-token-auth.coffee#L87

@amrnt amrnt changed the title What If my api don't use .data What If my api doesn't use .data Aug 14, 2014
@lynndylanhurley
Copy link
Owner

@amrnt - good question. I think the cleanest solution will be to provide a configurable method that returns authentication data from the API response. Something like this:

angular.module('myApp', ['ng-token-auth'])
    .config(function($authProvider) {
        $authProvider.configure({
            apiUrl: 'http://api.example.com'
            handleAuthResponse: function(response) {
              // this would be the default
              return response.data;

              // or if you don't use the data param, just return the response itself
              return response;
            });
        });
    });

Would this be acceptable?

@amrnt
Copy link
Contributor Author

amrnt commented Aug 14, 2014

@lynndylanhurley Yes! This would be just fine!

@lynndylanhurley
Copy link
Owner

Cool, I'll have this ready within the next day or so.

@lynndylanhurley
Copy link
Owner

@amrnt - I just pushed a new beta release that I hope will resolve this issue. Can you please update to version 0.0.19-beta1 and verify that everything is in order?

The documentation for the new config params is here. Please take a look and let me know if the instructions are clear.

@amrnt
Copy link
Contributor Author

amrnt commented Aug 18, 2014

It works great! Thank you 😃

Tho, for the last release, Bower is complaining about the version ng-token-auth#0.0.19-beta1 error Invalid Version: 0.0.19.beta1!

@lynndylanhurley
Copy link
Owner

Must be a typo in the bower.json file 😵. I'll push a proper release tomorrow!

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

No branches or pull requests

2 participants