move login functions into seperate controller file