You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
3.5 KiB
107 lines
3.5 KiB
<?php
|
|
#==============================================================================
|
|
# LTB Self Service Password
|
|
#
|
|
# Copyright (C) 2009 Clement OUDOT
|
|
# Copyright (C) 2009 LTB-project.org
|
|
#
|
|
# This program 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.
|
|
#
|
|
# This program 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.
|
|
#
|
|
# GPL License: http://www.gnu.org/licenses/gpl.txt
|
|
#
|
|
#==============================================================================
|
|
|
|
# This page is called to reset a password when a valid token is found in URL
|
|
|
|
#==============================================================================
|
|
# POST parameters
|
|
#==============================================================================
|
|
# Initiate vars
|
|
$result = "";
|
|
$login = $presetLogin;
|
|
$email = "";
|
|
$firstname = "";
|
|
$lastname = "";
|
|
$token = "";
|
|
$tokenid = "";
|
|
$password = "";
|
|
$ldap = "";
|
|
$userdn = "";
|
|
if (!isset($pwd_forbidden_chars)) { $pwd_forbidden_chars=""; }
|
|
$mail = "";
|
|
$extended_error_msg = "";
|
|
|
|
if (isset($_REQUEST["token"]) and $_REQUEST["token"]) { $token = strval($_REQUEST["token"]); }
|
|
else { $result = "tokenrequired"; }
|
|
|
|
#==============================================================================
|
|
# Get token
|
|
#==============================================================================
|
|
if ( $result === "" ) {
|
|
|
|
# Open session with the token
|
|
if ( $crypt_tokens ) {
|
|
$tokenid = decrypt($token, $keyphrase);
|
|
} else {
|
|
$tokenid = $token;
|
|
}
|
|
|
|
ini_set("session.use_cookies",0);
|
|
ini_set("session.use_only_cookies",1);
|
|
|
|
session_id($tokenid);
|
|
session_name("token");
|
|
session_start();
|
|
$login = $_SESSION['login'];
|
|
$firstname = $_SESSION['firstname'];
|
|
$lastname = $_SESSION['lastname'];
|
|
$email = $_SESSION['email'];
|
|
$password = $_SESSION['password'];
|
|
|
|
if ( !$login ) {
|
|
$result = "tokennotvalid";
|
|
error_log("Unable to open session $tokenid");
|
|
} else if (isset($token_lifetime)) {
|
|
# Manage lifetime with session content
|
|
$tokentime = $_SESSION['time'];
|
|
if ( time() - $tokentime > $token_lifetime ) {
|
|
$result = "tokennotvalid";
|
|
error_log("Token lifetime expired");
|
|
}
|
|
}
|
|
}
|
|
|
|
#==============================================================================
|
|
# Get info
|
|
#==============================================================================
|
|
if ( $result === "" ) {
|
|
|
|
if (isset($_POST["firstname"]) and $_POST["firstname"]) { $firstname = $_POST["firstname"]; }
|
|
else { $result = "firstnamerequired"; }
|
|
|
|
if (isset($_POST["lastname"]) and $_POST["lastname"]) { $lastname = $_POST["lastname"]; }
|
|
else { $result = "lastnamerequired"; }
|
|
|
|
if (isset($_POST["email"]) and $_POST["email"]) { $email = $_POST["email"]; }
|
|
else { $result = "emailrequired"; }
|
|
|
|
if (isset($_POST["password"]) and $_POST["password"]) { $password = $_POST["password"]; }
|
|
else { $result = "passwordrequired"; }
|
|
}
|
|
|
|
system("sudo yunohost user create $login -f $firstname -l $lastname -p '$password' -d yntest.weblibre.ca");
|
|
system("sudo yunohost user update $login --add-mailforward $email");
|
|
|
|
# Delete token if all is ok
|
|
if ( $result === "passwordchanged" ) {
|
|
$_SESSION = array();
|
|
session_destroy();
|
|
}
|