Changeset 43

Show
Ignore:
Timestamp:
05/22/07 15:28:34 (2 years ago)
Author:
pdingle
Message:

updated functions evaluateIncomingRequest, doUserLogin, updateUserData, getLoginID

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-infocard/wp/login/class.infocard-login.php

    r42 r43  
    131131                //print get_settings('siteurl') . "/wp-login.php"; 
    132132                // hardcoded for now FIX THIS before release 
    133                 print get_settings('securesiteurl') 
     133                print get_settings('siteurl') 
    134134                        . "/wp-login.php"; 
    135135        }  
  • trunk/wp-infocard/wp/login/infocard-login.php

    r40 r43  
    7575        <tr><td colspan="2"> 
    7676                <ul><li> 
    77                 <a href="<?php bloginfo('wpurl'); ?>/wp-register.php"><?php _e('Register', 'wp-infocard'); ?></a> 
     77                <a href="<?php bloginfo('siteurl'); ?>/wp-register.php"><?php _e('Register', 'wp-infocard'); ?></a> 
    7878                </li><li> 
    79                 <a href="<?php bloginfo('wpurl'); ?>/wp-login.php?action=lostpassword" title="Password Lost and Found"><?php _e('Lost your password?', 'wp-infocard'); ?></a> 
     79                <a href="<?php bloginfo('siteurl'); ?>/wp-login.php?action=lostpassword" title="Password Lost and Found"><?php _e('Lost your password?', 'wp-infocard'); ?></a> 
    8080                </li></ul> 
    8181        </td></tr> 
  • trunk/wp-infocard/wp/userdata.pw.php

    r42 r43  
    33include_once( dirname(__FILE__) . '/../pw-config.php'); 
    44include_once( dirname(__FILE__) . '/utils.pw.php'); 
    5 //require_once( ABSPATH . WPINC . '/registration-functions.php'); 
     5include_once( ABSPATH . WPINC . '/registration-functions.php'); 
    66 
    77/* 
     
    3232        // Side-effects: none 
    3333 
    34         function evaluateIncomingRequest( $email='', $modulusHash='', $ppid=''
    35         { 
    36                 global $wpdb
     34        function evaluateIncomingRequest(
     35        { 
     36                global $wpdb, $claimslist, $datamap
    3737                $incominguser['id'] = 0; 
    3838                $incominguser['status'] = 'UNKNOWNERROR'; 
    3939                $identity_user_id = 0; 
    4040 
    41                 InfocardUtils::printDebug( '<br/>Evaluating Incoming Request:<br/>'); 
    42  
    43                 if (!is_email($email)) { 
     41                pw_utils::printDebug( '<br/>Evaluating Incoming Request:<br/>'); 
     42 
     43                if (!is_email($claimslist['emailaddress']->token_value)) { 
    4444                        $incominguser['status'] = "INVALIDEMAIL"; 
    4545                        return $incominguser; 
    4646                } 
    4747 
    48                 $query = "SELECT * FROM `wp_infocard_identities` WHERE modulusHash = " 
    49                         . "'$modulusHash' AND ppid = '$ppid'"; 
     48                $query = "SELECT * FROM `" . PW_TABLE_PREFIX  
     49                . "infocard_identities` WHERE modulusHash = '" 
     50                        . $claimslist['modulusHash']->token_value  
     51                        . "' AND ppid = '" 
     52                        . $claimslist['privatepersonalidentifier']->token_value 
     53                        . "'"; 
    5054                $identity_info = $wpdb->get_results( $query, OBJECT ); 
    5155 
     
    5559                                // could be valid-user, or new-email 
    5660                                $identity_user_id = $identity_info[0]->accountid; 
     61                                 $datamap['modulusHash']->add_db_value($identity_info[0]->modulusHash); 
     62                                                                 $datamap['privatepersonalidentifier']->add_db_value($identity_info[0]->ppid); 
     63 
    5764                        break; 
    5865 
     
    6976 
    7077 
    71                 pw_utils::printDebug('&nbsp;&nbsp;Identity_user_id: ' . $identity_user_id . "<br/>" );  
    72  
    73  
    74                 $query = "SELECT * from wp_users WHERE user_email LIKE '$email'"; 
     78                pw_utils::printDebug('&nbsp;&nbsp;Card belongs to account #: ' . $identity_user_id . "<br/>" );  
     79 
     80 
     81                $query = "SELECT * from " . PW_TABLE_PREFIX . "users " 
     82                . "WHERE user_email LIKE '" 
     83                . $claimslist['emailaddress']->token_value . "'"; 
     84 
    7585                $user_info = $wpdb->get_results( $query, ARRAY_A ); 
    7686 
     
    7989                        case 1: 
    8090                                $mail_user_id = $user_info[0][ID]; 
    81                                 $incominguser['user_row'] = $user_info[0]; 
    82  
    83                                 if ($identity_user_id == $mail_user_id) 
    84                                 { 
    85                                         $incominguser['id'] = $mail_user_id; 
    86                                         $incominguser['status'] = 'valid-user'; 
    87                                 } 
    88                                 elseif ($identity_user_id == 0) 
    89                                 { 
    90                                         $incominguser['id'] = $mail_user_id; 
    91                                         $incominguser['status'] = 'new-card'; 
    92  
    93                                 } 
    94                                 else 
    95                                 { 
    96                                         $incominguser['status'] = "CLAIMSMISMATCHED"; 
    97                                         return $incominguser; 
    98                                 } 
     91                                pw_utils::printDebug('&nbsp;&nbsp;User belongs to account #: ' . $mail_user_id . "<br/>" ); 
     92                                if ($identity_user_id == 0) 
     93                                { 
     94                                        $incominguser['id'] = $mail_user_id; 
     95                                        $incominguser['status'] = 'new-card'; 
     96                                } 
     97                                elseif ($identity_user_id != $mail_user_id) 
     98                                { 
     99                                        $incominguser['status'] = "CLAIMSMISMATCHED"; 
     100                                        return $incominguser; 
     101                                } 
     102                                if ($identity_user_id == $mail_user_id) 
     103                                { 
     104                                        $incominguser['id'] = $mail_user_id; 
     105                                        $incominguser['status'] = 'valid-user'; 
     106 
     107                                } 
     108                                foreach (array_keys($datamap) as $key) 
     109                                { 
     110                                        if (array_key_exists($datamap[$key]->mappingattribute, $user_info[0])) 
     111                                        { 
     112                                                pw_utils::printDebug('Mapping: found '.$datamap[$key]->mappingattribute.' in user_info[0]<br/>'); 
     113                                                $datamap[$key]->add_db_value($user_info[0][$datamap[$key]->mappingattribute]); 
     114                                        } 
     115                                } 
     116 
     117                                // special case for first, last name 
     118                                $first = get_usermeta($mail_user_id, 'first_name'); 
     119                                pw_utils::printDebug('FIRST: ' . $first . '<br/>'); 
     120                                $datamap['first_name']->add_db_value(get_usermeta($mail_user_id, 'first_name')); 
     121                                $datamap['last_name']->add_db_value(get_usermeta($mail_user_id, 'last_name')); 
    99122                        break; 
    100123 
     
    120143                } 
    121144 
    122                 pw_utils::printDebug( "&nbsp;&nbsp;Email_user_id: $mail_user_id <br/>" ); 
    123                 InfocardUtils::printDebug( "&nbsp;&nbsp;Status: " . $incominguser['status'] . "<br/>" ); 
     145               pw_utils::printDebug( "&nbsp;&nbsp;Email address belongs toaccount #: $mail_user_id <br/>" ); 
     146                pw_utils::printDebug( "&nbsp;&nbsp;Status: " . $incominguser['status'] . "<br/><br/>" ); 
    124147 
    125148                return $incominguser; 
    126149        } // end function evaluateIncomingRequest 
    127150 
    128  
    129151        function mapTokenData() 
    130152        { 
    131153                global $claimslist, $datamap; 
    132                 pw_utils::printDebug('<br/>Mapped Data:<br/>'); 
     154                pw_utils::printDebug('<br/>Mapped Token Data:<br/>'); 
    133155                foreach(array_keys($datamap) as $key) 
    134156                { 
     
    138160                } 
    139161        } // end function mapTokenData 
     162 
     163        // Function: getLoginID 
     164        // Description:  always returns existing value if it exists 
     165        //               otherwise for now takes the email address. 
     166        function getLoginID() 
     167        { 
     168                global $datamap; 
     169                $loginid = $datamap['user_login']->db_value; 
     170                if ($loginid) 
     171                { 
     172                        pw_utils::printDebug('&nbsp;getLoginID: Login ID already exists: '.$loginid.'<br/>'); 
     173                        return $loginid; 
     174                } 
     175                $loginid = $datamap['user_email']->new_value; 
     176                //$loginid = 'pamtest'; 
     177                pw_utils::printDebug('&nbsp;getLoginID: Login ID generated: '.$loginid.'<br/>'); 
     178                return $loginid; 
     179        } //end function getLoginID 
     180 
     181        // Function: updateUserData 
     182        // Description: in order to do definitive account lookup with a card,  
     183        //              the PPID/modulus combination must uniquely identify an 
     184        //              account.  This may change in the future. 
     185        // Input: ppid, certificate modulus, account ID  
     186        // Output: none 
     187        // Side effect: modifies table data 
     188        function updateUserData( $ID, $datamap ) 
     189        { 
     190                global $wpdb; 
     191 
     192                // not sure if there is a more graceful way to do this... 
     193                $user_login = $datamap['user_login']->db_value; 
     194                if (!$datamap['display_name']->compare()) 
     195                { 
     196                        $display_name = $datamap['display_name']->new_value; 
     197                        $user_nicename = $display_name; 
     198                } 
     199                if (!$datamap['user_email']->compare()) 
     200                        $user_email = $datamap['user_email']->new_value; 
     201 
     202                if (($datamap['user_url']) && (!$datamap['user_url']->compare())) 
     203                        $user_url = $datamap['user_url']->new_value; 
     204 
     205                if (!$datamap['first_name']->compare()) 
     206                        $first_name = $datamap['first_name']->new_value; 
     207 
     208                if (!$datamap['last_name']->compare()) 
     209                        $last_name = $datamap['last_name']->new_value; 
     210 
     211                $userdata = compact('ID', 'user_login', 'user_email', 'user_nicename', 'user_url', 'display_name', 'first_name', 'last_name'); 
     212 
     213                if (wp_update_user($userdata)) 
     214                { 
     215                        pw_utils::printDebug('&nbsp;User Updates Successful'); 
     216                        pw_utils::printDebug($query); 
     217                } 
     218        } // end function updateUserData 
    140219 
    141220        // Function: updateIdentityData 
     
    198277        } // end function updateIdentityData 
    199278 
    200         // Function: getLoginID 
    201         // Description:  always returns existing value if it exists 
    202         //               otherwise for now takes the email address. 
    203         function getLoginID() 
     279        // Function:    Perform user login functions 
     280        // Description: set whatever cookie &/or session information needed 
     281        //              for an authenticated user. 
     282        // Returns: 
     283        function doUserLogin($id, $username, $ppid ) 
    204284        { 
    205285                global $datamap; 
    206                 $loginid = $datamap['loginid']->db_value; 
    207  
    208                 if ($loginid) 
    209                         return $loginid; 
    210                  
    211                 $loginid = $datamap['email']->new_value; 
    212                 return $loginid;         
    213         } 
     286                // note - don't put any debug statements in here, we are buffering in the main infocard-post file 
     287                $user_url = ($datamap['user_url']?$datamap['user_url']->new_value:""); 
     288                InfocardProcessing::setLoginCookies($username, $ppid, $datamap['display_name']->new_value, $datamap['user_email']->new_value, $user_url); 
     289                //mosRedirect('index.php'); 
     290        } //end function doUserLogin 
    214291 
    215292} // end class pw_userdata 
  • trunk/wp-infocard/wp/utils.pw.php

    r41 r43  
    176176                foreach ($datamap as $map) 
    177177                { 
    178                         pw_utils::printDebug($map->handle . " in " 
     178                        pw_utils::printDebug($map->displayname . " in " 
    179179                        . $map->mappingtable . "." 
    180180                        . $map->mappingattribute