deployd / docs

documentation for deployd
http://docs.deployd.com
29 stars 30 forks source link

Getting the current user with HTTP in AngularJS #12

Closed HerrHansen closed 9 years ago

HerrHansen commented 11 years ago

Hi there,

after a successful login per HTTP, I'm trying to get current user per HTTP in AngularJS.

Trying this, response an empty string, NO error:

    $http.get('http://localhost:2403/users/me')
    .success(function (user) {
      console.log("get user:");
      console.log(user);
    });

What did I miss with the Cookie instructions in docs?

Include the sid cookie to identify your session.

I see a Cookie under my chrome dev tool named 'sid' allways new with a refresh of login view. But I can't access to it with Angular's $cookieStore.get('sid')?

Question: Is it necessary to include the Cookie manually like the Deployd DOCs say it, or did I misread it?

GET /users/me Cookie: sid=6009c5b070d834a2d336224a93...

… if so, how should I include the current Cookie to the GET?

Thank you very very much.

P.S. Deployd is a great tool, thank you very much for this great work!

RoyceLithgo commented 10 years ago

You need to enable cookies to be passed. In a .config block, do the following:

.config(function($httpProvider){ $httpProvider.defaults.withCredentials = true; }

NicolasRitouet commented 9 years ago

I close this issue to clean up a bit. If you still have an issue, don't hesitate to reopen it.