diff --git a/security/MemberLoginForm.php b/security/MemberLoginForm.php index f73359830..99fe83028 100644 --- a/security/MemberLoginForm.php +++ b/security/MemberLoginForm.php @@ -109,7 +109,7 @@ class MemberLoginForm extends LoginForm { Session::clear("BackURL"); Director::redirect($backURL); } else { - Director::redirectBack(); + Director::redirect(Security::default_login_dest()); } } else { Session::set('SessionForms.MemberLoginForm.Email', $data['Email']); diff --git a/security/Security.php b/security/Security.php index 2428e43ef..b5af178bc 100644 --- a/security/Security.php +++ b/security/Security.php @@ -927,6 +927,26 @@ class Security extends Controller { public static function login_recording() { return self::$login_recording; } + + protected static $default_login_dest = ""; + + /** + * Set the default login dest + * This is the URL that users will be redirected to after they log in, + * if they haven't logged in en route to access a secured page. + * + * By default, this is set to the homepage + */ + public static function set_default_login_dest($dest) { + self::$default_login_dest = $dest; + } + + /** + * Get the default login dest + */ + public static function default_login_dest() { + return self::$default_login_dest; + } }