[opw-web] Changes from Behnam



commit 319529f6c847c0b91c60ed72cb2dd9e4d0a26bde
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Fri Mar 7 15:41:26 2014 -0500

    Changes from Behnam

 classes/class_user.php                  |   75 +++++++++++++++++++++++++++++++
 lang/en-gb.php                          |   12 +++---
 modules/mod_login.php                   |    7 +--
 skins/easterngreen/html/tpl_header.html |    2 -
 skins/easterngreen/html/tpl_login.html  |   13 +++---
 5 files changed, 91 insertions(+), 18 deletions(-)
---
diff --git a/classes/class_user.php b/classes/class_user.php
index 1bcd3cf..39074a0 100644
--- a/classes/class_user.php
+++ b/classes/class_user.php
@@ -5,6 +5,8 @@
 * @copyright (c) 2012 KDE. All rights reserved.
 */
 
+require_once(__DIR__ . "/../auth/Hybrid/Auth.php");
+
 class user
 {
     // Global vars
@@ -192,6 +194,79 @@ class user
         return false;
     }
 
+    // Method for authenticating a user
+    function login_openid($openid)
+    {
+        global $config, $db;
+        $is_admin = false;
+
+        try {
+          $authconfig = dirname(__FILE__) . '/../auth/config.php';
+          $hybridauth = new Hybrid_Auth($authconfig);
+          $openidauth = $hybridauth->authenticate("OpenID", array (
+            'openid_identifier' => $openid
+          ));
+
+          /*XXX
+          $is_user_logged_in = $openidauth->isUserConnected();
+          if (!$is_user_logged_in) {
+            return false;
+          }
+
+          $user_profile = $openidauth->getUserProfile();
+
+          // access user profile data
+          echo "Ohai there! U are connected with: <b>{$openidauth->id}</b><br />";
+          echo "As: <b>{$user_profile->displayName}</b><br />";
+          echo "And your provider user identifier is: <b>{$user_profile->identifier}</b><br />";
+
+          // or even inspect it
+          echo "<pre>" . print_r( $user_profile, true ) . "</pre><br />";
+
+          // uncomment the line below to get user friends list
+          // $openidauth->getUserContacts();
+
+          // uncomment the line below to post something to openidauth if you want to
+          // $openidauth->setUserStatus( "Hello world!" );
+
+          // ex. on how to access the openidauth api with hybridauth
+          //     Returns the current count of friends, followers, updates (statuses) and favorites of the 
authenticating user.
+          //     https://dev.openidauth.com/docs/api/1/get/account/totals
+          $account_totals = $openidauth->api()->get( 'account/totals.json' );
+
+          // print recived stats
+          echo "Here some of yours stats on Twitter:<br /><pre>" . print_r( $account_totals, true ) . 
"</pre>";
+
+          // logout
+          echo "Logging out..";
+          $openidauth->logout();
+           */
+
+        }
+        catch (Exception $e) {
+          return false;
+        }
+
+        /*TODO
+        if (true) {
+          $is_admin = true;
+        }
+         */
+
+        /*TODO
+        if (true) {
+          // Create a new session for the user
+          $this->create_session($username, $is_admin);
+
+          // Authentication was successful
+          return true;
+        }
+         */
+
+        // Username was not found
+        return false;
+    }
+
     // Method for logging a user out
     function logout()
     {
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 7c2304e..1cb7a81 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -49,6 +49,7 @@ $lang_data = array(
     'save'                  => 'Save',
     'cancel'                => 'Cancel',
     'username'              => 'Username',
+    'openid'                => 'OpenID',
     'sending_status'        => 'Sending status mails for project',
     'sending_result'        => 'Sending result mails for project',
     'status_ok'             => '(Status OK)',
@@ -69,15 +70,14 @@ $lang_data = array(
 
     /* Module: login */
     'reset'                 => 'Reset',
+    'enter_openid'          => 'Please enter your OpenID',
     'enter_user_pw'         => 'Please enter your username and password',
-    'login_error'           => 'Login failed. Please notify the <a href="mailto:kde-soc-mentor-owner kde 
org">' .
-                               'KDE SoC Administrators</a> if the problem persists',
-    'iko_credentials'       => 'Log into [[site_name]] using your <a href="http://identity.kde.org"; 
target="_blank">' .
-                               'KDE Identity</a> credentials:',
+    'login_error'           => 'Login failed! Please notify the <a href="mailto:webmaster gnome org">' .
+                               'webmaster</a> if the problem persists',
+    'iko_credentials'       => 'Log into [[site_name]] using OpenID:',
     'password'              => 'Password',
     'create_account'        => 'Create a new account',
-    'create_account_exp'    => 'Don\'t have an account? In order to log into [[site_name]], you\'ll need to 
create a ' .
-                               'new account on <a href="http://identity.kde.org";>identity.kde.org</a>',
+    'create_account_exp'    => 'Don\'t have an account? In order to log into [[site_name]], you\'ll need an 
OpenID account.',
     'register_iko'          => 'Register on KDE Identity',
     'account_banned'        => 'Your account has been banned by an administrator',
 
diff --git a/modules/mod_login.php b/modules/mod_login.php
index 9055e9b..122e07b 100644
--- a/modules/mod_login.php
+++ b/modules/mod_login.php
@@ -9,7 +9,6 @@ if (!defined('IN_PANDORA')) exit;
 
 // Collect some data
 $username = $core->variable('username', '', false, true);
-$password = $core->variable('password', '');
 $redir_url = $core->variable('r', '');
 $dest_url = !empty($redir_url) ? urldecode($redir_url) : $core->path();
 
@@ -22,14 +21,14 @@ if ($user->is_logged_in)
 // Login data was submitted
 $login_submit = isset($_POST['login']);
 if ($login_submit) {
-    if (!empty($username) && !empty($password)) {
+    if (!empty($username)) {
         // Check if user is banned
         $is_banned = $user->is_banned($username);
 
         // User isn't banned
         if (!$is_banned) {
             // Log in user
-            $login_success = $user->login($username, $password);
+            $login_success = $user->login_openid($username);
 
             // Check if login succeeded
             if ($login_success) {
@@ -44,7 +43,7 @@ if ($login_submit) {
         }
     }
     else {
-        $error_message = $lang->get('enter_user_pw');
+        $error_message = $lang->get('enter_openid');
     }
 }
 
diff --git a/skins/easterngreen/html/tpl_header.html b/skins/easterngreen/html/tpl_header.html
index 9439e7e..03bce69 100644
--- a/skins/easterngreen/html/tpl_header.html
+++ b/skins/easterngreen/html/tpl_header.html
@@ -153,14 +153,12 @@ ocalization variable
                             </ul>
                         </li>
 
-                        <!--TODO
                         <li class="[[guest_visibility]]">
                             <a href="?q=login">
                                 <i class="icon-share-alt"></i>
                                 {{log_in}}
                             </a>
                         </li>
-                        -->
 
                         <li class="[[user_visibility]]">
                             <a href="?q=logout">
diff --git a/skins/easterngreen/html/tpl_login.html b/skins/easterngreen/html/tpl_login.html
index f6ab8a5..ed8f136 100644
--- a/skins/easterngreen/html/tpl_login.html
+++ b/skins/easterngreen/html/tpl_login.html
@@ -10,29 +10,30 @@
 <br />
 
 <div class="control-group">
-    <label class="control-label">{{username}}</label>
+    <label class="control-label">{{openid}}</label>
     <div class="controls">
         <input type="text" name="username" class="input-xlarge" />
     </div>
 </div>
 
+<!--
 <div class="control-group">
     <label class="control-label">{{password}}</label>
     <div class="controls">
         <input type="password" name="password" class="input-xlarge" />
     </div>
 </div>
+-->
 
 <div class="form-actions">
     <button type="submit" name="login" class="btn btn-primary">{{log_in}}</button>
     <button type="reset" class="btn">{{reset}}</button>
 </div>
 
+<!--
 <div class="alert alert-info">
     <h3>{{create_account}}</h3>
     <p>{{create_account_exp}}</p>
-    
-    <a href="https://identity.kde.org/index.php?r=registration/index"; target="_blank" class="btn">
-        {{register_iko}}
-    </a>
-</div>
\ No newline at end of file
+</div>
+-->
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]