1

I'm wondering if it's possible to selectively require confirmation for certain controller actions using Devise.

Basically: I want users to sign up for an account (which will trigger a confirmation email), be automatically logged in, and be able to immediately explore certain parts of the site as a signed in (but still unconfirmed) user. Access to certain areas (e.g., payment) would require the user to first confirm their email.

I'm hoping for something like before_filter: user_is_confirmed, only: [payment_related_stuff]

I searched for a while and could not find a way to do this out of the box, so I thought creating a hacky solution in which all possibly protected areas would still require before_filter: authenticate!, but I would override the Devise SessionsController's create to permissibly allow access to certain areas before confirmation. However, I'm not sure if this is the right way to go.

Sherwin Yu
  • 3,180
  • 2
  • 25
  • 41

1 Answers1

4

Using built in solution in devise, you could use allow_unconfirmed_access_for 1.year in combination with current_user.confirmed? in your before filter

Yuri Barbashov
  • 5,407
  • 1
  • 24
  • 20
  • Great, this is exactly what I want. This [post](https://groups.google.com/d/msg/plataformatec-devise/OOBqd4qMpuc/AYJWuYZHT58J) explains it in more detail. – Sherwin Yu Jul 23 '12 at 20:39