本文整理汇总了PHP中Member::config方法的典型用法代码示例。如果您正苦于以下问题:PHP Member::config方法的具体用法?PHP Member::config怎么用?PHP Member::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Member
的用法示例。
在下文中一共展示了Member::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
parent::tearDown();
BasicAuth::protect_entire_site(false);
Member::config()->unique_identifier_field = self::$original_unique_identifier_field;
Security::$force_database_is_ready = null;
}
示例2: onAfterInit
/**
* If the REMOTE_USER is set and is in the Member table, log that member in. If
* not, and Config::inst()->get('AuthRemoteUserExtension', 'auto_create_user') is set, add that
* Member to the configured group, and log the new user in. Otherwise, do nothing.
*/
public function onAfterInit()
{
if (isset($_SERVER['REMOTE_USER'])) {
$unique_identifier = $_SERVER['REMOTE_USER'];
} elseif (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
$unique_identifier = $_SERVER['REDIRECT_REMOTE_USER'];
}
if (isset($unique_identifier)) {
$unique_identifier_field = Member::config()->unique_identifier_field;
$member = Member::get()->filter($unique_identifier_field, $unique_identifier)->first();
if ($member) {
$member->logIn();
$this->owner->redirectBack();
} elseif (Config::inst()->get('AuthRemoteUserExtension', 'auto_create_user') && strlen(Config::inst()->get('AuthRemoteUserExtension', 'auto_user_group'))) {
$group = Group::get()->filter('Title', Config::inst()->get('AuthRemoteUserExtension', 'auto_user_group'))->first();
if ($group) {
$member = new Member();
$member->{$unique_identifier_field} = $unique_identifier;
$member->write();
$member->Groups()->add($group);
$member->logIn();
}
}
}
}
开发者ID:helpfulrobot,项目名称:quinninteractive-silverstripe-auth-remote-user,代码行数:30,代码来源:AuthRemoteUserExtension.php
示例3: __construct
/**
* EmailVerificationLoginForm is the same as MemberLoginForm with the following changes:
* - The code has been cleaned up.
* - A form action for users who have lost their verification email has been added.
*
* We add fields in the constructor so the form is generated when instantiated.
*
* @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
* @param string $name The method on the controller that will return this form object.
* @param FieldList|FormField $fields All of the fields in the form - a {@link FieldList} of {@link FormField} objects.
* @param FieldList|FormAction $actions All of the action buttons in the form - a {@link FieldList} of {@link FormAction} objects
* @param bool $checkCurrentUser If set to TRUE, it will be checked if a the user is currently logged in, and if so, only a logout button will be rendered
*/
function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
{
$email_field_label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
$email_field = TextField::create('Email', $email_field_label, null, null, $this)->setAttribute('autofocus', 'autofocus');
$password_field = PasswordField::create('Password', _t('Member.PASSWORD', 'Password'));
$authentication_method_field = HiddenField::create('AuthenticationMethod', null, $this->authenticator_class, $this);
$remember_me_field = CheckboxField::create('Remember', 'Remember me next time?', true);
if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
$fields = FieldList::create($authentication_method_field);
$actions = FieldList::create(FormAction::create('logout', _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
} else {
if (!$fields) {
$fields = FieldList::create($authentication_method_field, $email_field, $password_field);
if (Security::config()->remember_username) {
$email_field->setValue(Session::get('SessionForms.MemberLoginForm.Email'));
} else {
// Some browsers won't respect this attribute unless it's added to the form
$this->setAttribute('autocomplete', 'off');
$email_field->setAttribute('autocomplete', 'off');
}
}
if (!$actions) {
$actions = FieldList::create(FormAction::create('doLogin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField('forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'), new LiteralField('resendEmail', '<p id="ResendEmail"><a href="Security/verify-email">' . _t('MemberEmailVerification.BUTTONLOSTVERIFICATIONEMAIL', "I've lost my verification email") . '</a></p>'));
}
}
if (isset($_REQUEST['BackURL'])) {
$fields->push(HiddenField::create('BackURL', 'BackURL', $_REQUEST['BackURL']));
}
// Reduce attack surface by enforcing POST requests
$this->setFormMethod('POST', true);
parent::__construct($controller, $name, $fields, $actions);
$this->setValidator(RequiredFields::create('Email', 'Password'));
}
开发者ID:jordanmkoncz,项目名称:silverstripe-memberemailverification,代码行数:46,代码来源:EmailVerificationLoginForm.php
示例4: setUp
public function setUp()
{
parent::setUp();
// Fixtures assume Email is the field used to identify the log in identity
Member::config()->unique_identifier_field = 'Email';
Member::config()->lock_out_after_incorrect_logins = 10;
}
示例5: memberLoggedOut
/**
* Clear the cart, and session variables on member logout
*/
public function memberLoggedOut()
{
if (Member::config()->login_joins_cart) {
ShoppingCart::singleton()->clear();
OrderManipulation::clear_session_order_ids();
}
}
示例6: authenticate_member
/**
* Attempt to find and authenticate member if possible from the given data.
*
* @param array $data
* @param Form $form
* @param bool &$success Success flag
* @return Member Found member, regardless of successful login
* @see MemberAuthenticator::authenticate_member()
*/
protected static function authenticate_member($data, $form, &$success)
{
// Default success to false
$success = false;
// Attempt to identify by temporary ID
$member = null;
$email = null;
if (!empty($data['tempid'])) {
// Find user by tempid, in case they are re-validating an existing session
$member = Member::member_from_tempid($data['tempid']);
if ($member) {
$email = $member->Email;
}
}
// Otherwise, get email from posted value instead
if (!$member && !empty($data['Email'])) {
$email = $data['Email'];
}
// Check default login (see Security::setDefaultAdmin()) the standard way and the "extension"-way :-)
$asDefaultAdmin = $email === Security::default_admin_username();
if ($asDefaultAdmin || isset($GLOBALS['_DEFAULT_ADMINS']) && array_key_exists($email, $GLOBALS['_DEFAULT_ADMINS'])) {
// If logging is as default admin, ensure record is setup correctly
$member = Member::default_admin();
$success = Security::check_default_admin($email, $data['Password']);
// If not already true check if one of the extra admins match
if (!$success) {
$success = $GLOBALS['_DEFAULT_ADMINS'][$email] == $data['Password'];
}
if ($success) {
return $member;
}
}
// Attempt to identify user by email
if (!$member && $email) {
// Find user by email
$member = Member::get()->filter(Member::config()->unique_identifier_field, $email)->first();
}
// Validate against member if possible
if ($member && !$asDefaultAdmin) {
$result = $member->checkPassword($data['Password']);
$success = $result->valid();
} else {
$result = new ValidationResult(false, _t('Member.ERRORWRONGCRED'));
}
// Emit failure to member and form (if available)
if (!$success) {
if ($member) {
$member->registerFailedLogin();
}
if ($form) {
$form->sessionMessage($result->message(), 'bad');
}
} else {
if ($member) {
$member->registerSuccessfulLogin();
}
}
return $member;
}
示例7: testCustomIdentifierField
public function testCustomIdentifierField()
{
$origField = Member::config()->unique_identifier_field;
Member::config()->unique_identifier_field = 'Username';
$label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
$this->assertEquals($label, 'Username');
Member::config()->unique_identifier_field = $origField;
}
示例8: tearDown
public function tearDown()
{
parent::tearDown();
// set old Member::config()->unique_identifier_field value
if ($this->member_unique_identifier_field) {
Member::config()->unique_identifier_field = $this->member_unique_identifier_field;
}
}
示例9: setUp
public function setUp()
{
parent::setUp();
// Fixtures assume Email is the field used to identify the log in identity
Member::config()->unique_identifier_field = 'Email';
Security::$force_database_is_ready = true;
// Prevents Member test subclasses breaking ready test
Member::config()->lock_out_after_incorrect_logins = 10;
}
示例10: getData
public function getData(Order $order)
{
$data = array();
if ($member = Member::currentUser()) {
$idf = Member::config()->unique_identifier_field;
$data[$idf] = $member->{$idf};
}
return $data;
}
示例11: VerifyEmailForm
/**
* Factory method for the Verify Email form.
*
* @return Form
*/
public function VerifyEmailForm()
{
$email_field_label = singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
$email_field = TextField::create('Email', $email_field_label, null, null, $this)->setAttribute('autofocus', 'autofocus');
$fields = FieldList::create($email_field);
$actions = FieldList::create(FormAction::create('submitVerifyEmailForm', _t('MemberEmailVerification.BUTTONRESENDEMAIL', "Send me the email verification link again")));
$form = new EmailVerificationLoginForm($this->owner, 'submitVerifyEmailForm', $fields, $actions, false);
return $form;
}
开发者ID:jordanmkoncz,项目名称:silverstripe-memberemailverification,代码行数:14,代码来源:EmailVerificationSecurityExtension.php
示例12: acs
/**
* Assertion Consumer Service
*
* The user gets sent back here after authenticating with the IdP, off-site.
* The earlier redirection to the IdP can be found in the SAMLAuthenticator::authenticate.
*
* After this handler completes, we end up with a rudimentary Member record (which will be created on-the-fly
* if not existent), with the user already logged in. Login triggers memberLoggedIn hooks, which allows
* LDAP side of this module to finish off loading Member data.
*
* @throws OneLogin_Saml2_Error
*/
public function acs()
{
$auth = Injector::inst()->get('SAMLHelper')->getSAMLAuth();
$auth->processResponse();
$error = $auth->getLastErrorReason();
if (!empty($error)) {
SS_Log::log($error, SS_Log::ERR);
Form::messageForForm("SAMLLoginForm_LoginForm", "Authentication error: '{$error}'", 'bad');
Session::save();
return $this->getRedirect();
}
if (!$auth->isAuthenticated()) {
Form::messageForForm("SAMLLoginForm_LoginForm", _t('Member.ERRORWRONGCRED'), 'bad');
Session::save();
return $this->getRedirect();
}
$decodedNameId = base64_decode($auth->getNameId());
// check that the NameID is a binary string (which signals that it is a guid
if (ctype_print($decodedNameId)) {
Form::messageForForm("SAMLLoginForm_LoginForm", "Name ID provided by IdP is not a binary GUID.", 'bad');
Session::save();
return $this->getRedirect();
}
// transform the NameId to guid
$guid = LDAPUtil::bin_to_str_guid($decodedNameId);
if (!LDAPUtil::validGuid($guid)) {
$errorMessage = "Not a valid GUID '{$guid}' recieved from server.";
SS_Log::log($errorMessage, SS_Log::ERR);
Form::messageForForm("SAMLLoginForm_LoginForm", $errorMessage, 'bad');
Session::save();
return $this->getRedirect();
}
// Write a rudimentary member with basic fields on every login, so that we at least have something
// if LDAP synchronisation fails.
$member = Member::get()->filter('GUID', $guid)->limit(1)->first();
if (!($member && $member->exists())) {
$member = new Member();
$member->GUID = $guid;
}
$attributes = $auth->getAttributes();
foreach ($member->config()->claims_field_mappings as $claim => $field) {
if (!isset($attributes[$claim][0])) {
SS_Log::log(sprintf('Claim rule \'%s\' configured in LDAPMember.claims_field_mappings, but wasn\'t passed through. Please check IdP claim rules.', $claim), SS_Log::WARN);
continue;
}
$member->{$field} = $attributes[$claim][0];
}
$member->SAMLSessionIndex = $auth->getSessionIndex();
// This will throw an exception if there are two distinct GUIDs with the same email address.
// We are happy with a raw 500 here at this stage.
$member->write();
// This will trigger LDAP update through LDAPMemberExtension::memberLoggedIn.
// Both SAML and LDAP identify Members by the GUID field.
$member->logIn();
return $this->getRedirect();
}
示例13: updatedetails
public function updatedetails($data, $form)
{
$form->saveInto($this->member);
if (Member::config()->send_frontend_update_notifications) {
$this->sendUpdateNotification();
}
$this->member->write();
$form->sessionMessage("Your member details have been updated.", "good");
return $this->controller->redirectBack();
}
示例14: getEditForm
public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm();
if ($this->modelClass == "Member") {
if ($columns = Member::config()->export_fields) {
$form->Fields()->fieldByName("Member")->getConfig()->getComponentByType("GridFieldExportButton")->setExportColumns($columns);
}
}
return $form;
}
示例15: testLoginDoesntJoinCart
public function testLoginDoesntJoinCart()
{
Member::config()->login_joins_cart = false;
$order = $this->objFromFixture("Order", "cart");
ShoppingCart::singleton()->setCurrent($order);
$member = $this->objFromFixture("Member", "jeremyperemy");
$member->logIn();
$this->assertEquals(0, $order->MemberID);
$member->logOut();
$this->assertTrue((bool) ShoppingCart::curr());
}