On sign up not getting a meaningful flash message

1,350 views
Skip to first unread message

John Plummer

unread,
Feb 2, 2011, 3:29:22 PM2/2/11
to Devise
Using the current master, when signing up (and the model is
confirmable) I am getting a flash notice of 'You need to sign in or
sign up before continuing.' and the sign in page after pressing sign
up. I would expect to see 'You will receive an email with instructions
about how to confirm your account in a few minutes.'

The user is getting created successfully in the database. If I fill
email and password on sign in page I get the flash message 'You have
to confirm your account before continuing.' as I would expect.

I have recreated this on a test project with rails 3.0.3
* No changes to devise.rb
* Set up action_mailer default url, root :to, and flash classes in
application layout
* Generated a user model and added :confirmable
* Amended the migration to add t.confirmable and index for
confirmation_token
* Added before_filter to HomeController.

I have tried looking through the code but cant see anything.

Any pointers appreciated.

John

Carlos Antonio da Silva

unread,
Feb 2, 2011, 3:32:08 PM2/2/11
to plataforma...@googlegroups.com
You can change pretty much all devise messages in the locale file Devise copies to your app when you run devise:install generator.
--
At.
Carlos A. da Silva

John Plummer

unread,
Feb 2, 2011, 4:22:03 PM2/2/11
to Devise
Hi Carlos.

I think devise (in my instance at least) is showing:

failure: / unauthenticated: 'You need to sign in or sign up before
continuing.'

where I would expect to see either:

failure: / unconfirmed: or registrations: / inactive_signed_up: or
confirmations: / send_instructions:

I don't want to edit the unauthenticated message as it is correct in
most instances.

John


On Feb 2, 8:32 pm, Carlos Antonio da Silva

John Plummer

unread,
Feb 7, 2011, 4:15:34 PM2/7/11
to Devise
Still having problems with this issue. My failing scenario is:
Feature: Authentication

This scenario fails on the last step I am getting a flash message of
"You need to sign in or sign up before continuing." Rather than
"You have signed up successfully. However, we could not sign you in
because your account is unconfirmed."
which is the correct message according to test/integration/
registerable_test.rb -
test 'a guest user should be able to sign up successfully and be
blocked by confirmation'

Scenario: Register new user
Given I am not signed in
And I am on the sign up page
And I fill in the following:
| Email | fr...@foo.bar |
| Password | password |
| Password confirmation | password |
When I press "Sign up"
Then a new user should get created with the following details:
| email |
| fr...@foo.bar |
And I should receive an email with the following details:
| subject |
body |
| Confirmation instructions | You can confirm your account
through the link below |
And I should be on the sign in page
And I should see "You have signed up successfully. However, we
could not sign you in because your account is unconfirmed."

I have pushed a bare bones project to https://github.com/JohnPlummer/test_confirm.
I presume I must have something wrong in the config but can't for the
life of me work out what.

John

José Valim

unread,
Feb 7, 2011, 4:58:30 PM2/7/11
to plataforma...@googlegroups.com
John,

I took a quick look at your sample app and I can see what is happening. After you create an account, Devise redirects you to the root_url. However, your root_url *is protected* and requires authentication. So after you create your account, you are redirect to root_url with the proper flash message (which contains confirmation instructions), however, when hitting the root_url, you are redirecting to the sign in page, showing the message you need sign in or sign up. To fix the issue, you need to configure the path you are redirect to after you create an account. There are several ways to do it, one option is to inherit from RegistrationsController and overwrite this method:


These methods are public APIs, so you will be safe overriding them.

John Plummer

unread,
Feb 8, 2011, 9:48:55 AM2/8/11
to Devise
Thanks José

On Feb 7, 9:58 pm, José Valim <jose.va...@gmail.com> wrote:
> John,
>
> I took a quick look at your sample app and I can see what is happening.
> After you create an account, Devise redirects you to the root_url. However,
> your root_url *is protected* and requires authentication. So after you
> create your account, you are redirect to root_url with the proper flash
> message (which contains confirmation instructions), however, when hitting
> the root_url, you are redirecting to the sign in page, showing the message
> you need sign in or sign up. To fix the issue, you need to configure the
> path you are redirect to after you create an account. There are several ways
> to do it, one option is to inherit from RegistrationsController and
> overwrite this method:
>
> https://github.com/plataformatec/devise/blob/master/app/controllers/d...
Reply all
Reply to author
Forward
0 new messages