create authenticate function in repository