Implements secure login and login check.