mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.2' into 4
This commit is contained in:
commit
83e461abbf
@ -325,7 +325,7 @@ en:
|
||||
LOGOUT: 'Log out'
|
||||
LOSTPASSWORDHEADER: 'Lost Password'
|
||||
NOTEPAGESECURED: 'That page is secured. Enter your credentials below and we will send you right along.'
|
||||
NOTERESETLINKINVALID: '<p>The password reset link is invalid or expired.</p><p>You can request a new one <a href="{link1}">here</a> or change your password after you <a href="{link2}">logged in</a>.</p>'
|
||||
NOTERESETLINKINVALID: '<p>The password reset link is invalid or expired.</p><p>You can request a new one <a href="{link1}">here</a> or change your password after you <a href="{link2}">log in</a>.</p>'
|
||||
NOTERESETPASSWORD: 'Enter your e-mail address and we will send you a link with which you can reset your password'
|
||||
PASSWORDRESETSENTHEADER: 'Password reset link sent'
|
||||
PASSWORDRESETSENTTEXT: 'Thank you. A reset link has been sent, provided an account exists for this email address.'
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
namespace SilverStripe\Control;
|
||||
|
||||
use SilverStripe\Core\Environment;
|
||||
|
||||
/**
|
||||
* CLI specific request building logic
|
||||
*/
|
||||
@ -66,4 +68,19 @@ class CLIRequestBuilder extends HTTPRequestBuilder
|
||||
// Parse rest of variables as standard
|
||||
return parent::cleanEnvironment($variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $variables
|
||||
* @param string $input
|
||||
* @return HTTPRequest
|
||||
*/
|
||||
public static function createFromVariables(array $variables, $input, $url = null)
|
||||
{
|
||||
$request = parent::createFromVariables($variables, $input, $url);
|
||||
// unset scheme so that SS_BASE_URL can provide `is_https` information if required
|
||||
$scheme = parse_url(Environment::getEnv('SS_BASE_URL'), PHP_URL_SCHEME);
|
||||
$request->setScheme($scheme);
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
|
@ -790,6 +790,9 @@ class Email extends ViewableData
|
||||
return $this;
|
||||
}
|
||||
|
||||
// Do not interfere with emails styles
|
||||
Requirements::clear();
|
||||
|
||||
// Render plain part
|
||||
if ($plainTemplate && !$plainPart) {
|
||||
$plainPart = $this->renderWith($plainTemplate, $this->getData());
|
||||
@ -806,6 +809,9 @@ class Email extends ViewableData
|
||||
$htmlPartObject = DBField::create_field('HTMLFragment', $htmlPart);
|
||||
$plainPart = $htmlPartObject->Plain();
|
||||
}
|
||||
|
||||
// Rendering is finished
|
||||
Requirements::restore();
|
||||
|
||||
// Fail if no email to send
|
||||
if (!$plainPart && !$htmlPart) {
|
||||
|
@ -245,7 +245,7 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
|
||||
} else {
|
||||
// First page button
|
||||
$firstPage = new GridField_FormAction($gridField, 'pagination_first', 'First', 'paginate', 1);
|
||||
$firstPage->addExtraClass('btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-left ss-gridfield-firstpage');
|
||||
$firstPage->addExtraClass('btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-left ss-gridfield-pagination-action ss-gridfield-firstpage');
|
||||
if ($state->currentPage == 1) {
|
||||
$firstPage = $firstPage->performDisabledTransformation();
|
||||
}
|
||||
@ -259,7 +259,7 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
|
||||
'paginate',
|
||||
$previousPageNum
|
||||
);
|
||||
$previousPage->addExtraClass('btn btn-secondary btn--hide-text btn-sm font-icon-angle-left ss-gridfield-previouspage');
|
||||
$previousPage->addExtraClass('btn btn-secondary btn--hide-text btn-sm font-icon-angle-left ss-gridfield-pagination-action ss-gridfield-previouspage');
|
||||
if ($state->currentPage == 1) {
|
||||
$previousPage = $previousPage->performDisabledTransformation();
|
||||
}
|
||||
@ -273,14 +273,14 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
|
||||
'paginate',
|
||||
$nextPageNum
|
||||
);
|
||||
$nextPage->addExtraClass('btn btn-secondary btn--hide-text btn-sm font-icon-angle-right ss-gridfield-nextpage');
|
||||
$nextPage->addExtraClass('btn btn-secondary btn--hide-text btn-sm font-icon-angle-right ss-gridfield-pagination-action ss-gridfield-nextpage');
|
||||
if ($state->currentPage == $totalPages) {
|
||||
$nextPage = $nextPage->performDisabledTransformation();
|
||||
}
|
||||
|
||||
// Last page button
|
||||
$lastPage = new GridField_FormAction($gridField, 'pagination_last', 'Last', 'paginate', $totalPages);
|
||||
$lastPage->addExtraClass('btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-right ss-gridfield-lastpage');
|
||||
$lastPage->addExtraClass('btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-right ss-gridfield-pagination-action ss-gridfield-lastpage');
|
||||
if ($state->currentPage == $totalPages) {
|
||||
$lastPage = $lastPage->performDisabledTransformation();
|
||||
}
|
||||
|
@ -227,10 +227,6 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr
|
||||
foreach ($printColumns as $field => $label) {
|
||||
$value = $gridField->getDataFieldValue($item, $field);
|
||||
|
||||
if ($item->escapeTypeForField($field) != 'xml') {
|
||||
$value = Convert::raw2xml($value);
|
||||
}
|
||||
|
||||
$itemRow->push(new ArrayData(array(
|
||||
"CellString" => $value,
|
||||
)));
|
||||
|
@ -74,7 +74,7 @@ class ChangePasswordHandler extends RequestHandler
|
||||
}
|
||||
$token = $request->getVar('t');
|
||||
|
||||
// Check whether we are merely changin password, or resetting.
|
||||
// Check whether we are merely changing password, or resetting.
|
||||
if ($token !== null && $member && $member->validateAutoLoginToken($token)) {
|
||||
$this->setSessionToken($member, $token);
|
||||
|
||||
@ -122,10 +122,10 @@ class ChangePasswordHandler extends RequestHandler
|
||||
'SilverStripe\\Security\\Security.NOTERESETLINKINVALID',
|
||||
'<p>The password reset link is invalid or expired.</p>'
|
||||
. '<p>You can request a new one <a href="{link1}">here</a> or change your password after'
|
||||
. ' you <a href="{link2}">logged in</a>.</p>',
|
||||
. ' you <a href="{link2}">log in</a>.</p>',
|
||||
[
|
||||
'link1' => $this->Link('lostpassword'),
|
||||
'link2' => $this->Link('login')
|
||||
'link1' => Security::lost_password_url(),
|
||||
'link2' => Security::login_url(),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
@ -577,8 +577,8 @@ class Security extends Controller implements TemplateGlobalProvider
|
||||
$holderPage->ID = -1 * random_int(1, 10000000);
|
||||
|
||||
$controller = ModelAsController::controller_for($holderPage);
|
||||
$controller->doInit();
|
||||
$controller->setRequest($this->getRequest());
|
||||
$controller->doInit();
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Security\Tests\MemberAuthenticator;
|
||||
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\Session;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\MemberAuthenticator\ChangePasswordHandler;
|
||||
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
||||
use SilverStripe\Security\Security;
|
||||
|
||||
class ChangePasswordHandlerTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = 'ChangePasswordHandlerTest.yml';
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Config::modify()
|
||||
->set(Security::class, 'login_url', 'Security/login')
|
||||
->set(Security::class, 'lost_password_url', 'Security/lostpassword');
|
||||
|
||||
$this->logOut();
|
||||
}
|
||||
|
||||
public function testExpiredOrInvalidTokenProvidesLostPasswordAndLoginLink()
|
||||
{
|
||||
$request = new HTTPRequest('GET', '/Security/changepassword', [
|
||||
'm' => $this->idFromFixture(Member::class, 'sarah'),
|
||||
't' => 'an-old-or-expired-hash',
|
||||
]);
|
||||
$request->setSession(new Session([]));
|
||||
|
||||
/** @var ChangePasswordHandler $handler */
|
||||
$handler = $this->getMockBuilder(ChangePasswordHandler::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(null)
|
||||
->getMock();
|
||||
|
||||
$result = $handler->setRequest($request)->changepassword();
|
||||
|
||||
$this->assertInternalType('array', $result, 'An array is returned');
|
||||
$this->assertContains('Security/lostpassword', $result['Content'], 'Lost password URL is included');
|
||||
$this->assertContains('Security/login', $result['Content'], 'Login URL is included');
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
SilverStripe\Security\Member:
|
||||
sarah:
|
||||
FirstName: Sarah
|
||||
Surname: Smith
|
||||
AutoLoginToken: foobar
|
Loading…
Reference in New Issue
Block a user