Check if host and login is allowed to change the password, false = not allowed, true = not allowed
514359
private function check_host_login_exceptions()
    {
        $rcmail = rcmail::get_instance();

        // Host exceptions
        $hosts = $rcmail->config->get('password_hosts');
        if (!empty($hosts) && !in_array($_SESSION['storage_host'], (array) $hosts)) {
            return false;
        }

        // Login exceptions
        if ($exceptions = $rcmail->config->get('password_login_exceptions')) {
            $exceptions = array_map('trim', (array) $exceptions);
            $exceptions = array_filter($exceptions);
            $username   = $_SESSION['username'];

            foreach ($exceptions as $ec) {
                if ($username === $ec) {
                    return false;
                }
            }
        }

        return true;
    }
1224869
def check_user(user, password):
    """"""
    return ((user == attowiki.user or attowiki.user is None) and
            (password == attowiki.password or attowiki.password is None))
1068167
def is_ssh_available(host, port=22):
    
    s = socket.socket()
    try:
        s.connect((host, port))
        return True
    except:
        return False
519550
private function checkIfAdminExists(): void
    {
        $adminExists = $this->userService->getRepository()->findOneBy(['email' => $this->email]);

        if (!is_null($adminExists)) {

            $this->checkIfHaveSuperAdminRole($adminExists);

            $this->info('Admin account already exists!');

            if ($this->confirm('Do you want to change its password? [y|N]')) {
                $this->changePassword($adminExists);
            }

            exit;
        }
    }
597780
def change_password():
    
    basic_auth = '%s:%s' % (DEFAULT_USERNAME, DEFAULT_PASSWORD)
    try:  # Python 2
        auth = base64.encodestring(basic_auth)
    except TypeError:  # Python 3
        auth = base64.encodestring(bytes(basic_auth, 'utf-8')).decode()

    headers = {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": "Basic %s" % auth.strip()
    }
    
    response = None
    retry = 0
    while not response:  # Retry if the server is not ready yet
        sleep(1)
        con = http.HTTPConnection('localhost:7474', timeout=10)
        try:
            con.request('GET', 'http://localhost:7474/user/neo4j', headers=headers)
            response = json.loads(con.getresponse().read().decode('utf-8'))
        except ValueError:
            con.close()
        retry += 1
        if retry > 10:
            print("Could not change password for user neo4j")
            break
    if response and response.get('password_change_required', None):
        payload = json.dumps({'password': 'testing'})
        con.request('POST', 'http://localhost:7474/user/neo4j/password', payload, headers)
        print("Password changed for user neo4j")
    con.close()
936296
function cmd_change_password(args, done) {
    var seneca = this
    var user = args.user

    seneca.act(
      {
        role: role,
        cmd: 'encrypt_password',
        whence: 'change/user=' + user.id + ',' + user.nick,
        password: args.password,
        repeat: args.repeat,
        salt: args.salt
      },
      function(err, out) {
        if (err) {
          return done(err)
        }
        if (!out.ok) {
          return done(null, out)
        }

        user.failedLoginCount = 0
        user.salt = out.salt
        user.pass = out.pass
        user.save$(function(err, user) {
          if (err) {
            return done(err)
          }

          user = user.data$(false)
          done(null, { ok: true, user: user })
        })
      }
    )
  }
324215
def login(self, login, password, set_auth=False):
        
        rv = self.session.post(
            self.host,
            dumps({
                "method": "common.db.login",
                "params": [login, password]
            }),
        )
        rv = loads(rv.content)['result']
        if set_auth:
            self.set_auth(
                SessionAuth(login, *rv)
            )
        return rv
647784
def change_db_user_password(username, password):
    """"""

    sql = "ALTER USER %s WITH PASSWORD '%s'" % (username, password)
    excute_query(sql, use_sudo=True)
644249
def check_basic_auth(user, passwd):
    """"""

    auth = request.authorization
    return auth and auth.username == user and auth.password == passwd
306269
def set_password(self, password):
        
        self.password = password
        self.changed_event.emit(self)
408878
def change_ssh_port():
    
    host = normalize(env.host_string)[1]

    after = env.port
    before = str(env.DEFAULT_SSH_PORT)
    

    host_string=join_host_strings(env.user,host,before)
    with settings(host_string=host_string, user=env.user):
        if env.verbosity:
            print env.host, "CHANGING SSH PORT TO: "+str(after)
        sed('/etc/ssh/sshd_config','Port '+ str(before),'Port '+str(after),use_sudo=True)
        if env.verbosity:
            print env.host, "RESTARTING SSH on",after

        sudo('/etc/init.d/ssh restart')
        return True
1110675
def set_user_password(name, passwd, **client_args):
    '''
    
    '''
    if not user_exists(name, **client_args):
        log.info('User \'%s\' does not exist', name)
        return False

    client = _client(**client_args)
    client.set_user_password(name, passwd)

    return True
1023659
public function changePassword()
    {
        if ($this->validate() && $this->new_password == $this->new_password_confirm && $this->new_password) {
            $this->user->setPassword($this->new_password);
            return $this->user->save(false);
        } else {
            return false;
        }
    }
64957
def set_password(query, password, send_email):
    
    user = _query_to_user(query)
    if click.confirm(f'Are you sure you want to change {user!r}\'s password?'):
        security_service.change_password(user, password, send_email=send_email)
        user_manager.save(user, commit=True)
        click.echo(f'Successfully updated password for {user!r}')
    else:
        click.echo('Cancelled.')
132592
final protected function _canChangePassword() {
         //validate that required indices exist
        if (!isset($this->_userProfile['username'])
            || !isset($this->_userProfile['password'])
            || !isset($this->_userProfile['fullname'])
            || !isset($this->_userProfile['passhist'])
        ) {
            throw new UserCredentialException('The username and password are not set', 1016);
        }
  
        //Verify if the password was changed today or server has been futuredated
        $currDateTimeObj = new \DateTime();
        
        //Password was changed today or in the future
        if ($currDateTimeObj <= $this->_userProfile['policyinfo']['password_last_changed_datetime']) {
            return false;
        } else {
            return true;
        }
    }
761462
def check_credentials(self, username, password):
        
        return password is not None and self.credentials.get(username, None) == password
42940
def set_authorization_password(self, password):
        
        self.authorization_password = password
        self.changed_event.emit(self)