Chargify - Subscriptions are cancelled automatically in TEST mode

We have integrated Chargify in one of our web application for recurring subscription payments. Recently we observed that few of our test users, that are more than 6 months old, are unable to login in our staging site, which is connected to Chargify TEST Mode. We noticed that auto cancellations are happening (once a day) for these users in their Chargify subscription records. This was a strange behaviour. We thought either this is happening due to our Dunning settings in Chargify or due to unpaid state changes for credit card expiry. After debugging and verifying everything in our Chargify settings,

Customizing Devise authentication, to check for active Chargify subscription

This post is an extension of article. I added further customization to check if user has active chargify_subscription and then only proceed to login otherwise show custom message instead of default devise message. Here is what I did (2 step process). In our user model (specifically user_extensions) override devise method active_for_authentication as follows def active_for_authentication? super && locked? && active_subscription? end Calling super first is very important here, to have devise perform all its regular checks first and then upon success we can proceed to add our custom checks. locked? is