Fix bugs in authentication service