User authentication logic + some web stuff