Conversation
mcelicalderon
left a comment
There was a problem hiding this comment.
Left some comments about an alternative approach, let me know what you think. I think it should work
| else | ||
| Class.new(ActionController::Base) | ||
| end | ||
| ApplicationController = Class.new(GraphqlDevise.base_controller) |
There was a problem hiding this comment.
Would this fail in production with eager load? I think this would happen before the mount method gets executed during app start.
| module GraphqlDevise | ||
| module RouteMounter | ||
| def mount_graphql_devise_for(resource, options = {}) | ||
| GraphqlDevise.setup_base_controller(options.delete(:base_controller)) |
There was a problem hiding this comment.
What if we build a new controller class every time the method is called? Maybe something like:
# do not execute if base_controller option is not present
new_controller = GraphqlDevise.const_set("#{resource}AuthController", Class.new(options.delete(:base_controller)))
new_controller.include(SetUserByToken)
new_controller.include(AuthActionMethod) # module that defines the controller action
post clean_options.at, to: "#{new_controller.to_s.underscore}#auth"
get clean_options.at, to: "#{new_controller.to_s.underscore}#auth"Not sure that works, but it should?
mcelicalderon
left a comment
There was a problem hiding this comment.
This looks great! Left some notes. Also, what do you think about adding a test like the one you introduced for this when using the plugin?
| # frozen_string_literal: true | ||
|
|
||
| module GraphqlDevise | ||
| module AuthControllerMethods |
There was a problem hiding this comment.
WDYT about renaming this one to AuthControllerActions?
|
|
||
| class CookiesController < ApplicationController | ||
| include ActionController::Cookies | ||
| protect_from_forgery with: :null_session |
There was a problem hiding this comment.
WDYT about doing what we did in
instead of setting a null session here? That way we could probably test that the correct cookie is set after login and other mutations
This PR adds the option
base_controlleron the mount method. This will create a controller on the fly using the specified controller as the parent.