Refractory the login process with state pattern.