9 include_once (
'FDL/Lib.Dir.php');
10 include_once (
'WHAT/Class.UserToken.php');
12 $action->parent->AddCssRef(
'AUTHENT:loginform.css',
true);
13 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/resizeimg.js");
14 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/geometry.js");
15 $action->parent->addJsRef(
"AUTHENT:loginform.js",
true);
16 $action->lay->set(
'CALLBACK_OK', False);
17 $action->lay->set(
'CALLBACK_NOT_OK', False);
18 $action->lay->set(
'ON_ERROR_CONTACT', $action->
getParam(
'SMTP_FROM'));
20 $token = $au->addRequiredParameter(
"token",
"token number");
21 $uid = $au->addOptionalParameter(
"uid",
"user id");
22 $pwd1 = $au->addOptionalParameter(
"pwd1",
"new password 1");
23 $pwd2 = $au->addOptionalParameter(
"pwd2",
"new password 2");
26 $utok =
new UserToken($action->dbaccess, $token);
28 if (!$utok->isAffected()) {
29 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"no element found for token " . $token);
30 $action->
exitError(_(
"Cannot access interface to change password"));
35 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Token " . $utok->token .
" has expired (expire = " . $utok->expire .
")");
36 $action->
exitError(_(
"Cannot access interface to change password"));
41 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"context not valid");
42 $action->
exitError(_(
"Cannot access interface to change password"));
45 $context = unserialize($utok->context);
46 if (empty($context[
"app"]) || empty($context[
"action"])) {
47 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"context not valid");
48 $action->
exitError(_(
"Cannot access interface to change password"));
51 $u =
new Account(
'', $utok->userid);
52 if (!$u->isAffected()) {
53 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"new Doc(" . $utok->userid .
") returned with error : " . $utok->userid);
54 $action->
exitError(_(
"Cannot access interface to change password"));
58 $action->lay->eset(
"uid", $u->id);
59 $action->lay->eset(
"token", $token);
61 $action->lay->eset(
"username", $u->getDisplayName($u->id));
63 if ($uid == $utok->userid) {
64 if ($pwd1 !=
'' && $pwd2 == $pwd1) {
70 $udoc = new_doc($action->dbaccess, $u->fid);
71 $udoc->disableEditControl();
72 if ($udoc->isAlive()) {
73 $err = $udoc->testForcePassword($pwd1);
75 $u->password_new = $pwd1;
78 $udoc->addHistoryEntry(_(
"Change password by token"));
81 $err = $utok->delete();
83 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"utok->delete() returned with error : " .
$err);
85 authLog(sprintf(
"Change password succeeded for %s [%d]", $u->login, $u->id));
89 $udoc->enableEditControl();
92 $err = _(
"password must not be empty");
94 $err = _(
"the two passwords must be the same");
99 $err = _(
"acking detection : clear token");
104 if (
$err)
authLog(sprintf(
"Fail to change password for %s [%d] : %s", $u->login, $u->id,
$err));
105 else if (!$finish)
authLog(sprintf(
"Try to change password for %s [%d]", $u->login, $u->id));
106 $action->lay->set(
"errortxt",
$err);
107 $action->lay->set(
"ERROR", (
$err !=
''));
108 $action->lay->set(
"finish", $finish);
115 $log =
new Log(
"",
"Authent",
"ChangePassword");
116 $facility = constant(
getParam(
"AUTHENT_LOGFACILITY",
"LOG_AUTH"));
117 $log->wlog(
"S", $txt, NULL, $facility);
static verifyOpenExpire(\UserToken $token)
exitError($texterr, $exit=true, $code="")
getParam($name, $def="")
must be in core or global type
Verify arguments for action function.
static verifyOpenAccess(\UserToken $token)
if($file) if($subject==""&&$file) if($subject=="") $err