fixed issues with logging in and token generation