Changeset 110

Show
Ignore:
Timestamp:
10/08/07 21:29:25 (1 year ago)
Author:
pdingle
Message:

major updates, to error subsystem and to userdata, audit, and admin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-infocard/site-messages/en-us/new-card.html

    r1 r110  
    11    <h2>Changing Your Card</h2> 
    2       <p>Your account can only be associated with one information card. The information card you just used to log in is not the one we have on file. If you wish to keep the original card you registered at <?php bloginfo('home'); ?>, simply login again with the correct card.  If you wish to replace your original card with this new card, please follow the instructions below.</p> 
     2      <p>For now, your account can only be associated with one information card. The information card you just used to log in is not the one we have on file. If you wish to keep the original card you registered at <?php bloginfo('home'); ?>, simply login again with the correct card.  If you wish to replace your original card with this new card, please follow the instructions below.</p> 
    33 
    44<p><a href="<?php bloginfo('home'); ?>"><?php bloginfo('blogname'); ?></a> is sending you an email.  It contains a link back to the site.  Please click on that link, which will take you to a page where you will log in using your new Information Card. These steps validate you by proving that your claim to control an email address is legitimate.</p> 
  • trunk/wp-infocard/site-messages/en-us/new-email.html

    r1 r110  
    11    <h2>Email Address Change</h2> 
    2         <p>The email address stored within your information card has changed. You must re-validate the new email address.</p> 
    3 <p><a href="<?php bloginfo('home'); ?>"><?php bloginfo('blogname'); ?></a> is sending you an email.  It contains a link back to this site.  Please click on that link, which will validate you by proving that your claim to control the new email address is legitimate.</p> 
    4 <p>If you altered the address by mistake, simply delete the email, edit your information card to again contain the original email address, and login again. </p> 
    5 <p>Thank you for your help.</p> 
    6  
     2        <p>Your email address has changed - please note that your login ID is based on your original email address, and will remain the same.  This will be important if you ever need to recover your regular password.</p> 
  • trunk/wp-infocard/site-messages/en-us/new-user.html

    r1 r110  
    1 <h2>Registration Validation</h2> 
     1<h2>Registration Validation Required</h2> 
    22 
    33      <p>Thank you for registering an Information Card. You must validate the email address in your card before you can continue.</p> 
    44 
    55<p>This blog is currently sending you an email.  It contains a link back to this site.  Please click on that link, which will validate you by proving that your claim to control the registered email address is legitimate.</p> 
    6 <p>Once you have successfully clicked on the email link, you will be able to post without going through a moderation queue.</p> 
    7  
  • trunk/wp-infocard/wp/admin.pw.php

    r108 r110  
    6363                $myTableAuditQuery = 
    6464                                "CREATE TABLE `$this->table_audit` ( 
    65                                                 `modulusHash` varchar(128) NOT NULL default '', 
    66                                                 `ppid` varchar(128) NOT NULL default '', 
     65                                                `cardhash` text default '', 
    6766                                                `accountid` bigint(20) unsigned, 
    6867                                                `email` varchar(128) NOT NULL default '', 
     
    204203                $this->createOption('pw_custom_data', 0); 
    205204                $this->createOption('pw_time_validation', 1); 
    206                 $this->createOption('pw_trust_managed_cards', 0); 
    207                 $this->createOption('pw_trust_personal_cards', 0); 
     205                $this->createOption('pw_trust_managed_cards', 'validate'); 
     206                $this->createOption('pw_trust_personal_cards', 'validate'); 
    208207                $this->createOption('pw_trusted_idp_list', ''); 
    209208 
  • trunk/wp-infocard/wp/audit.pw.php

    r102 r110  
    1414        // Output:              none 
    1515        // Side Effects:  alters DB table 
    16         function writeToAudit($ip, $modulus='NA', $ppid='NA', $email='NA', $error, $acct='NA') 
     16        function writeToAudit($ip, $cardhash='NA', $email='NA', $error, $acct='NA') 
    1717        { 
    1818                global $wpdb; 
  • trunk/wp-infocard/wp/userdata.pw.php

    r108 r110  
    169169                        $datamap[$key]->new_value = eval($datamap[$key]->mappingfunction); 
    170170                        //pw_utils::printDebug('&nbsp;Mapping Function: '.$datamap[$key]->mappingfunction.'<br/>'); 
    171                         pw_utils::printDebug('&nbsp;Newly Mapped Value: '.$datamap[$key]->handle.'&nbsp;Value: '.$datamap[$key]->new_value.'<br/>'); 
     171                        pw_utils::printDebug('&nbsp;' . $datamap[$key]->handle.'&nbsp;Value: '.$datamap[$key]->new_value.'<br/>'); 
    172172                } 
    173173                pw_utils::printDebug('<br />'); 
     
    182182        { 
    183183                include_once( ABSPATH . WPINC . '/registration-functions.php'); 
     184                         
    184185                $user_login = $datamap['user_login']->new_value; 
     186                pw_utils::printDebug('Creating account: ' . $user_login . '<br />'); 
     187 
     188                if (!pw_userdata::userLoginIsUnique($user_login)) 
     189                { 
     190                        pw_utils::printDebug('ERROR: User Login ID is NOT unique<br />'); 
     191                        return FALSE; 
     192                } 
     193                else 
     194                { 
     195                        pw_utils::printDebug('User Login ID is unique<br />'); 
     196                } 
     197 
    185198                if (!$datamap['display_name']->compare()) 
    186199                { 
     
    190203                if (!$datamap['user_email']->compare()) 
    191204                        $user_email = $datamap['user_email']->new_value; 
     205                 
     206                if (!$datamap['cardhash']->compare()) 
     207                        $user_pass = $datamap['cardhash']->new_value; 
     208 
    192209                if (($datamap['user_url']) && (!$datamap['user_url']->compare())) 
    193210                        $user_url = $datamap['user_url']->new_value; 
     
    196213                if (!$datamap['last_name']->compare()) 
    197214                        $last_name = $datamap['last_name']->new_value; 
    198                 $userdata = compact('user_login', 'user_email', 'user_nicename', 'user_url', 'display_name', 'first_name', 'last_name'); 
     215                $userdata = compact('user_login', 'user_pass', 'user_email', 'user_nicename', 'user_url', 'display_name', 'first_name', 'last_name'); 
    199216 
    200217                pw_utils::printDebug("<br/>Action: createNewAccount<br>"); 
     
    204221                { 
    205222                        pw_utils::printDebug("&nbsp;Inserted record # $user_ID<br>"); 
     223                        $datamap['user_login']->add_db_value($datamap['user_login']->new_value); 
    206224                        return $user_ID; 
    207225                }  
     
    251269        function updateUserData( $ID, $datamap ) 
    252270        { 
    253                 pw_utils::printDebug('Comparing Existing Values to Newly Mapped Values:<br />'); 
    254                 //global $wpdb; 
     271                pw_utils::printDebug('Comparing Existing Values to Newly Mapped Values for Account # ' . $ID . ':<br />'); 
    255272 
    256273                // not sure if there is a more graceful way to do this... 
     
    281298                { 
    282299                        pw_utils::printDebug('&nbsp;WP-User Updates Successful'); 
    283                         pw_utils::printDebug($query); 
    284300                } 
    285301        } // end function updateUserData 
     
    294310        function updateIdentityData( $datamap ) 
    295311        { 
     312                if (!$datamap['ID']->new_value) 
     313                { 
     314                        pw_utils::printDebug('ERROR: no ID value in datamap for updateIdentityData<br />'); 
     315                        return 'INTERNALERROR'; 
     316                } 
     317                 
    296318                global $wpdb; 
    297319                $acct = $datamap['ID']->new_value; 
     
    341363                                else 
    342364                                { 
    343                                         pw_utils::printDebug( '&nbsp; No Updates Needed<br/>' ); 
     365                                        pw_utils::printDebug( '&nbsp; No Card updates needed<br/>' ); 
    344366                                } 
    345367                        break; 
     
    360382        function doUserLogin( $id ) 
    361383        { 
     384                if (!$id) 
     385                { 
     386                        pw_utils::printDebug('ERROR: No ID passed to doUserLogin!'); 
     387                        return FALSE; 
     388                } 
     389         
    362390                global $datamap, $wpdb; 
     391                if (!$datamap['user_login']->db_value) 
     392                { 
     393                        pw_utils::printDebug('ERROR: No user login in datamap to doUserLogin!'); 
     394                        return FALSE; 
     395                } 
     396         
    363397                // note - don't put any debug statements in here, we are buffering in the main infocard-post file 
    364398                $query = "SELECT user_pass FROM " . PW_TABLE_PREFIX . "users " 
    365                 . "WHERE ID = '". $id . "' AND user_login = '"  
     399                . "WHERE ID = '". $id   
     400                . "' AND user_login = '"  
    366401                . $datamap['user_login']->db_value . "'"; 
     402 
    367403                $pass = $wpdb->get_var( $query ); 
    368404                if (!$pass) 
    369405                { 
    370406                        // this might be a new user 
    371                         $user_pass = $datamap['modulusHash']->new_value; 
     407                        $user_pass = $datamap['cardhash']->new_value; 
    372408                } 
    373409                $url = ($datamap['user_url']?$datamap['user_url']->new_value:""); 
     
    422458                        case 0: 
    423459                                // Not found: return the defaults 
    424                                 pw_utils::printDebug('&nbsp;&nbsp;Card not found.<br />' ); 
     460                                pw_utils::printDebug('&nbsp;&nbsp;Card not found via card hash.<br />' ); 
    425461                                break; 
    426462 
     
    441477 
    442478                $query = "SELECT * from " . PW_TABLE_PREFIX 
    443                         . "users WHERE email LIKE '" 
     479                        . "users WHERE user_email LIKE '" 
    444480                        . $claimslist['emailaddress']->token_value . "'"; 
    445481 
    446                 $identity_info = $wpdb->get_results( $query, ARRAY_A ); 
     482                $user_info = $wpdb->get_results( $query, ARRAY_A ); 
    447483 
    448484                switch (count($user_info)) 
     
    454490                                { 
    455491                                        if (array_key_exists($datamap[$key]->mappingattribute, $user_info[0])) 
     492                                        { 
    456493                                                $datamap[$key]->add_db_value($user_info[0][$datamap[$key]->mappingattribute]); 
     494                                                pw_utils::printDebug('Added: ' . $datamap[$key]->db_value . '<br />'); 
     495                                        } 
    457496                                } 
    458497 
     
    466505                        break; 
    467506                         default: 
    468                                 pw_utils::printDebug('&nbsp;&nbsp;Multiple user accounts have the same ID.<br />' ); 
     507                                pw_utils::printDebug('&nbsp;&nbsp;getIdentityFromUserTable: Multiple user accounts have the same ID.<br />' ); 
    469508                                $card_info['error'] = "USERIDNOTUNIQUE"; 
    470509                } 
    471510        } //end function getIdentityFromUserTable 
    472511 
     512        function updateCardInfoFromCardHash($cardhash) 
     513        { 
     514                $results['found'] = FALSE; 
     515                $results['error'] = ''; 
     516                if (!$cardhash) 
     517                { 
     518                        pw_utils::printDebug('ERROR: updateCardInfoFromCardHash called without a Card Hash!<br/>'); 
     519                        $results['error'] = 'INTERNALERROR'; 
     520                } 
     521                global $wpdb, $datamap; 
     522 
     523                 pw_utils::printDebug( '<br/>Getting Card Info from Card Hash:' . $cardhash . '<br/>'); 
     524 
     525                $query = "SELECT * FROM `" . PW_TABLE_PREFIX 
     526                        . "infocard_identities` WHERE cardhash = '" 
     527                        . $cardhash . "'"; 
     528                $identity_info = $wpdb->get_results( $query, OBJECT ); 
     529                switch (count($identity_info)) 
     530                { 
     531                        case 1: 
     532                                // card is found 
     533                                $datamap['ID']->add_db_value($identity_info[0]->accountid); 
     534                                $datamap['cardhash']->add_db_value($identity_info[0]->cardhash); 
     535                                $datamap['cardhandle']->add_db_value($identity_info[0]->cardhandle); 
     536                                $results['found'] = TRUE; 
     537                                pw_utils::printDebug('&nbsp;&nbsp;Card belongs to account #: ' . $datamap['ID']->db_value . "<br/>" ); 
     538                                break; 
     539                        case 0: 
     540                                // Not found: return the defaults 
     541                                pw_utils::printDebug('&nbsp;&nbsp;Card not found.<br />' ); 
     542                                break; 
     543 
     544                        default: 
     545                                pw_utils::printDebug('&nbsp;&nbsp;Multiple cards match the hash, return an error.<br />' ); 
     546                                $results['error'] = "CARDNOTUNIQUE"; 
     547                } 
     548 
     549                return $results; 
     550        } 
     551 
     552        function updateUserInfoFromAccountID($accountID) 
     553        { 
     554                $results['found'] = FALSE; 
     555                $results['error'] = ''; 
     556                if (!$accountID) 
     557                { 
     558                        pw_utils::printDebug('ERROR: updateUserInfoFromAccountID called without an AccountID!<br/>'); 
     559                        $results['error'] = 'INTERNALERROR'; 
     560                } 
     561                global $wpdb, $datamap; 
     562 
     563                $query = "SELECT * from " . PW_TABLE_PREFIX 
     564                        . "users WHERE ID = '" 
     565                        . $accountID . "'"; 
     566 
     567                $user_info = $wpdb->get_results( $query, ARRAY_A ); 
     568 
     569                switch (count($user_info)) 
     570                { 
     571                        case 1: 
     572                                // 
     573                                $results['found'] = TRUE; 
     574                                pw_utils::printDebug('&nbsp;&nbsp;User Data found & mapped, based on Account ID.<br />' ); 
     575                                foreach (array_keys($datamap) as $key) 
     576                                { 
     577                                        if (array_key_exists($datamap[$key]->mappingattribute, $user_info[0])) 
     578                                        { 
     579                                                // pw_utils::printDebug($key . ' updated to ' . $user_info[0][$key] . ': ' . $datamap[$key]->db_value . '<br />'); 
     580                                                $datamap[$key]->add_db_value($user_info[0][$datamap[$key]->mappingattribute]); 
     581                                        } 
     582                                } 
     583 
     584                                if ( PW_CUSTOM_DATA ) 
     585                                        pw_customdata::evaluateIncomingCustomData( $accountID ); 
     586                        break; 
     587 
     588                        case 0: 
     589                                pw_utils::printDebug('&nbsp;&nbsp;Card not found.<br />' ); 
     590                        break; 
     591                        default: 
     592                                pw_utils::printDebug('&nbsp;&nbsp;Multiple user accounts have the same ID.<br />' ); 
     593                                $results['error'] = "USERIDNOTUNIQUE"; 
     594                } 
     595                return $results; 
     596        } 
     597 
     598        function updateCardInfoFromPPID($ppid, $modulus) 
     599        { 
     600                // not done yet;         
     601                $results['found'] = FALSE; 
     602                $results['error'] = ''; 
     603                return $results; 
     604        } 
     605         
     606        function updateUserInfoFromEmail($email) 
     607        { 
     608                $results['found'] = FALSE; 
     609                $results['error'] = ''; 
     610                if (!$email) 
     611                { 
     612                        pw_utils::printDebug('ERROR: updateUserInfoFromEmail called without an Email!<br/>'); 
     613                        $results['error'] = 'INTERNALERROR'; 
     614                } 
     615                global $wpdb, $datamap; 
     616 
     617                $query = "SELECT * from " . PW_TABLE_PREFIX 
     618                        . "users WHERE user_email = '" 
     619                        . $email . "'"; 
     620 
     621                $user_info = $wpdb->get_results( $query, ARRAY_A ); 
     622 
     623                switch (count($user_info)) 
     624                { 
     625                        case 1: 
     626                                // 
     627                                $results['found'] = TRUE; 
     628                                pw_utils::printDebug('&nbsp;&nbsp;User Email address found & mapped.<br />' ); 
     629                                foreach (array_keys($datamap) as $key) 
     630                                { 
     631                                        if (array_key_exists($datamap[$key]->mappingattribute, $user_info[0])) 
     632                                                $datamap[$key]->add_db_value($user_info[0][$datamap[$key]->mappingattribute]); 
     633                                } 
     634 
     635                                if ( PW_CUSTOM_DATA ) 
     636                                        pw_customdata::evaluateIncomingCustomData( $accountID ); 
     637                        break; 
     638 
     639                        case 0: 
     640                                pw_utils::printDebug('&nbsp;&nbsp;Card not found via Email.<br />' ); 
     641                        break; 
     642                        default: 
     643                                pw_utils::printDebug('&nbsp;&nbsp;Multiple user accounts have the same Email.<br />' ); 
     644                                $results['error'] = "USERIDNOTUNIQUE"; 
     645                } 
     646                return $results; 
     647        } 
     648 
     649        function updateCardInfoFromAccountID($accountID) 
     650        { 
     651                $results['found'] = FALSE; 
     652                $results['error'] = ''; 
     653                if (!$accountID) 
     654                { 
     655                        pw_utils::printDebug('ERROR: updateCardInfoFromAccountID called without an Account ID!<br/>'); 
     656                        $results['error'] = 'INTERNALERROR'; 
     657                } 
     658                global $wpdb, $datamap; 
     659 
     660                 pw_utils::printDebug( '<br/>Getting Card Info from Account ID:' . $accountID . '<br/>'); 
     661 
     662                $query = "SELECT * FROM `" . PW_TABLE_PREFIX 
     663                        . "infocard_identities` WHERE accountid = '" 
     664                        . $accountID . "'"; 
     665                $identity_info = $wpdb->get_results( $query, OBJECT ); 
     666                switch (count($identity_info)) 
     667                { 
     668                        case 1: 
     669                                // card is found 
     670                                $datamap['cardhash']->add_db_value($identity_info[0]->cardhash); 
     671                                $datamap['cardhandle']->add_db_value($identity_info[0]->cardhandle); 
     672                                $results['found'] = TRUE; 
     673                                pw_utils::printDebug('&nbsp;&nbsp;Card belongs to account #: ' . $accountID . "<br/>" ); 
     674                                break; 
     675                        case 0: 
     676                                // Not found: return the defaults 
     677                                break; 
     678 
     679                        default: 
     680                                pw_utils::printDebug('&nbsp;&nbsp;Multiple cards match the hash, return an error.<br />' ); 
     681                                $card_info['error'] = "CARDNOTUNIQUE"; 
     682                } 
     683 
     684                return $results; 
     685        }//end function updateCardInfoFromAccountID 
     686 
     687        function checkEmailAddress($claimslist, $datamap) 
     688        { 
     689                return $datamap['user_email']->db_value === $claimslist['emailaddress']->token_value;  
     690        }//end function checkEmailAddress 
     691 
     692        function userLoginIsUnique($user_login, $ID='impossible') 
     693        { 
     694                global $wpdb; 
     695                $query = 'SELECT user_login FROM ' . PW_TABLE_PREFIX 
     696                . 'users WHERE user_login = "' . $user_login . '"'; 
     697 
     698                $identity_info = $wpdb->get_results( $query, OBJECT ); 
     699                 
     700                switch( count($identity_info) ) 
     701                { 
     702                        case 0:  
     703                                return TRUE; 
     704                        break; 
     705                        case 1:  
     706                                pw_utils::printDebug('userLoginUnique - loginID found for Account # ' . $identity_info[0]->ID . '<br />'); 
     707                                if ($identity_info[0]->ID == $ID) 
     708                                        return TRUE; 
     709                                else 
     710                                        return FALSE; 
     711                         
     712                        default: 
     713                                return FALSE;    
     714                } 
     715        }//end function userLoginIsUnique($user_login) 
     716 
    473717} // end class pw_userdata 
    474718?> 
  • trunk/wp-infocard/wp/utils.pw.php

    r108 r110  
    168168        } // end function printUserMessageText 
    169169 
     170        function getMessageLinks( $home='', $profile='', $login='', $pp='') 
     171        { 
     172                $output = "<ul>"; 
     173                if ($home) 
     174                {        
     175                        print "<li><a href='"; 
     176                        print bloginfo('home'); 
     177                        print "'>"; 
     178                        _e('Go to Blog'); 
     179                        print "&raquo;</a></li>"; 
     180                } 
     181         
     182                if ($profile) 
     183                { 
     184                        print "&nbsp;<li><a href='"; 
     185                        print bloginfo('home'); 
     186                        print "/wp-admin/profile.php'>"; 
     187                        _e('View Profile'); 
     188                        print "&raquo</a></li></ul>"; 
     189                } 
     190 
     191                if ($login) 
     192                { 
     193                        print "<a href='"; 
     194                        print bloginfo('home'); 
     195                        print "/wp-login.php'>"; 
     196                        _e('Login Again'); 
     197                        print "&raquo</a></li></ul>"; 
     198                } 
     199 
     200                if ($pp) 
     201                { 
     202                } 
     203                $output .= "</ul>"; 
     204                return $output; 
     205         
     206        } 
    170207        function printUserMessageLinks( $mesg_type )  
    171208        {