Wrote user authenticate method