I am creating a module in which I want to check some condition after customer successfully login, if condition is true then customer login otherwise not.
I know two ways of doing this :
- Overriding
AccountController
- With Magento event.
My query are:
- which is the best way?
- Is there any event with which I can full fill my requirement?
Or if there is other best way of doing this, please recommend.
You need to use
customer_login
On theMage_Customer_Model_Session
model's methodsetCustomerAsLoggedIn()
the eventcustomer_login
is dispatched.config.xml
and your Observer
Whenever a user is sucessfully logged in, the event
customer_login
will be fired and you have observed the methodcustomerLogin()
on that event, so your method from the observer will execute whenever a customer is successfully logged in. Here you can check your conditions as per requirements.