I'm building a new app and im using devise for authentication. I need
some extended functionality. It should be easy to implement but im new
to ruby and also rails. The thing is, after a user sign up and confirm
his/her email, admin must be approve their account (Or after
transaction complete).
I'll be glad if someone give me an idea about implement this kind of
functionality.
Thanks!
You'd probably need an attribute like :approved in your users table,
false by default, and then you can override a class method Devise
provides called find_for_authentication, something like:
def self.find_for_authentication(conditions={})
conditions[:approved] = true
find(:first, :conditions => conditions)
end
This way if your user is not approved, it won't be able to
authenticate.
So, the strategy is authenticatable if im not wrong.
By default, devise sets error msg :invalid after a failed login.
When approved = false, either password is correct or wrong, it also
sets :invalid.
How can i add a proper error msg when user email&pass is true but his/
her account disabled for log in?
I'll be glad if anyone give me a clue about to implement this idea.
Thanks
The hook is called whenever the user is retrieved from session and
it's a better approach because it allows the Administrator to activate
and deactivate any account at any time and the user will be
immediately signed out.
If you just check the active? on sign in, after the user is signed in,
you cannot sign him out anymore.
You can have this same behavior using before_filters in your
controllers. Just choose the one which pleases you the most. :)
Now im able to extend this strategy like confirmable right?
Like sending email after account activation or the opposite
I added some methods to activatable, like activate account, send user
an email to tell his/her account is activated and so on.
Im not using confirmable and i dont think that i need it but,
activatable includes to confirmable.
So that means i cant use confirmable methods anymore right?
I just tried to call "send_confirmation_instructions" to just see if
its working but what i saw is a NoMethodError.
Thanks for your help and also for Devise