finish the authenticate user function