move login function into user class