appdb/ ./account.php include/user.php
WineHQ
wineowner at wine.codeweavers.com
Wed Jul 5 22:37:50 CDT 2006
ChangeSet ID: 26194
CVSROOT: /opt/cvs-commit
Module name: appdb
Changes by: wineowner at winehq.org 2006/07/05 22:37:50
Modified files:
. : account.php
include : user.php
Log message:
Chris Morgan <cmorgan at alum.wpi.edu>
Move $_SESSION['current'] manipulation into user class. Add user::logout() to keep user::login() and logout() symmetrical
Patch: http://cvs.winehq.org/patch.py?id=26194
Old revision New revision Changes Path
1.22 1.23 +7 -4 appdb/account.php
1.72 1.73 +13 -0 appdb/include/user.php
Index: appdb/account.php
diff -u -p appdb/account.php:1.22 appdb/account.php:1.23
--- appdb/account.php:1.22 6 Jul 2006 3:37:50 -0000
+++ appdb/account.php 6 Jul 2006 3:37:50 -0000
@@ -54,7 +54,13 @@ function do_account($cmd = null)
exit;
case "logout":
+ /* if we are logged in, log us out */
+ if($_SESSION['current'])
+ $_SESSION['current']->logout();
+
+ /* destroy all session variables */
$GLOBALS['session']->destroy();
+
addmsg("You are successfully logged out.", "green");
redirect(apidb_fullurl("index.php"));
exit;
@@ -116,8 +122,7 @@ function cmd_do_new()
if($result == SUCCESS)
{
/* if we can log the user in, log them in automatically */
- if($user->login($aClean['ext_email'], $aClean['ext_password']) == SUCCESS)
- $_SESSION['current'] = $user;
+ $user->login($aClean['ext_email'], $aClean['ext_password']);
addmsg("Account created! (".$aClean['ext_email'].")", "green");
redirect(apidb_fullurl());
@@ -211,13 +216,11 @@ function cmd_do_login()
if($result == SUCCESS)
{
- $_SESSION['current'] = $user;
addmsg("You are successfully logged in as '$user->sRealname'.", "green");
redirect(apidb_fullurl("index.php"));
} else
{
retry("login","Login failed ".$note);
- $_SESSION['current'] = "";
}
}
Index: appdb/include/user.php
diff -u -p appdb/include/user.php:1.72 appdb/include/user.php:1.73
--- appdb/include/user.php:1.72 6 Jul 2006 3:37:50 -0000
+++ appdb/include/user.php 6 Jul 2006 3:37:50 -0000
@@ -75,11 +75,24 @@ class User {
// Update timestamp and clear the inactivity flag if it was set
query_parameters("UPDATE user_list SET stamp = ?, inactivity_warned = '?' WHERE userid='?'",
"NOW()", "false", $this->iUserId);
+
+ /* set the session variable for the current user to this user object */
+ $_SESSION['current'] = $this;
+
return SUCCESS;
}
+
+ /* null out the session variable for the current user since we failed to login */
+ $_SESSION['current'] = "";
return USER_LOGIN_FAILED;
}
+ function logout()
+ {
+ /* null out the session current variable to log us out */
+ $_SESSION['current'] = "";
+ }
+
/*
* Creates a new user.
More information about the wine-cvs
mailing list