用户登陆
        :return: true if login successfully
339942
def login(self):
        
        self._cookies = self.__get_rndnum_cookies()
        # print self._cookies
        UserCode, UserPwd = self._userid, self._userpsw
        Validate = self._cookies['LogonNumber']
        Submit = '%CC%E1+%BD%BB'
        headers = {'Referer': 'http://jwc.wyu.edu.cn/student/body.htm'}
        # save header
        self._headers = headers
        data = {
            'UserCode': UserCode,
            'UserPwd': UserPwd,
            'Validate': Validate,
            'Submit': Submit,

        }
        r = requests.post('http://jwc.wyu.edu.cn/student/logon.asp', data=data, headers=headers, cookies=self._cookies)
        # print r.content.decode(_.get_charset(r.content))
        return True if r.status_code == 200 else False
858011
public static function isLogin() {

		if ( isset( $_SESSION[ md5( 'login' . self::$app->url->baseUrl() ) ] ) &&
		     base64_decode( $_SESSION[ md5( 'login' . self::$app->url->baseUrl() ) ] ) == 'TRUE'
		) {
			return TRUE;
		} else {
			return FALSE;
		}
	}
1267447
def handle_failed_login(self, login_result):
        
        error_code = login_result.get('error')
        if '2fa-required' in error_code:
            utils.error_message('Login Failed: 2FA or 2SV is active!')
            self.trigger_two_step_login(login_result)
            self.finish_two_step_login()
        else:
            utils.error_message_and_exit('\nLogin Failed', login_result)
1311818
public function loginByRememberMe(): bool {
		
		// build the cookie name
		$cookieName = static::getRememberMeCookieName();

		// check if cookie exists
		if (!isset($_COOKIE[$cookieName])) {
			return FALSE;
		}
			
		// try to unserialize the cookie content
		$content = unserialize($_COOKIE[$cookieName]);
		
		// cookie content is not unserializable
		if (FALSE === $content) {
			return FALSE;
		}

		// check if content exists and RememberMe length
		if (isset($content[0]) and isset($content[1]) and 32==strlen($content[1])) {
			
			// try to load user
			$user = static::getByRememberMe($content[1]);
			
			// if user exists, return it
			if (is_a($user, 'Pair\User')) {
				$user->createSession($content[0]);
				$user->renewRememberMe();
				return TRUE;
			}
		
		}
		
		return FALSE;
	
	}
265937
def authentication_ok(self):
        ''''''
        username = None
        password = None
        if self.authCallback:
            if self.authNeedUser:
                username = self.readline(prompt=self.PROMPT_USER, use_history=False)
            if self.authNeedPass:
                password = self.readline(echo=False, prompt=self.PROMPT_PASS, use_history=False)
                if self.DOECHO:
                    self.write("\n")
            try:
                self.authCallback(username, password)
            except:
                self.username = None
                return False
            else:
                # Successful authentication
                self.username = username
                return True
        else:
            # No authentication desired
            self.username = None
            return True
138621
def login(self):
        
        resp = super(CookieSession, self).request(
            'POST',
            self._session_url,
            data={'name': self._username, 'password': self._password},
        )
        resp.raise_for_status()
1111577
def login(self):
        """"""
        self._username = input("Username:")
        self._password = getpass.getpass("Password:")
        if self.get_auth_token():
            _LOGGER.debug("Login successful!")
            return True
        _LOGGER.warning("Unable to login with %s.", self._username)
        return False
544837
def is_following(self, login):
        
        json = False
        if login:
            url = self._build_url('user', 'following', login)
            json = self._boolean(self._get(url), 204, 404)
        return json
671637
def verify_aws_login(self):
        '''  '''
        if not self.mtc:
            return False

        try:
            self.mtc.get_account_balance()
        except Exception as exception:
            print exception
            return False
        else:
            return True
624666
def check_request(request, login_unsuccessful,
                  get_username=get_username_from_request,
                  username=None):
    
    ip_address = get_ip(request)
    username = username or get_username(request)

    if not login_unsuccessful:
        # user logged in -- forget the failed attempts
        reset_failed_attempts(ip_address=ip_address, username=username)
        return True
    else:
        # add a failed attempt for this user
        return record_failed_attempt(ip_address, username)
41755
def login(self):
		
		if self.options['token']:
			self.client.token = self.options['token']
			result = self.users.get_user('me')
		else:
			response = self.users.login_user({
				'login_id': self.options['login_id'],
				'password': self.options['password'],
				'token': self.options['mfa_token']
			})
			if response.status_code == 200:
				self.client.token = response.headers['Token']
				self.client.cookies = response.cookies
			try:
				result = response.json()
			except ValueError:
				log.debug('Could not convert response to json, returning raw response')
				result = response

		log.debug(result)

		if 'id' in result:
			self.client.userid = result['id']
		if 'username' in result:
			self.client.username = result['username']

		return result
406008
def authenticate(self, login, passcode):
        
        return login in self.store and self.store[login] == passcode
76148
def login(self, username, password, disableautosave=True, print_response=True):
        
        if type(username) != str:
            return False, "Username must be string"

        if type(password) != str:
            return False, "Password must be string"

        if type(disableautosave) != bool:
            return False, "Disableautosave must be boolean"

        data = {"username": username, "password": password, "disableautosave": disableautosave}

        status_response, response = self.call_api("r/user/login/", data, print_response=print_response)

        # Store httpcookie if possible
        if status_response and "deployr" in response:
            if "response" in response["deployr"]:
                if "httpcookie" in response["deployr"]["response"]:
                    self.JSESSIONID = response["deployr"]["response"]["httpcookie"]

        return status_response, response
126912
def follow(self, login):
        
        resp = False
        if login:
            url = self._build_url('user', 'following', login)
            resp = self._boolean(self._put(url), 204, 404)
        return resp
1293989
def login_failures(user):

    '''
    
    '''

    cmd = 'lsuser -a unsuccessful_login_count {0}'.format(user)
    cmd += " | grep -E 'unsuccessful_login_count=([3-9]|[0-9][0-9]+)'"
    out = __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=True)

    ret = []

    lines = out['stdout'].splitlines()
    for line in lines:
        ret.append(line.split()[0])

    return ret
1107931
def login(self):
        """"""
        if self.__logged_in:
            return
        login = {'userId': self.__username, 'userPassword': self.__password}
        header = BASE_HEADERS.copy()
        request = requests.post(BASE_URL + 'login',
                                data=login,
                                headers=header,
                                timeout=10)

        try:
            result = request.json()
        except ValueError as error:
            raise Exception(
                "Not a valid result for login, " +
                "protocol error: " + request.status_code + ' - ' +
                request.reason + "(" + str(error) + ")")

        if 'error' in result.keys():
            raise Exception("Could not login: " + result['error'])

        if request.status_code != 200:
            raise Exception(
                "Could not login, HTTP code: " +
                str(request.status_code) + ' - ' + request.reason)

        if 'success' not in result.keys() or not result['success']:
            raise Exception("Could not login, no success")

        cookie = request.headers.get("set-cookie")
        if cookie is None:
            raise Exception("Could not login, no cookie set")

        self.__cookie = cookie
        self.__logged_in = True
        return self.__logged_in
545886
def _login(self):
        
        headers = {
            "Content-Type": "application/x-www-form-urlencoded",
            "Accept": "application/json"
        }

        url = self.api_base_url + "account/directlogin"

        data = {'Email': self.username,
                'Password': self.password,
                'RememberMe': 'True'}

        response = requests.post(url, data=data, headers=headers, timeout=10)

        if response.status_code != 200:
            return False

        self.login_data = response.json()
        if not self.login_data['isSuccess']:
            self.login_data = None
            return False

        if ('token' in self.login_data
                and 'accessToken' in self.login_data['token']):
            self.home_id = self.login_data['token']['currentHomeId']
            self.user_id = self.login_data['token']['userId']
            return True

        self.login_data = None
        return False