Changeset 1330

Show
Ignore:
Timestamp:
03/02/08 14:24:55 (7 months ago)
Author:
benoitg
Message:
  • Fix #431: Don't even display the Signup button if none of the networks allow signing up. Allow Authenticators to define the signup URL themselves.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/CHANGELOG

    r1329 r1330  
    11# $Id$ 
     22008-03-02 Benoit GrĂ©goire  <bock@step.polymtl.ca> 
     3        * Fix #431: Don't even display the Signup button if none of the networks allow signing up.  Allow Authenticators to define the signup URL themselves. 
    24 
    352008-02-27 Damien Raude-Morvan <drazzib@drazzib.com> 
  • trunk/wifidog-auth/wifidog/classes/Authenticator.php

    r1304 r1330  
    151151        $smarty->assign('error', self::$_loginLastError); 
    152152 
     153        // Check if one of the network allow signup 
     154        $network_array=Network::getAllNetworks(); 
     155 
     156        $networksAllowingSignup = null; 
     157        foreach ($network_array as $network) { 
     158            if ($network->getAuthenticator()->isRegistrationPermitted()) { 
     159                $networksAllowingSignup[] = $network; 
     160            } 
     161        } 
     162        //pretty_print_r($networksAllowingSignup); 
     163        if (count($networksAllowingSignup)>0){ 
     164            //FIXME:  This is far from ideal, it assumes that all networks use the same signup URL, or that only one network allows signup.   
     165            $smarty->assign('signupUrl', $networksAllowingSignup[0]->getAuthenticator()->getSignupUrl()); 
     166        } 
    153167        // Compile HTML code 
    154         $html = self::ArrayToHiddenInput($_POST);//This must remain BEFORE the actual form 
     168        $html = self::ArrayToHiddenInput($_POST);//This must remain BEFORE the actual form. It allws repeating the request if the login attempt is causes by a session timeout or insufficient permissions. 
    155169        $html .= $smarty->fetch("templates/classes/Authenticator_getLoginForm.tpl"); 
    156170        return $html; 
     
    342356     * @return bool Returns if the class allows registration 
    343357     */ 
    344     public function isRegistrationPermitted() 
    345     { 
    346         return false; 
    347     } 
    348  
     358    final public function isRegistrationPermitted() 
     359    { 
     360        return $this->getSignupUrl()?true:false; 
     361    } 
     362    /** 
     363     * If the authenticator allows new users to register new account, this must return the URL at which they must do so. 
     364     * 
     365     * @return text The URL to register at or NULL.  NULL means that the Authenticator does not allow new users to self-register. 
     366     */ 
     367    public function getSignupUrl() 
     368    { 
     369        return null; 
     370    } 
    349371} 
    350372 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUser.php

    r1304 r1330  
    208208 
    209209    /** 
    210      * The basic AuthenticatorLocalUser allows user signup 
    211      * 
    212      * @return bool Returns if the class allows registration 
    213      */ 
    214     public function isRegistrationPermitted() 
    215     { 
    216         return true
     210     * If the authenticator allows new users to register new account, this must return the URL at which they must do so. 
     211     * 
     212     * @return text The URL to register at or NULL.  NULL means that the Authenticator does not allow new users to self-register. 
     213     */ 
     214    public function getSignupUrl() 
     215    { 
     216        return BASE_NON_SSL_PATH.'signup.php'
    217217    } 
    218218 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUserNoSignup.php

    r1090 r1330  
    6060{ 
    6161    /** 
    62      * The AuthenticatorLocalUserNoSignup does not allow user signup 
     62     * If the authenticator allows new users to register new account, this must return the URL at which they must do so. 
    6363     * 
    64      * @return bool Returns if the class allows registration 
     64     * @return text The URL to register at or NULL.  NULL means that the Authenticator does not allow new users to self-register. 
    6565     */ 
    66     function isRegistrationPermitted() 
     66    public function getSignupUrl() 
    6767    { 
    68         return false
     68        return null
    6969    } 
    7070 
  • trunk/wifidog-auth/wifidog/templates/classes/Authenticator_getLoginForm.tpl

    r1297 r1330  
    6868 
    6969            <input class="submit" type="submit" tabindex="3" name="login_form_submit" value="{"Login"|_}" onclick="return validateForm(this.form);"/>&nbsp; 
    70             <input class="submit" type="submit" tabindex="4" name="form_signup" value="{"Create a free account"|_}" onclick="location.href='{$base_ssl_path}signup.php';" /> 
    71     <script type="text/javascript"> 
     70            {if $signupUrl} 
     71                           <input class="submit" type="submit" tabindex="4" name="form_signup" value="{"Create a free account"|_}" onclick="location.href='{$signupUrl}';" /> 
     72            {/if} 
     73            <script type="text/javascript"> 
    7274        <!-- 
    7375                {literal}