Yes, we have to introduce a flag so as to  redirect to the original page after login successfully