Inclusi js essenziali BugFix LoginManager Creata classe MenuGenerator per ottenere le voci menu in base ai ruoli Incluso sistema di inclusione header in GUIHandler
67 lines
1.6 KiB
PHP
67 lines
1.6 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 13/gen/2016
|
|
*/
|
|
|
|
abstract class LoginManager {
|
|
|
|
/**
|
|
* Restituisce true se la login è avvenuta con successo
|
|
* @param string $login
|
|
* @param string $pass in chiaro
|
|
* @return boolean
|
|
*/
|
|
public static function login($login,$pass){
|
|
$rval = false;
|
|
$dao = GlobalVariables::get("dao");
|
|
|
|
$user = $dao->getFirst(static::getRelatedModel(),array("username"=>$login,"password"=>sha1($pass)));
|
|
|
|
if (!is_null($user) && is_object($user)){
|
|
ASDSessionHandler::setSessionValue(static::getSessionVariableName(), $user);
|
|
|
|
$user->lastConnection = new stdClass();
|
|
$user->lastConnection->date = new MongoDate();
|
|
$user->lastConnection->ip = $_SERVER['REMOTE_ADDR'];
|
|
$dao->save($user);
|
|
$rval = true;
|
|
}
|
|
return $rval;
|
|
}
|
|
|
|
/**
|
|
* Slogga l'utente
|
|
*/
|
|
public static function logout(){
|
|
ASDSessionHandler::unsetSessionValue(static::getSessionVariableName());
|
|
}
|
|
|
|
/**
|
|
* Restituisce true se l'utente è loggato
|
|
* @return bool
|
|
*/
|
|
public static function isLogged(){
|
|
return ASDSessionHandler::sessionValueExists(static::getSessionVariableName());
|
|
}
|
|
|
|
/**
|
|
* Restituisce l'utente loggato
|
|
* @return Model
|
|
*/
|
|
public static function getLogged(){
|
|
return ASDSessionHandler::getSessionValue(static::getSessionVariableName());
|
|
}
|
|
|
|
/**
|
|
* Restituisce il nome della classe model da utilizzare
|
|
* @return string
|
|
*/
|
|
protected static abstract function getRelatedModel();
|
|
/**
|
|
* Restituisce il nome della variabile di sessione da utilizzare
|
|
*/
|
|
protected static abstract function getSessionVariableName();
|
|
}
|
|
|
|
?>
|