function lemon_auth_login($username, $password, $authorized_url) { $auth = lemon_auth(); if (lemon_auth_logged_in()) { halt(SERVER_ERROR, "User is already logged in."); } $errors = lemon_auth_filter_form($username, $password); if (lemon_auth_is_authorized($username, $password)) { $_SESSION['username'] = $username; redirect_to($authorized_url); } else { $errors[] = "Identifiant ou mot de passe incorrect"; } return $errors; }
function helye_espace_client_files() { $auth = lemon_auth(option('auth_config')); if ($username = lemon_auth_logged_in()) { $is_admin = lemon_auth_is_admin($username); $path = rawurldecode(params(0)); if (!$is_admin && !preg_match("/^{$username}/", $path)) { halt(HTTP_FORBIDDEN); } return _render_file_with_http_cache(file_path(option('private_lemon_tree_root'), $path)); } redirect_to('/espace_client/login'); }