Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set my message from #inactive_message method #265

Open
vitaliiorlov opened this issue Nov 2, 2023 · 7 comments
Open

Unable to set my message from #inactive_message method #265

vitaliiorlov opened this issue Nov 2, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@vitaliiorlov
Copy link

Describe the bug

Hi!
I have defined #active_for_authentication? method in the User model according to the Devise documentation which can return false when I would like to disable login for users.

def active_for_authentication?
  super && ...
end

To show the reason why the user cannot log in I should define #inactive_message method in User model.

def inactive_message
  "My message"
end

But it doesn't work with this gem because in Login mutation you have such conditions.
Instead of my message, I saw a message that confirmation instructions were sent to my email address.

Steps to reproduce

  1. Define those methods in your User model:
def active_for_authentication?
  false
end

def inactive_message
  "My message"
end
  1. Try to log in.

Expected behavior

Show message from #inactive_message method.
By the way, #unauthenticated_message method also exists. Maybe it is worth supporting this method too.

Thank you!

@vitaliiorlov vitaliiorlov added the needs triage Needs to be clasified by the mantiners label Nov 2, 2023
@mcelicalderon
Copy link
Member

Thank you for looking into this, @vitaliiorlov! I'll take a look asap. It looks like something that might be easy to fix

@mcelicalderon mcelicalderon added bug Something isn't working and removed needs triage Needs to be clasified by the mantiners labels Nov 9, 2023
@mcelicalderon
Copy link
Member

@vitaliiorlov after taking a closer look at this, I see now that we based our implementation on DTA's implementation https://github.com/lynndylanhurley/devise_token_auth/blob/6b0659f18c678b319913d0fb053e96aa555857aa/app/controllers/devise_token_auth/sessions_controller.rb#L13

I still think this is something we can implement, but I need to take a longer look as it's not just removing something I thought we had overwritten. Also, looking at Devise's code https://github.com/search?q=repo%3Aheartcombo%2Fdevise%20inactive_message&type=code I'm not sure those messagesare easy to override? They return symbols and in one place it's interpolated. Could you please point to the docs where it's explained how to use this method?

@mcelicalderon mcelicalderon added enhancement New feature or request and removed bug Something isn't working labels Nov 15, 2023
@mcelicalderon
Copy link
Member

Thank you for the link, @vitaliiorlov. So it is based on localized messages. I still think that's something we can implement

@vitaliiorlov
Copy link
Author

Thank you @mcelicalderon! Looking forward for this enhancement.

@vitaliiorlov
Copy link
Author

Hello @mcelicalderon !

Any news regarding this?

Thank you!

@mcelicalderon
Copy link
Member

@vitaliiorlov we haven't had the chance to work on this yet and we'll do it as soon as possible. You are welcome to propose an MR for us to review if you have the time before we do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants