Devise by default redirects the user to the previous url (if present) after authenticating. This is a very useful default to have. But this behaviour is lost if we override the
after_sign_in_path_for method in our application.
Internally devise stores the previous url in the session with key
resource_return_to. In its actual implemention,
after_sign_in_path_for checks for the presence of the
resource_return_to key in the session and redirects the user to it. We need to do the same if we ever override this method.
The recommended way of overriding is
Ref: stored_location_for is a helper method provided by devise.