Code written for authenticating user.