Fixed authentication bug in mongoose