]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/authenticationplugin.php
Merge branch '1.0.x' of git://gitorious.org/statusnet/mainline
[quix0rs-gnu-social.git] / lib / authenticationplugin.php
index 5be3ea5b90795c360f3865e506f9f265b835135d..5e878c155b0ddceb7acc8bb3fe2e979e065db102 100644 (file)
@@ -22,6 +22,7 @@
  * @category  Plugin
  * @package   StatusNet
  * @author    Craig Andrews <candrews@integralblue.com>
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
  */
@@ -39,12 +40,11 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
-
 abstract class AuthenticationPlugin extends Plugin
 {
     //is this plugin authoritative for authentication?
     public $authoritative = false;
-    
+
     //should accounts be automatically created after a successful login attempt?
     public $autoregistration = false;
 
@@ -79,7 +79,7 @@ abstract class AuthenticationPlugin extends Plugin
             $nickname = $username;
         }
         $registration_data = array();
-        $registration_data['nickname'] = $nickname ;
+        $registration_data['nickname'] = $nickname;
         return User::register($registration_data);
     }
 
@@ -101,12 +101,14 @@ abstract class AuthenticationPlugin extends Plugin
     * Used during autoregistration
     * Useful if your usernames are ugly, and you want to suggest
     * nice looking nicknames when users initially sign on
+    * All nicknames returned by this function should be valid
+    *  implementations may want to use common_nicknamize() to ensure validity
     * @param username
     * @return string nickname
     */
     function suggestNicknameForUsername($username)
     {
-        return $username;
+        return common_nicknamize($username);
     }
 
     //------------Below are the methods that connect StatusNet to the implementing Auth plugin------------\\
@@ -129,7 +131,7 @@ abstract class AuthenticationPlugin extends Plugin
             $test_user = User::staticGet('nickname', $suggested_nickname);
             if($test_user) {
                 //someone already exists with the suggested nickname, so used the passed nickname
-                $suggested_nickname = $nickname;
+                $suggested_nickname = common_nicknamize($nickname);
             }
             $test_user = User::staticGet('nickname', $suggested_nickname);
             if($test_user) {
@@ -215,12 +217,14 @@ abstract class AuthenticationPlugin extends Plugin
                         //stop handling of other handlers, because what was requested was done
                         return false;
                     }else{
-                        throw new Exception(_('Password changing failed'));
+                        // TRANS: Exception thrown when a password change fails.
+                        throw new Exception(_('Password changing failed.'));
                     }
                 }else{
                     if($this->authoritative){
                         //since we're authoritative, no other plugin could do this
-                        throw new Exception(_('Password changing failed'));
+                        // TRANS: Exception thrown when a password change fails.
+                        throw new Exception(_('Password changing failed.'));
                     }else{
                         //let another handler try
                         return null;
@@ -230,7 +234,8 @@ abstract class AuthenticationPlugin extends Plugin
         }else{
             if($this->authoritative){
                 //since we're authoritative, no other plugin could do this
-                throw new Exception(_('Password changing is not allowed'));
+                // TRANS: Exception thrown when a password change attempt fails because it is not allowed.
+                throw new Exception(_('Password changing is not allowed.'));
             }
         }
     }
@@ -264,4 +269,3 @@ abstract class AuthenticationPlugin extends Plugin
         return true;
     }
 }
-