function register_login() { session_destroy(); session_start(); $ticket = $_GET["ticket"]; //$service = $_CONFIG['service']; $service = $_GET["service"]; $login = Cas::authenticate($ticket, $service); if ($login == -1) { $_SESSION['auth'] = array("logged" => False, "login_utc" => "", "cas_url" => Cas::getUrl()); return array_merge(array("error" => array("title" => "Connexion refusé", "content" => "Nous n'avons malheureusement pas pu vous authentifier...")), is_logged()); } else { // TODO: Verifier que l'utilisateur en question à des droits de vente. // Sinon on le refuse ^^ ici seulement les vendeurs ont le droit de s'authentifier... $_SESSION['auth'] = array("logged" => True, "login_utc" => $login, "cas_url" => Cas::getUrl()); return array_merge(array("success" => array("title" => "Connexion réussi", "content" => "<br>Bienvenue <b>" . $_SESSION['auth']["login_utc"] . "</b> sur l'interface de réalisation de voeux pour les stages TN09 & TN10")), is_logged()); } }
/** * //login * @return redirect::to */ public function doLogin() { if (!Cas::authenticate()) { return Redirect::to('report.html')->with('msg', Config::get('msg.errorSSO'))->with('alertLevel', 'danger'); } $attributes = Cas::attr(); $statusUvus = stripos($attributes['schacuserstatus'], 'uvus:OK'); //Uvus no valido :) if ($statusUvus == false) { return Redirect::to(route('report.html'))->with('msg', Config::get('msg.uvusNoValido'))->with('alertLevel', 'danger'); } $user = User::where('username', '=', $attributes['uid'])->first(); //No existe user en BD => Primer Acceso if ($this->existsUser($user) == false) { // => registrar acceso $this->registraAcceso($attributes); // => Salva notificación para admins SGR $motivo = 'Nuevo acceso'; $this->salvaNotificacion($attributes, $motivo); // => send mail para admins SGR $sgrMail = new sgrMail(); $sgrMail->notificaRegistroUser($user); //notifica a los administradores designados que hay un nuevo usuario a registrar. // => Redirect report for user return Redirect::to(route('report.html'))->with('msg', Config::get('msg.uvusRegistrado'))->with('alertLevel', 'danger'); } //User existe en BD // Cuenta desactivada :) if ($user->estado == false) { return Redirect::to(route('report.html'))->with('msg', Config::get('msg.uvusNoActivo'))->with('alertLevel', 'danger'); } //Cuenta Caducada :) if (strtotime($user->caducidad) < strtotime(date('Y-m-d'))) { // => Salva notificación para admins SGR $motivo = 'Cuenta caducada'; $this->salvaNotificacion($attributes, $motivo); return Redirect::to(route('report.html'))->with('msg', Config::get('msg.cuentaCaducada'))->with('alertLevel', 'danger'); } //Cuenta OK Auth::loginUsingId($user->id); $sgrUser = new sgrUser($user); return Redirect::to($sgrUser->home()); }
function register_login() { global $_CONFIG; // Déclaration de la variable étant globale session_destroy(); session_start(); if (!isset($_GET["ticket"])) { header('Location: ' . $_CONFIG['cas_url'] . 'login?service=' . $_CONFIG['service']); } else { $ticket = $_GET["ticket"]; $service = $_CONFIG['service']; $login = Cas::authenticate($ticket, $service); if ($login == -1) { $_SESSION['auth'] = array("logged" => False, "login_utc" => "", "cas_url" => Cas::getUrl()); echo $_CONFIG['cas_url'] . 'login?service=' . $_CONFIG['service']; } else { $_SESSION['auth'] = array("logged" => True, "login_utc" => $login, "cas_url" => Cas::getUrl()); } } }
public function loginSso() { \Cas::authenticate(); $api = new ApiController(); $user = $api->_getUserAttributes(\Cas::getCurrentUser()); $_user = User::where('username', $user->username)->first(); if (!$_user) { $_user = new User(); $_user->email = $user->email; $_user->nip = $user->nip; $_user->username = $user->username; $_user->save(); } \Auth::login($_user); return redirect('/'); }
$gingerClient = new GingerClient($_CONFIG["ginger_apikey"], $_CONFIG["ginger_server"]); $app->get('/', function () use($app, $gingerClient, $_CONFIG) { if (isset($_SESSION['username'])) { $userInfo = $gingerClient->getUser($_SESSION["username"]); $app->render('template.php', array("title" => $_CONFIG["title"], "loggedin" => true, "logoutUrl" => $_CONFIG["self_url"] . "logout", "userInfo" => $userInfo, "cotiseUrl" => $_CONFIG["self_url"] . "cotiser")); } else { $app->render('template.php', array("title" => $_CONFIG["title"], "loggedin" => false, "loginUrl" => $_CONFIG["self_url"] . "logincas")); } }); $app->get('/logincas', function () use($app, $payutcClient, $_CONFIG) { if (empty($_GET["ticket"])) { $casUrl = $payutcClient->getCasUrl() . "login?service=" . $_CONFIG["self_url"] . 'logincas'; $app->response->redirect($casUrl, 303); } else { $cas = new Cas($payutcClient->getCasUrl()); $user = $cas->authenticate($_GET["ticket"], $_CONFIG["self_url"] . 'logincas'); $_SESSION['username'] = $user; $app->response->redirect($_CONFIG["self_url"], 303); } }); $app->get('/logout', function () use($app, $_CONFIG, $payutcClient) { session_destroy(); $casUrl = $payutcClient->getCasUrl() . "logout?url=" . $_CONFIG["self_url"]; $app->response->redirect($casUrl, 303); }); $app->get('/cotiser', function () use($app, $gingerClient, $payutcClient, $_CONFIG) { $userInfo = $gingerClient->getUser($_SESSION["username"]); if (!$userInfo->is_cotisant) { $payutcClient->loginApp(array("key" => $_CONFIG["payutc_apikey"])); $vente = $payutcClient->createTransaction(array("items" => json_encode(array(array($_CONFIG["payutc_artid"], 1))), "fun_id" => $_CONFIG["payutc_funid"], "mail" => $userInfo->mail, "return_url" => $_CONFIG["self_url"], "callback_url" => $_CONFIG["self_url"] . "callback?username="******"username"])); $app->response->redirect($vente->url, 303);
<?php if (!isset($_SESSION['user'])) { $cas = new Cas("https://cas.utc.fr/cas/", $accessPath); $user = $cas->authenticate(); if ($user == -1) { $cas->login(); } else { $user['user']; $_SESSION['user'] = $user['user']; include "modele/user/user.php"; if (!mexiste($user['user'])) { $nom = $user['nom']; $prenom = $user['prenom']; $mail = $user['mail']; mnouvel_user($user['user'], $nom, $prenom, $mail, ""); } unset($_GET['ticket']); $url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; $url = strtok($url, '?'); header("Location: " . $url); } }