From: Calin Burloiu Date: Fri, 14 Oct 2011 14:00:11 +0000 (+0300) Subject: still working at OpenID X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=59d86a4497243dd290ef731341aaa9110553dbbd;hp=ada355332b092d2bd0ec7845f62c307587c9aab0;p=living-lab-site.git still working at OpenID --- diff --git a/application/config/openid.php b/application/config/openid.php index 2dc2630..176a648 100644 --- a/application/config/openid.php +++ b/application/config/openid.php @@ -2,7 +2,7 @@ $config['openid_storepath'] = './tmp'; $config['openid_required'] = array('nickname'); -$config['openid_optional'] = array('fullname', 'email'); +$config['openid_optional'] = array('fullname', 'email', 'dob', 'country'); $config['openid_pape_policies'] = array(); // OBSOLETE diff --git a/application/controllers/user.php b/application/controllers/user.php index 5a9b779..2e4b4ee 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -157,6 +157,8 @@ class User extends CI_Controller { //echo 'nickname('. $sreg_resp->get('nickname'). ')'; echo var_dump($obj->data); + echo '
'; + echo var_dump($sreg); // foreach ($sreg as $key => $value) // { // $data['success'] .= $this->_set_message('openid_content', array($key, $value), array('%s', '%t')); diff --git a/application/libraries/Openid.php b/application/libraries/Openid.php index 0ac29e4..7fd12fd 100644 --- a/application/libraries/Openid.php +++ b/application/libraries/Openid.php @@ -122,9 +122,12 @@ class Openid { // Create attribute request object // See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters // Usage: make($type_uri, $count=1, $required=false, $alias=null) - $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email',2,1, 'email'); - $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first',1,1, 'firstname'); - $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last',1,1, 'lastname'); + $attribute[] = Auth_OpenID_AX_AttrInfo::make( + 'http://axschema.org/contact/email', 1, TRUE); + $attribute[] = Auth_OpenID_AX_AttrInfo::make( + 'http://axschema.org/namePerson/first', 1, TRUE); + $attribute[] = Auth_OpenID_AX_AttrInfo::make( + 'http://axschema.org/namePerson/last', 1, TRUE); // Create AX fetch request $ax = new Auth_OpenID_AX_FetchRequest; diff --git a/application/models/users_model.php b/application/models/users_model.php index 76f378d..02a520f 100644 --- a/application/models/users_model.php +++ b/application/models/users_model.php @@ -78,6 +78,10 @@ class Users_model extends CI_Model { && ! $this->ldap_login($username, $password)) return FALSE; + if (empty($user['email']) || empty($user['first_name']) + || empty($user['last_name'])) + $user['import'] = TRUE; + // Update last login time. $this->db->query("UPDATE `users` SET last_login = UTC_TIMESTAMP() @@ -201,6 +205,9 @@ class Users_model extends CI_Model { $data['password'] = sha1($data['password']); // TODO picture data: save, convert, make it thumbnail + if (empty($data['birth_date'])) + $data['birth_date'] = NULL; + $cols = ''; $vals = ''; foreach ($data as $col=> $val) @@ -229,13 +236,16 @@ class Users_model extends CI_Model { // If registered with internal authentication it needs to activate // the account. - $activation_code = Users_model::gen_activation_code($data['username']); - $user_id = $this->get_user_id($data['username']); - $query = $this->db->query("INSERT INTO `users_unactivated` - (user_id, activation_code) - VALUES ($user_id, '$activation_code')"); - $this->send_activation_email($user_id, $data['email'], - $activation_code, $data['username']); + if ($data['auth_src'] == 'internal') + { + $activation_code = Users_model::gen_activation_code($data['username']); + $user_id = $this->get_user_id($data['username']); + $query = $this->db->query("INSERT INTO `users_unactivated` + (user_id, activation_code) + VALUES ($user_id, '$activation_code')"); + $this->send_activation_email($user_id, $data['email'], + $activation_code, $data['username']); + } // TODO exception on failure return $query; @@ -395,15 +405,22 @@ class Users_model extends CI_Model { $data['password'] = sha1($data['password']); // TODO picture data: save, convert, make it thumbnail + if (empty($data['birth_date'])) + $data['birth_date'] = NULL; + $set = ''; foreach ($data as $col => $val) { + if ($val === NULL) + { + $set .= "$col = NULL, "; + continue; + } + if (is_int($val)) $set .= "$col = $val, "; else if (is_string($val)) $set .= "$col = '$val', "; - else if (is_null($var)) - $set .= "$col = NULL, "; } $set = substr($set, 0, -2); diff --git a/data/user_pictures/admin-.jpg b/data/user_pictures/admin-.jpg new file mode 100644 index 0000000..a33a4da Binary files /dev/null and b/data/user_pictures/admin-.jpg differ diff --git a/data/user_pictures/admin-.jpg-thumb.jpg b/data/user_pictures/admin-.jpg-thumb.jpg new file mode 100644 index 0000000..95820d9 Binary files /dev/null and b/data/user_pictures/admin-.jpg-thumb.jpg differ