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

Documentation: Logging in #15

Closed
gregpalaci opened this issue Oct 26, 2015 · 5 comments
Closed

Documentation: Logging in #15

gregpalaci opened this issue Oct 26, 2015 · 5 comments
Assignees
Milestone

Comments

@gregpalaci
Copy link

Would be great to show an example of logging a user in from the public site. I see the admin section has a full fledged angular application and 1000's of lines of code to do this. It's still not clear the mechanism to create a session.

Is it simply a POST to /login with a response that should be added as cookie?

@loicsaintroch loicsaintroch added this to the v1.3.0 milestone Oct 26, 2015
@pierreburgy
Copy link
Member

What do you mean by public site?

Here is the documentation for user authentication: http://strapi.io/documentation/users

@gregpalaci
Copy link
Author

Using POST /auth/local/register I get back the newly created user and jwt.
Using POST /auth/local/login with the same users filled in credentials:

{
  "identifier": "contact@company.com",
  "password": "123456"
}

I get back a 400:
http://localhost:1337/auth/local/login Failed to load resource: the server responded with a status of 400 (Bad Request)

@gregpalaci
Copy link
Author

By public site I mean, not the admin section.. The project root index.html.

Script:

$.ajax({
  type: "POST",
  url: '/auth/local/register',
  data: {
    username: "bobbybrown123",
    email: "bobbybrown123@gmail.com",
    password: "bobbybrown123"
  },
  success: function(response) {
    console.log(response) // works returns user
  }
});

// executed after user is created, 400 response

$.ajax({
  type: "POST",
  url: '/auth/local/login',
  data: {
    identifier: "bobbybrown123@gmail.com",
    password: "bobbybrown123"
  },
  success: function(response) {
    console.log(response)
  }
});

@gregpalaci
Copy link
Author

Ok I've figured it out. The documentation http://strapi.io/documentation/users#local-login says /auth/local/login but when I viewed the network request of logging in from admin it is actually /auth/local
Maybe it's an error in the documentation?

@pierreburgy
Copy link
Member

Good catch, @sylvainlap just made a pull request to update the documentation : strapi/strapi-docs#2
Thanks @gregbenner @sylvainlap

@strapi strapi locked and limited conversation to collaborators Oct 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants