We need to overwrite the global "alternate login url" setting if wayf is enabled.

@param string $data Form data.
@return string Empty when no errors.
765577
public function write_setting($data) {
        global $CFG;

        // Overwrite alternative login URL if integrated WAYF is used.
        if (isset($data) && $data == 'on') {
            set_config('alt_login', $data, 'auth_shibboleth');
            set_config('alternateloginurl', $CFG->wwwroot.'/auth/shibboleth/login.php');
        } else {
            // Check if integrated WAYF was enabled and is now turned off.
            // If it was and only then, reset the Moodle alternate URL.
            $oldsetting = get_config('auth_shibboleth', 'alt_login');
            if (isset($oldsetting) and $oldsetting == 'on') {
                set_config('alt_login', 'off', 'auth_shibboleth');
                set_config('alternateloginurl', '');
            }
            $data = 'off';
        }
        return parent::write_setting($data);
    }
442004
public function update($data)
    {
        $uID = (int) $this->getUserID();
        if ($uID === 0) {
            $result = false;
        } else {
            $result = true;
            $emailChanged = false;
            $passwordChangedOn = null;
            $fields = [];
            $values = [];
            if (isset($data['uName'])) {
                $fields[] = 'uName = ?';
                $values[] = $data['uName'];
            }
            if (isset($data['uEmail']) && $data['uEmail'] !== $this->getUserEmail()) {
                $emailChanged = true;
                $fields[] = 'uEmail = ?';
                $values[] = $data['uEmail'];
            }
            if (isset($data['uHasAvatar'])) {
                $fields[] = 'uHasAvatar = ?';
                $values[] = $data['uHasAvatar'] ? 1 : 0;
            }
            if (isset($data['uTimezone'])) {
                $fields[] = 'uTimezone = ?';
                $values[] = $data['uTimezone'];
            }
            if (isset($data['uDefaultLanguage'])) {
                $fields[] = 'uDefaultLanguage = ?';
                $values[] = $data['uDefaultLanguage'];
            }
            if (isset($data['uPassword']) && (string) $data['uPassword'] !== '') {
                if (isset($data['uPasswordConfirm']) && $data['uPassword'] === $data['uPasswordConfirm']) {
                    $passwordChangedOn = $this->application->make('date')->getOverridableNow();
                    $fields[] = 'uPassword = ?';
                    $values[] = $this->getUserObject()->getUserPasswordHasher()->HashPassword($data['uPassword']);
                    $fields[] = 'uLastPasswordChange = ?';
                    $values[] = $passwordChangedOn;
                    if (isset($data['uIsPasswordReset'])) {
                        $fields[] = 'uIsPasswordReset = ?';
                        $values[] = $data['uIsPasswordReset'] ? 1 : 0;
                    }
                } else {
                    $result = null;
                }
            }
            if ($result === true && !empty($fields)) {
                $this->connection->executeQuery(
                    'update Users set  ' . implode(', ', $fields) . 'where uID = ? limit 1',
                    array_merge($values, [$uID])
                );
                if ($emailChanged) {
                    $this->connection->executeQuery('DELETE FROM UserValidationHashes WHERE uID = ?', [$uID]);
                    $h = $this->application->make('helper/validation/identifier');
                    $h->deleteKey('UserValidationHashes', 'uID', $uID);
                }
                // now we check to see if the user is updated his or her own logged in record
                $session = $this->application->make('session');
                if ($session->has('uID') && $uID === (int) $session->get('uID')) {
                    if (isset($data['uName'])) {
                        $session->set('uName', $data['uName']);
                    }
                    if (isset($data['uTimezone'])) {
                        $session->set('uTimezone', $data['uTimezone']);
                    }
                    if (isset($data['uDefaultLanguage'])) {
                        $session->set('uDefaultLanguage', $data['uDefaultLanguage']);
                    }
                    if ($passwordChangedOn !== null) {
                        $session->set('uLastPasswordChange', $passwordChangedOn);
                    }
                }
                // run any internal event we have for user update
                $ue = new UserInfoEvent($this);
                $this->getDirector()->dispatch('on_user_update', $ue);
                if ($passwordChangedOn !== null) {
                    $ue = new UserInfoWithPasswordEvent($this);
                    $ue->setUserPassword($data['uPassword']);
                    $this->getDirector()->dispatch('on_user_change_password', $ue);
                }
            }
        }

        return $result;
    }
702401
protected function handleResult($data)
    {
        if (empty($data->data)) {
            $data->data = new stdClass();
        }
        if ($data->http_code !== 200) {
            $data->data->is_error = true;
            $data->data->http_code = $data->http_code;
        }

        return $data->data;
    }
573743
public function lostPassword($data) {
        $response=CodeBank_ClientAPI::responseBase();
        $response['login']=true;
        
        
		$SQL_email=Convert::raw2sql($data->user);
		$member=Member::get_one('Member', "\"Email\"='{$SQL_email}'");

		// Allow vetoing forgot password requests
		$sng=new MemberLoginForm(Controller::has_curr() ? Controller::curr():singleton('Controller'), 'LoginForm');
		$results=$sng->extend('forgotPassword', $member);
		if($results && is_array($results) && in_array(false, $results, true)) {
		    $response['status']='HELO';
			$response['message']=_t('CodeBankAPI.PASSWORD_SENT_TEXT', "A reset link has been sent to '{email}', provided an account exists for this email address.", array('email'=>$data['Email']));
		}

		if($member) {
			$token=$member->generateAutologinTokenAndStoreHash();

			$e=Member_ForgotPasswordEmail::create();
			$e->populateTemplate($member);
			$e->populateTemplate(array(
				'PasswordResetLink'=>Security::getPasswordResetLink($member, $token)
			));
			$e->setTo($member->Email);
			$e->send();

			$response['status']='HELO';
			$response['message']=_t('CodeBankAPI.PASSWORD_SENT_TEXT', "A reset link has been sent to '{email}', provided an account exists for this email address.", array('email'=>$data->user));
		}else if(!empty($data->user)) {
			$response['status']='HELO';
			$response['message']=_t('CodeBankAPI.PASSWORD_SENT_TEXT', "A reset link has been sent to '{email}', provided an account exists for this email address.", array('email'=>$data->user));
		}else {
			$response['status']='EROR';
			$response['message']=_t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.');
		}
		
		
		return $response;
    }
160374
public function encode($data)
    {
        if ($data !== null) {
            $data = gzencode((string) $data, $this->options['level'], $this->options['mode']);
            if ($data === false) {
                $data = null;
                $this->error = error_get_last()['message'] ?? 'Unknown';
            }
        }

        return $data;
    }
934405
protected function _checkProvider($data)
    {
        $fields = $this->_config['fields'];

        if (empty($data[$fields['provider']])) {
            return false;
        }

        $provider = $data[$fields['provider']];

        if ($provider === 'OpenID' && empty($data[$fields['openid_identifier']])) {
            return false;
        }

        return $provider;
    }
655991
public function doReplace($data)
    {
        $data = preg_replace_callback(
            '/#([^\s\r#]+)#/',
            function ($matches) {
                if (defined($matches[1])) {
                    return constant($matches[1]);
                }

                return $matches[0];
            },
            $data
        );

        if (isset($this->values)) {
            $values = $this->values;

            $data = preg_replace_callback(
                '/%([^\s\r%]+)%/',
                function ($matches) use ($values) {
                    if (isset($values[$matches[1]])) {
                        return $values[$matches[1]];
                    }

                    return $matches[0];
                },
                $data
            );
        }

        return $data;
    }
583750
private function getQSEncode($data)
    {
        $req = null;
        foreach ($data as $key => $value) {
            $req .= $key . '=' . urlencode(stripslashes($value)) . '&';
        }

        // cut the last '&'
        $req = substr($req, 0, strlen($req) - 1);

        return $req;
    }
1365363
protected function preSetHook(&$data)
    {
        // check if we are trying to edit any protected fields,
        // i.e. password or email address, that require the current
        // password to be changed
        $passwordRequired = false;

        foreach ($data as $key => $value) {
            if (static::hasProperty($key)) {
                if (in_array($key, static::$protectedFields)) {
                    // protected fields, i.e. passwords, are not allowed
                    // to be set to empty values
                    if (strlen(implode((array) $value)) == 0) {
                        unset($data[$key]);
                        continue;
                    }

                    $passwordRequired = true;
                }

                $data[$key] = $value;
            }
        }

        // verify the given current password, when required
        $auth = $this->getApp()['auth'];
        if ($passwordRequired && !$this->can('skip-password-required', $auth->getCurrentUser())) {
            $password = array_value($data, 'current_password');
            $strategy = $auth->getStrategy('traditional');
            if (!$strategy->verifyPassword($this, $password)) {
                $this->getErrors()->add('invalid_password');

                return false;
            }
        }

        $this->_changedPassword = isset($data['password']) && !$this->isTemporary();

        return true;
    }
729115
public function login($data) {
        $username = $data[$this->username];
        $password = $data[$this->password];
        $autoLogin = isset($data['auto_login']) ? $data['auto_login'] : !$this->requirePrompt;

        if ($username && $password && $autoLogin) {
            $this->write($username, $password);

        } else if (!$autoLogin) {
            $this->delete();
        }
    }
1342866
protected function renderLogin(array $data): Response
	{
		$securityContext = $this->container->get('security.authorization_checker');
		
		if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') || $securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
			$this->addFlash("info-flash", "You were connected with success");
			
			return new RedirectResponse($this->generateUrl("ribsadmin_index"), 303);
		}
		
		return $this->render("@RibsAdmin/login/login.html.twig", $data);
	}
112309
public function reverseTransform($data)
    {
        $value = parent::reverseTransform($data);

        return ! is_null($value) ? (int) $value : null;
    }
355980
public function write_setting($data) {
        global $CFG;

        $login = get_config('auth_shibboleth', 'alt_login');
        if (isset($data) && !empty($data) && isset($login) && $login == 'on') {

            // Need to use the get_idp_list() function here.
            require_once($CFG->dirroot.'/auth/shibboleth/auth.php');

            $idplist = get_idp_list($data);
            if (count($idplist) < 1) {
                return false;
            }
            $data = '';
            foreach ($idplist as $idp => $value) {
                $data .= $idp.', '.$value[0];
                if (isset($value[1])) {
                    // Value[1] is optional.
                    $data .= ', '.$value[1] . "\n";
                } else {
                    $data .= "\n";
                }
            }
        }
        return parent::write_setting($data);
    }
11303
public function extractUrlAliasFromData($data)
    {
        $urlAlias = new UrlAlias();

        list($type, $destination) = $this->matchTypeAndDestination($data['action']);
        $urlAlias->id = $data['parent'] . '-' . $data['text_md5'];
        $urlAlias->pathData = $this->normalizePathData($data['raw_path_data']);
        $urlAlias->languageCodes = $this->languageMaskGenerator->extractLanguageCodesFromMask($data['lang_mask']);
        $urlAlias->alwaysAvailable = $this->languageMaskGenerator->isAlwaysAvailable($data['lang_mask']);
        $urlAlias->isHistory = isset($data['is_path_history']) ? $data['is_path_history'] : !$data['is_original'];
        $urlAlias->isCustom = (bool)$data['is_alias'];
        $urlAlias->forward = $data['is_alias'] && $data['alias_redirects'];
        $urlAlias->destination = $destination;
        $urlAlias->type = $type;

        return $urlAlias;
    }
1086059
protected function invalidPayload($data)
    {
        return ! is_array($data) || ! isset($data['iv']) || ! isset($data['value']) || ! isset($data['mac']);
    }
433012
protected static function getUrlSafeData($data)
    {
        $remainder = strlen($data) % 4;

        if ($remainder) {
            $data .= str_repeat('=', 4 - $remainder);
        }

        return strtr($data, '-_', '+/');
    }
789653
public function doLogin($data, MemberLoginForm $form, HTTPRequest $request)
    {
        $failureMessage = null;

        $this->extend('beforeLogin');
        // Successful login
        /** @var ValidationResult $result */
        if ($member = $this->checkLogin($data, $request, $result)) {
            $this->performLogin($member, $data, $request);
            // Allow operations on the member after successful login
            $this->extend('afterLogin', $member);

            return $this->redirectAfterSuccessfulLogin();
        }

        $this->extend('failedLogin');

        $message = implode("; ", array_map(
            function ($message) {
                return $message['message'];
            },
            $result->getMessages()
        ));

        $form->sessionMessage($message, 'bad');

        // Failed login

        /** @skipUpgrade */
        if (array_key_exists('Email', $data)) {
            $rememberMe = (isset($data['Remember']) && Security::config()->get('autologin_enabled') === true);
            $this
                ->getRequest()
                ->getSession()
                ->set('SessionForms.MemberLoginForm.Email', $data['Email'])
                ->set('SessionForms.MemberLoginForm.Remember', $rememberMe);
        }

        // Fail to login redirects back to form
        return $form->getRequestHandler()->redirectBackToForm();
    }