Changeset 1289
- Timestamp:
- 09/09/07 19:14:26 (1 year ago)
- Files:
-
- trunk/wifidog-auth/CHANGELOG (modified) (1 diff)
- trunk/wifidog-auth/wifidog/classes/Authenticator.php (modified) (4 diffs)
- trunk/wifidog-auth/wifidog/classes/OpenIdServerWifidog.php (added)
- trunk/wifidog-auth/wifidog/classes/User.php (modified) (3 diffs)
- trunk/wifidog-auth/wifidog/include/schema_validate.php (modified) (2 diffs)
- trunk/wifidog-auth/wifidog/install.php (modified) (1 diff)
- trunk/wifidog-auth/wifidog/openid (added)
- trunk/wifidog-auth/wifidog/openid/index.php (added)
- trunk/wifidog-auth/wifidog/profile/index.php (modified) (2 diffs)
- trunk/wifidog-auth/wifidog/templates/classes/Authenticator_getLoginForm.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wifidog-auth/CHANGELOG
r1287 r1289 1 1 # $Id$ 2 2007-09-09 Benoit Grégoire <bock@step.polymtl.ca> 3 * Early OpenID support. The auth server can now be used as an identity provider, with your profile page as the identity URL 4 2 5 2007-09-08 Benoit Grégoire <bock@step.polymtl.ca> 3 6 * Dependencies installation: Improve layout, add embryo of unified install sytem (currently works for tarballs). Improve error output. trunk/wifidog-auth/wifidog/classes/Authenticator.php
r1249 r1289 122 122 /** 123 123 * Get the login interface 124 * @param string $userData=null Array of contextual data optionally sent to the method. 125 * The function must still function if none of it is present. 126 * 127 * * This method understands: 128 * $userData['preSelectedUser'] An optional User object. 124 129 * @return HTML markup 125 130 */ 126 static public function getLoginUI( )131 static public function getLoginUI($userData=null) 127 132 { 128 133 require_once('classes/SmartyWifidog.php'); 134 $networkUserData = null; 135 if(!empty($userData['preSelectedUser'])){ 136 $selectedUser=$userData['preSelectedUser']; 137 $networkUserData['preSelectedObject']=$selectedUser; 138 } 139 else { 140 $selectedUser=null; 141 } 142 129 143 $smarty=SmartyWiFiDog::getObject(); 130 144 // Set network selector 131 $smarty->assign('selectNetworkUI', Network::getSelectUI('auth_source' ));145 $smarty->assign('selectNetworkUI', Network::getSelectUI('auth_source', $networkUserData)); 132 146 // Set user details 133 $smarty->assign('username', !empty($username) ? $username : ""); 147 $smarty->assign('user_id', $selectedUser ? $selectedUser->getId() : ""); 148 $smarty->assign('username', $selectedUser ? $selectedUser->getUsername() : ""); 134 149 135 150 // Set error message … … 145 160 * Process the login interface 146 161 */ 147 static public function processLoginUI(&$errmsg )162 static public function processLoginUI(&$errmsg = null) 148 163 { 149 164 if (!empty($_REQUEST["login_form_submit"])) { 150 if (isset($_REQUEST["username"])) { 165 if (isset($_REQUEST["user_id"])) { 166 $username = User::getObject($_REQUEST["user_id"])->getUsername(); 167 } 168 else if (isset($_REQUEST["username"])) { 151 169 $username = $_REQUEST["username"]; 152 170 } … … 155 173 $password = $_REQUEST["password"]; 156 174 } 175 157 176 // Authenticating the user through the selected auth source. 158 177 $network = Network::processSelectUI('auth_source'); … … 160 179 self::$_loginLastError = $errmsg; 161 180 } 162 163 164 181 } 165 182 /** trunk/wifidog-auth/wifidog/classes/User.php
r1285 r1289 161 161 162 162 /** Instantiate a user object 163 * @param $url The OpenId url 164 * @return a User object, or null if none matched 165 */ 166 public static function getUserByOpenIdUrl($url) { 167 $db = AbstractDb::getObject(); 168 $object = null; 169 170 $url_str = $db->escapeString($url); 171 $db->execSqlUniqueRes("SELECT user_id FROM users WHERE open_id_url = '$url_str'", $user_rows, false); 172 173 if ($user_rows != null) { 174 $object = self::getObject($user_rows[0]['user_id']); 175 } 176 return $object; 177 } 178 /** Instantiate a user object 163 179 * @param $email The email of the user 164 180 * @param $account_origin Network: The account origin … … 293 309 $profiles=$this->getAllProfiles(); 294 310 if($profiles){ 295 $html .= "<a href='".BASE_URL_PATH."profile/? profile_user_id=".$this->getId()."' title='".htmlentities(_("View this user's profile."), ENT_QUOTES)."' class='user_nickname'>";311 $html .= "<a href='".BASE_URL_PATH."profile/?user_id=".$this->getId()."' title='".htmlentities(_("View this user's profile."), ENT_QUOTES)."' class='user_nickname'>"; 296 312 } 297 313 if(empty($nickname)) … … 311 327 } 312 328 329 function getOpenIdUrl() { 330 return $this->_row['open_id_url']; 331 } 332 313 333 function getUsername() { 314 334 return $this->_row['username']; trunk/wifidog-auth/wifidog/include/schema_validate.php
r1263 r1289 48 48 * Define current database schema version 49 49 */ 50 define('REQUIRED_SCHEMA_VERSION', 5 6);50 define('REQUIRED_SCHEMA_VERSION', 57); 51 51 /** Used to test a new shecma version before modyfying the database */ 52 52 define('SCHEMA_UPDATE_TEST_MODE', false); … … 1291 1291 $sql .= "CREATE INDEX idx_connections_timestamp_in ON connections (timestamp_in);\n"; 1292 1292 } 1293 1293 1294 $new_schema_version = 57; 1295 if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 1296 printUpdateVersion($new_schema_version); 1297 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 1298 $sql .= "ALTER TABLE users ADD COLUMN open_id_url text;\n"; 1299 $sql .= "CREATE INDEX idx_users_topen_id_url ON users (open_id_url);\n"; 1300 } 1294 1301 /* 1295 1302 $new_schema_version = ; trunk/wifidog-auth/wifidog/install.php
r1288 r1289 170 170 'tmp/smarty/templates_c', 171 171 'tmp/smarty/cache', 172 'tmp/openidserver', 172 173 'lib/simplepie', 173 174 'lib/feedpressreview', trunk/wifidog-auth/wifidog/profile/index.php
r1253 r1289 68 68 * Start general request parameter processing section 69 69 */ 70 if (!empty ($_REQUEST[' profile_user_id'])) {70 if (!empty ($_REQUEST['user_id'])) { 71 71 try { 72 $profile_user = User :: getObject($_REQUEST[' profile_user_id']);72 $profile_user = User :: getObject($_REQUEST['user_id']); 73 73 if(!empty($profile_user)) { 74 74 $profiles = $profile_user->getAllProfiles(); … … 97 97 $ui = MainUI::getObject(); 98 98 $ui->setTitle(_("User profile")); 99 if(Dependency::check('php-openid')){ 100 require_once('classes/OpenIdServerWifidog.php'); 101 $ui->appendHtmlHeadContent("<link rel='openid.server' href='".OpenIdServerWifidog::getOpenIdServerUrl()."' />"); 102 } 99 103 $ui->setPageName('profile'); 100 104 //$ui->addContent('left_area_middle', $tool_html); trunk/wifidog-auth/wifidog/templates/classes/Authenticator_getLoginForm.tpl
r1249 r1289 46 46 47 47 *} 48 49 48 <h1>{"Login or Signup here"|_}:</h1> 50 51 52 49 <p> 53 50 {$selectNetworkUI} 54 51 </p> 55 56 {"Username (or email)"|_}:<br/> 57 <input type="text" name="username" id="form_username" tabindex="1" value="{$username}" size="20" /><br/> 52 {if $user_id} 53 <input type="hidden" name="user_id" id="form_user_id" value="{$user_id}"/> 54 {else} 55 {"Username (or email)"|_}:<br/> 56 <input type="text" name="username" id="form_username" tabindex="1" value="{$username}" size="20" /><br/> 57 {/if} 58 58 {"Password"|_}:<br/> 59 59 <input type="password" name="password" id="form_password" tabindex="2" size="20" /><br/>
