Code Monkey home page Code Monkey logo

Comments (4)

gonzalo-bulnes avatar gonzalo-bulnes commented on May 26, 2024

Hi @jamespeerless!

Exactly, it makes total sense to use the standard Devise registration mecanism. (That's simple separation of concerns, Simple Token Authentication does not aim at providing registration, thing that Devises does very well.)
As you correctly noted, the token authenticatable objects receive their authentication token via the ensure_authentication_token method and an Active Record callback.

In fact, the need to override the Devises::SessionsController is not related to token authentication by itself, but comes from the JSON requirement. It's only because that is a such common use case that I provided in #27 the SimpleToken Authentification-compatible SessionsController example you saw (and that I am using myself).

Go with Devise Registerable, that's the right way!

from simple_token_authentication.

jamespeerless avatar jamespeerless commented on May 26, 2024

Cool, thanks for the response. What if I also want the registration route to return a json representation of the user (or at the very least the authentication_token). I'm not using rails for any of the view layer, I use it only as a backend rest api for SPA's and mobile.

from simple_token_authentication.

gonzalo-bulnes avatar gonzalo-bulnes commented on May 26, 2024

In that case you should probably overwrite the Devise::RegistrationsController or part of it. There are several examples around the Devise documentation, I haven't any particular recommendation for that specific point but I'd love to hear which solution worked for you.

from simple_token_authentication.

gonzalo-bulnes avatar gonzalo-bulnes commented on May 26, 2024

@jamespeerless Here is an example of overriden Devise::RegistrationsController which may be interesting to you. ; )

from simple_token_authentication.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.