Extensions #48
Replies: 12 comments
-
That would be awesome. I don't have any examples on how to do extensions yet, so I'm open to suggestions. One idea might be to swap the included module with a class method that takes options. class User < ApplicationRecord
revise_auth locking_enabled: true
end Or we can keep it simple with an initializer config that defines the features (which might be cleaner). |
Beta Was this translation helpful? Give feedback.
-
The initializer would be cleaner, but what if you have multiple models authenticated, let's say |
Beta Was this translation helpful? Give feedback.
-
Good point, although I'm not sure if I even want to support authenticating multiple models? Maybe we should, but it adds a lot of complexity. |
Beta Was this translation helpful? Give feedback.
-
That's true, but that would make it a great alternative to devise. |
Beta Was this translation helpful? Give feedback.
-
If we can figure out a clean way of doing it, I'd be happy to support it. I think we'd have to do something like the Devise routes like revise_auth :user
# Generates routes with the scope.
/users/sign_up
/users/login
/users/profile Then somehow the controller needs to figure out the model from the route. |
Beta Was this translation helpful? Give feedback.
-
Looks like we can use get "users/sign_up", to: "registrations#create", defaults: { model: "User" } We'd still need to figure out a way to handle |
Beta Was this translation helpful? Give feedback.
-
What are your thoughts on 2FA and passwordless authentication support built-in to this library? I'd like to contribute if you think it belongs here. |
Beta Was this translation helpful? Give feedback.
-
@excid3 can we define those methods from the method which adds the routes? If not, maybe we could have a global registry of authenticable models, and we can have a method missing in the controller to catch calls to |
Beta Was this translation helpful? Give feedback.
-
Yes please! I'd also like to do OAuth (client and provider like doorkeeper) |
Beta Was this translation helpful? Give feedback.
-
For methods like
class SomeProtectedController > ApplicationController
revise_auth_with :user
before_action :revise_authenticate!
end It's a bit more verbose, but it may make (future) code maintenance easier (I'm thinking about my future 2033 self). |
Beta Was this translation helpful? Give feedback.
-
@excid3 I was thinking about this multiple-model authentication and I think you are right, and the added complexity wouldn't be worth supporting it. If someone wants to have separate authenticated models, it would be recommended to use a role-based approach instead. |
Beta Was this translation helpful? Give feedback.
-
@gregmolnar yeah, I think so too. I always implement roles and supporting multiple models really goes down the rabbit hole of complexity. Might just be an "anti-feature" we need to make clear. |
Beta Was this translation helpful? Give feedback.
-
Are you planning to support optional extensions like locking accounts on brute-force attempts, sudo mode, etc?
I would be happy to help with those if there is an example of how you would like them to be implemented.
Beta Was this translation helpful? Give feedback.
All reactions