I have user and account model and the association is user has_one account. For authentication, I'm using devise gem. Whenever a user registered for the first time, an account is also created. But the account will be inactivation state. This will be in active state when the admin gives access to the account. If it is inactivation state then I need the page to redirect to the specific page where it will show Waiting for activation. I have used the below code
def after_sign_in_path_for(resource)
redirect activation_path
end
But if the user clicks on the other links it should not go to that page, it should be restricted and redirect to the activation path saying that under activation process.
You could, for example, add a before_action
for this
class ApplicationController
before_action :check_activation
private
def check_activation
redirect_to activation_path unless current_user.account.active?
end
end
TODO:
current_user
is nil) are handled properly