Implemented login and register functionality