Created
April 15, 2013 15:50
-
-
Save sebastiangeiger/5389098 to your computer and use it in GitHub Desktop.
Devise strategy used when an admin has to verify users before they are granted access to a site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: UTF-8 | |
| class CheckVerifiedStrategy < ::Devise::Strategies::Base | |
| def valid? | |
| params[:user] and params[:user][:email] | |
| end | |
| def authenticate! | |
| user = User.where(email: params[:user][:email]).first | |
| if user and not user.verified? | |
| fail!(I18n.t('profile.requested')) | |
| else | |
| pass | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment