Search code examples
ruby-on-rails-3deviserestful-architecture

Rails RESTful API + Devise - How to check for user's credentials


I've built a RESTful API with Ruby On Rails, and now I good like to know whether the user's credentials received by POST are valid or not, using Devise.

Any ideas?


Solution

  • Devise - getting started should set you up.

    EDIT:

    Devise, by default, validates users by their email and password. If you want to add validation by username, refer this wiki Basically, you need to add username to the model and make it 'attr-accessible'

    Devise sets up paths for user sign-up, sign-in and sign-out, etc. Refer devise asciicast for these path helpers.

    To write controller tests, refer to this wiki for details.

    EDIT:

    Sorry for not understanding your requirements. Here is how to find user from credentials. This you can use from your service to validate user.