finish the function of login and layout