add index on login

also deal with case of already existing record