mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2740 from micmania1/add-logout-url
NEW add logout url to Security
This commit is contained in:
commit
85b00105ce
@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cms-login-status">
|
<div class="cms-login-status">
|
||||||
<a href="Security/logout" class="logout-link" title="<% _t('LeftAndMain_Menu_ss.LOGOUT','Log out') %>"><% _t('LeftAndMain_Menu_ss.LOGOUT','Log out') %></a>
|
<a href="$LogoutURL" class="logout-link" title="<% _t('LeftAndMain_Menu_ss.LOGOUT','Log out') %>"><% _t('LeftAndMain_Menu_ss.LOGOUT','Log out') %></a>
|
||||||
<% with $CurrentMember %>
|
<% with $CurrentMember %>
|
||||||
<span>
|
<span>
|
||||||
<% _t('LeftAndMain_Menu_ss.Hello','Hi') %>
|
<% _t('LeftAndMain_Menu_ss.Hello','Hi') %>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage security
|
* @subpackage security
|
||||||
*/
|
*/
|
||||||
class Security extends Controller {
|
class Security extends Controller implements TemplateGlobalProvider {
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'index',
|
'index',
|
||||||
@ -97,6 +97,24 @@ class Security extends Controller {
|
|||||||
*/
|
*/
|
||||||
private static $token;
|
private static $token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default login URL
|
||||||
|
*
|
||||||
|
* @config
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private static $login_url = "Security/login";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default logout URL
|
||||||
|
*
|
||||||
|
* @config
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private static $logout_url = "Security/logout";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get location of word list file
|
* Get location of word list file
|
||||||
*
|
*
|
||||||
@ -989,22 +1007,52 @@ class Security extends Controller {
|
|||||||
return self::$ignore_disallowed_actions;
|
return self::$ignore_disallowed_actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @config */
|
|
||||||
private static $login_url = "Security/login";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a custom log-in URL if you have built your own log-in page.
|
* Set a custom log-in URL if you have built your own log-in page.
|
||||||
|
*
|
||||||
|
* @deprecated 3.2 Use the "Security.login_url" config setting instead.
|
||||||
*/
|
*/
|
||||||
public static function set_login_url($loginUrl) {
|
public static function set_login_url($loginUrl) {
|
||||||
self::$login_url = $loginUrl;
|
Deprecation::notice('3.2', 'Use the "Security.login_url" config setting instead');
|
||||||
|
self::config()->update("login_url", $loginUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the URL of the log-in page.
|
* Get the URL of the log-in page.
|
||||||
* Defaults to Security/login but can be re-set with {@link set_login_url()}
|
*
|
||||||
|
* To update the login url use the "Security.login_url" config setting.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function login_url() {
|
public static function login_url() {
|
||||||
return self::$login_url;
|
return self::config()->login_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the URL of the logout page.
|
||||||
|
*
|
||||||
|
* To update the logout url use the "Security.logout_url" config setting.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function logout_url() {
|
||||||
|
return self::config()->logout_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines global accesible templates variables.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function get_template_global_variables() {
|
||||||
|
return array(
|
||||||
|
"LoginURL" => "login_url",
|
||||||
|
"LogoutURL" => "logout_url",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,7 @@ class SecurityTest extends FunctionalTest {
|
|||||||
* Helper method for the tests above
|
* Helper method for the tests above
|
||||||
*/
|
*/
|
||||||
public function doTestLoginForm($email, $password, $backURL = 'test/link') {
|
public function doTestLoginForm($email, $password, $backURL = 'test/link') {
|
||||||
$this->get('Security/logout');
|
$this->get(Config::inst()->get('Security', 'logout_url'));
|
||||||
$this->session()->inst_set('BackURL', $backURL);
|
$this->session()->inst_set('BackURL', $backURL);
|
||||||
$this->get(Config::inst()->get('Security', 'login_url'));
|
$this->get(Config::inst()->get('Security', 'login_url'));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user