Update authenticate functions

#327 (comment from 17 to 20)