1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
<?php
/** External authentication via A-Select for Gforge
*
* This file is part of Gforge
*
* This plugin, like Gforge, is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
global $gfplugins;
require_once $gfplugins.'aselectextauth/include/Aselect.class.php';
class ASelectextauthPlugin extends Plugin {
function ASelectextauthPlugin () {
$this->Plugin() ;
$this->name = "aselectextauth";
$this->hooks[] = "session_set_entry";
}
function CallHook ($hookname, &$params) {
global $HTML ;
switch ($hookname) {
case "session_set_entry":
$Aselect = new Aselect();
$loginname = strtolower($Aselect->getUserName());//Since A-Select UserID is
//not case sensitive we pass it to lower case
$passwd = '' ;
$this->AuthUser($loginname, $passwd) ;
break;
default:
// Forgot something
}
}
function AuthUser ($loginname, $passwd) {
global $feedback;
if(!$loginname) {
return false;
}
$u = user_get_object_by_name ($loginname) ;
if ($u) {
// User exists in DB
if($u->getStatus()=='A'){ //we check if it's active
$user_id = $u->getID();
session_set_new($user_id); //create session cookie
$GLOBALS['aselect_auth_failed']=false;
return true ;
} else {
$GLOBALS['aselect_auth_failed']=true;
return false ;
}
} else {
$GLOBALS['aselect_auth_failed']=true;
return false;
}
}
}
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
|