/ Authentication / Allow Unconfirmed User to Sign-in (Devise)

After the successful sign up, I would like to sign in the user directly but I will still want to display the message to tell the user to confirm his account. Here how’s I did that.

1. Edit User model

def self.allow_unconfirmed_access_for
  30.days # Or any time frame you like
end

 

2. Display the message

Edit app/layouts/application.html.erb :

<% if user_signed_in? && !current_user.confirmed? %>
   <p class="alert">
     <b>Please verify your email address to access all of Quickrail's features.</b> <br/>
     An email containing verification instructions was sent to <%= current_user.email %>.
   </p> 
<% end %>

 

No video for this post.

No issues for this post.

by ryzalyusoff