Perform a re-login if not signed in or raise an exception
12564
def check_auth(self):
        """"""
        if not self.logged_in:
            if self.relogin_interval and self.last_login and (time() - self.last_login) > self.relogin_interval:
                self.log(WARNING, 'Zabbix API not logged in. Performing Zabbix API relogin after %d seconds',
                         self.relogin_interval)
                self.relogin()  # Will raise exception in case of login error
            else:
                raise ZabbixAPIException('Not logged in.')
1359908
def login(self, login, password):
        
        self.client.read_until('Username: ')
        self.client.write(login + '\r\n')
        self.client.read_until('Password: ')
        self.client.write(password + '\r\n')
        current_data = self.client.read_until('$ ', 10)
        if not current_data.endswith('$ '):
            raise InvalidLogin
428115
def try_replace_token(authenticate, **kwargs):
    

    try:
        return authenticate(**kwargs)
    except errors.BinstarError as err:
        if kwargs.get('fail_if_already_exists') and len(err.args) > 1 and err.args[1] == 400:
            logger.warning('It appears you are already logged in from host %s' % socket.gethostname())
            logger.warning('Logging in again will remove the previous token. (This could cause troubles with virtual '
                           'machines with the same hostname)')
            logger.warning('Otherwise you can login again and specify a different hostname with "--hostname"')

            if bool_input("Would you like to continue"):
                kwargs['fail_if_already_exists'] = False
                return authenticate(**kwargs)

        raise
432165
public function afterMemberLoggedIn()
    {
        if ($this->owner->GUID) {
            try {
                Injector::inst()->get(LDAPService::class)->updateMemberFromLDAP($this->owner);
            } catch (Exception $e) {
                // If the failure is acceptable, then ignore it and return. Otherwise, re-throw the exception
                if ($this->owner->config()->get('allow_update_failure_during_login')) {
                    return;
                }
                throw $e;
            }
        }
    }
1128519
def _reconnected(self):
        """"""

        if self._login_data or self._login_token:

            def reconnect_login_callback(error, result):
                if error:
                    if self._login_token:
                        self._login_token = None
                        self._login(self._login_data,
                                    callback=reconnect_login_callback)
                        return
                    else:
                        raise MeteorClientException(
                            'Failed to re-authenticate during reconnect')

                self.connected = True
                self._resubscribe()

            if self._login_token:
                self._resume(self._login_token,
                             callback=reconnect_login_callback)
            else:
                self._login(self._login_data,
                            callback=reconnect_login_callback)
        else:
            self._resubscribe()
1015479
private void attemptLogin() {
        if (mAuth != null) {
            return;
        }

        // Reset errors.
        mEmailView.setError(null);
        mPasswordView.setError(null);

        // Store values at the time of the login attempt.
        String email = mEmailView.getText().toString();
        String password = mPasswordView.getText().toString();

        boolean cancel = false;
        View focusView = null;


        // Check for a valid password, if the user entered one.
        if (TextUtils.isEmpty(password) || !isPasswordValid(password)) {
            mPasswordView.setError(getString(R.string.error_invalid_password));
            focusView = mPasswordView;
            cancel = true;
        }

        // Check for a valid email address.
        if (TextUtils.isEmpty(email)) {
            mEmailView.setError(getString(R.string.error_field_required));
            focusView = mEmailView;
            cancel = true;
        } else if (!isEmailValid(email)) {
            mEmailView.setError(getString(R.string.error_invalid_email));
            focusView = mEmailView;
            cancel = true;
        }

        if (cancel) {
            // There was an error; don't attempt login and focus the first
            // form field with an error.
            focusView.requestFocus();
        } else {
            // Show a progress spinner, and kick off a background task to
            // perform the user login attempt.
            showProgress(true);
            mAuth = BaasUser.withUserName(email)
                            .setPassword(password)
                            .login(loginHandler);

        }
    }
667523
def login(username, password):
    
    check_for_cloud_server()
    old_username = config["cloud_server"]["username"]
    if old_username and old_username != username:
        raise click.ClickException(
            "Already logged in as user \"{}\". Run `openag cloud user logout` "
            "before attempting to log in as a different user".format(
                old_username
            )
        )
    server = Server(config["cloud_server"]["url"])
    server.log_in(username, password)
    config["cloud_server"]["username"] = username
    config["cloud_server"]["password"] = password
1156212
def allow_password_change?
        if params[:old_password]
          unless @user.authenticate(params[:old_password])
            raise ApplicationController::UNAUTHORIZED_ERROR 
          end
        else
          unless @token == @user.reset_token
            raise ApplicationController::UNAUTHORIZED_ERROR
          end
        end
        return true
      end
928652
def _do_login_locked(self):
    """"""
    self._telnet = telnetlib.Telnet(self._host)
    self._telnet.read_until(LutronConnection.USER_PROMPT)
    self._telnet.write(self._user + b'\r\n')
    self._telnet.read_until(LutronConnection.PW_PROMPT)
    self._telnet.write(self._password + b'\r\n')
    self._telnet.read_until(LutronConnection.PROMPT)

    self._send_locked("#MONITORING,12,2")
    self._send_locked("#MONITORING,255,2")
    self._send_locked("#MONITORING,3,1")
    self._send_locked("#MONITORING,4,1")
    self._send_locked("#MONITORING,5,1")
    self._send_locked("#MONITORING,6,1")
    self._send_locked("#MONITORING,8,1")
858710
def login(self, username=None, password=None):
        """"""
        if username is not None:
            self._username = username
        if password is not None:
            self._password = password

        if self._username is None or not isinstance(self._username, str):
            raise SkybellAuthenticationException(ERROR.USERNAME)

        if self._password is None or not isinstance(self._password, str):
            raise SkybellAuthenticationException(ERROR.PASSWORD)

        self.update_cache(
            {
                CONST.ACCESS_TOKEN: None
            })

        login_data = {
            'username': self._username,
            'password': self._password,
            'appId': self.cache(CONST.APP_ID),
            CONST.TOKEN: self.cache(CONST.TOKEN)
        }

        try:
            response = self.send_request('post', CONST.LOGIN_URL,
                                         json_data=login_data, retry=False)
        except Exception as exc:
            raise SkybellAuthenticationException(ERROR.LOGIN_FAILED, exc)

        _LOGGER.debug("Login Response: %s", response.text)

        response_object = json.loads(response.text)

        self.update_cache({
            CONST.ACCESS_TOKEN: response_object[CONST.ACCESS_TOKEN]})

        _LOGGER.info("Login successful")

        return True
409380
def start_session(self):
        
        if self.has_active_session():
            raise Exception("Session already in progress.")

        response = requests.post(self._get_login_url(),
                                 headers=self._get_login_headers(),
                                 data=self._get_login_xml())
        response.raise_for_status()

        root = ET.fromstring(response.text)
        for e in root.iter("%ssessionId" % self.SOAP_NS):
            if self.session_id:
                raise Exception("Invalid login attempt.  Multiple session ids found.")
            self.session_id = e.text

        for e in root.iter("%sserverUrl" % self.SOAP_NS):
            if self.server_url:
                raise Exception("Invalid login attempt.  Multiple server urls found.")
            self.server_url = e.text

        if not self.has_active_session():
            raise Exception("Invalid login attempt resulted in null sessionId [%s] and/or serverUrl [%s]." %
                            (self.session_id, self.server_url))
        self.hostname = urlsplit(self.server_url).hostname
1006781
def login_required(self, fresh=False, redirect_to=None):
        
        if not self.logged_in() or (fresh and not self.login_manager.login_fresh()):
            if redirect_to:
                resp = redirect(redirect_to)
            else:
                resp = self.login_manager.unauthorized()
            current_context.exit(resp, trigger_action_group="missing_user")
817310
def session_login(self, user=None, passwd=None):
        
        self.change_credentials(user=user, auth_token=passwd)
1268724
def login(self, password):
        """"""

        if self.logged_in:
            raise RuntimeError("User already logged in!")

        params = {"name": self.nick, "password": password}
        resp = self.conn.make_api_call("login", params)
        if "error" in resp:
            raise RuntimeError(
                f"Login failed: {resp['error'].get('message') or resp['error']}"
            )
        self.session = resp["session"]
        self.conn.make_call("useSession", self.session)
        self.conn.cookies.update({"session": self.session})
        self.logged_in = True
        return True
125859
def login_required(function=None, message=None, login_url=None):
    
    actual_decorator = user_passes_test(
        lambda u: u.is_authenticated(),
        message=message,
        login_url=login_url
    )

    if function:
        return actual_decorator(function)
    return actual_decorator
908
def session_hook(exception):
    
    safeprint(
        "The resource you are trying to access requires you to "
        "re-authenticate with specific identities."
    )

    params = exception.raw_json["authorization_parameters"]
    message = params.get("session_message")
    if message:
        safeprint("message: {}".format(message))

    identities = params.get("session_required_identities")
    if identities:
        id_str = " ".join(identities)
        safeprint(
            "Please run\n\n"
            "    globus session update {}\n\n"
            "to re-authenticate with the required identities".format(id_str)
        )
    else:
        safeprint(
            'Please use "globus session update" to re-authenticate '
            "with specific identities".format(id_str)
        )

    exit_with_mapped_status(exception.http_status)
406008
def authenticate(self, login, passcode):
        
        return login in self.store and self.store[login] == passcode