Update login process

refactor and change the check if it return to login page again