fixed sql to prevent link duplication and non multiprovider registration of same username