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

The inactive_message and active_for_authentication #695

Closed
oklas opened this issue Aug 9, 2016 · 5 comments
Closed

The inactive_message and active_for_authentication #695

oklas opened this issue Aug 9, 2016 · 5 comments

Comments

@oklas
Copy link

oklas commented Aug 9, 2016

I use devise_token_auth and want to implement blocking user feature. The documentation about feature which I refer here.

First part concerning active_for_authentication work fine.

But the inactive_message does not called. And the result error message does not possible to change. The result is:

{
    "success":false,
    "errors":["A confirmation email was sent to your account at user@example.com. You must follow the instructions in the email before your account can be activated"]
}

How to change the error message? Why it is impossible to change error message via inactive_message and why it is not called? Possible is it bug?

@steveclarkin
Copy link

I believe this is the same as #533

I ran into this issue today. There are many reasons why an account could be inactive, so to follow devise's lead, i'm thinking DTA should probably use inactive_message override if it has been defined to the build the error response. Thoughts?

@navkar
Copy link

navkar commented Sep 1, 2016

correct. do this in your custom controller.

protected
      def render_create_error_not_confirmed
        render :json=> {:success=>false, errors: ["your account has been disabled"]}, :status=> 421
      end

@steveclarkin
Copy link

Works a treat, thanks!

@zachfeldman
Copy link
Contributor

Nice

@pooja-mane
Copy link

Currently, I am facing the same issue.
I am using devise version - (4.7.3), devise_token_auth - (1.1.5), ruby - (3.0.0) and rails - (6.1.3.1)

I have written my custom method in app/models/user.rb file

def active_for_authentication?
    super && is_active
  end

trying to overwrite inactive_message message in same user model file app/models/user.rb file.But not able to overwrite message. Getting error message as
"A confirmation email was sent to your account at 'admin3@gmail.com'. You must follow the instructions in the email before your account can be activated"

When I tried to overwrite message from config/locales/devise.en.yml

en:
    devise_token_auth:
        sessions:
              not_confirmed: 'Your account is not active.'

Then I am getting custom error message.

Can someone help me with this?

Thank you

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

No branches or pull requests

5 participants