User authentication logic