beforeMemberLoggedIn/beforeMemberLoggedOut hooks

Required to save/restore parts of the session information,
which Member nukes indiscriminately on logout.

Specific use case is restoring linkages to temporary databases
on Behat test runs.
This commit is contained in:
Ingo Schommer 2013-12-18 18:25:51 +01:00
parent 763aa2fbf6
commit 15c7252af0

View File

@ -364,6 +364,8 @@ class Member extends DataObject implements TemplateGlobalProvider {
* @param bool $remember If set to TRUE, the member will be logged in automatically the next time.
*/
public function logIn($remember = false) {
$this->extend('beforeMemberLoggedIn');
self::session_regenerate_id();
Session::set("loggedInAs", $this->ID);
@ -469,6 +471,8 @@ class Member extends DataObject implements TemplateGlobalProvider {
* Logs this member out.
*/
public function logOut() {
$this->extend('beforeMemberLoggedOut');
Session::clear("loggedInAs");
if(Member::config()->login_marker_cookie) Cookie::set(Member::config()->login_marker_cookie, null, 0);