21 include_once (
'FDL/Lib.Dir.php');
22 include_once (
'FDL/freedom_util.php');
24 $submitted_login = $action->
getArgument(
'form_login');
25 $submitted_email = $action->
getArgument(
'form_email');
31 $action->parent->AddCssRef(
'AUTHENT:loginform.css',
true);
32 $action->parent->AddCssRef(
'AUTHENT:submitreqpasswd.css');
33 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/resizeimg.js");
34 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/geometry.js");
35 $action->parent->addJsRef(
"AUTHENT:loginform.js");
37 $action->lay->set(
'FORM_SEND_OK', False);
38 $action->lay->set(
'FORM_SEND_ERROR_INVALID_ARGS', False);
39 $action->lay->set(
'FORM_SEND_ERROR_UNKNOWN', False);
40 $action->lay->set(
'FORM_SEND_ERROR_EXTERNAL_AUTH', False);
41 $action->lay->set(
'ON_ERROR_CONTACT', $action->
getParam(
'SMTP_FROM',
___(
"Address not configured",
"authent")));
42 $action->lay->eSet(
"lang",
$lang);
44 $userdoc = retrieveUserDoc($action, $submitted_login, $submitted_email);
46 if ($userdoc == NULL) {
47 $action->lay->set(
'FORM_SEND_ERROR_INVALID_ARGS', True);
52 $ldapUserFamId =
getIdFromName($action->dbaccess,
'LDAPUSER');
53 if (!in_array(
'freedom', $providerList) || ($ldapUserFamId !==
false && $userdoc->fromid == $ldapUserFamId)) {
54 $action->lay->set(
'FORM_SEND_ERROR_EXTERNAL_AUTH', True);
58 $ret = sendCallback($action, $userdoc);
60 error_log(__FUNCTION__ .
" $ret");
61 $action->lay->set(
'FORM_SEND_ERROR_UNKNOWN', True);
64 $log =
new Log(
"",
"Authent",
"ChangePassword");
65 $facility = constant(
getParam(
"AUTHENT_LOGFACILITY",
"LOG_AUTH"));
66 $txt = sprintf(
"ask change password for %s [%d]", $userdoc->getAccount()->login, $userdoc->getAccount()->id);
67 $log->wlog(
"S", $txt, NULL, $facility);
68 $action->lay->set(
'FORM_SEND_OK', True);
80 $action->lay->set(
'MAILMULTIPLE',
false);
82 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Undefined email and login args.");
88 $s->addFilter(
"us_login = '%s'",
$login);
91 $s->addFilter(
"us_mail = '%s'", $email);
94 $s->setObjectReturn();
95 $s->overrideViewControl();
97 if (
$s->count() <= 0) {
98 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Empty search result");
102 if (
$s->count() > 1) {
103 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Result contains more than 1 element");
105 $action->lay->set(
'MAILMULTIPLE',
true);
111 $uDoc =
$s->getNextDoc();
112 $email = $uDoc->getMail();
114 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Empty us_mail for docid '" . $uDoc->id .
"'");
121 function sendCallback(
Action $action, \Dcp\family\IUser $userdoc)
123 include_once (
'WHAT/Class.UserToken.php');
124 include_once (
"FDL/sendmail.php");
126 $us_mail = $userdoc->getMail();
127 $uid = $userdoc->getRawValue(
"us_whatid");
128 if ($us_mail ==
"") {
129 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Empty us_mail for user " . $uid);
130 return "Empty us_mail for user " . $uid;
134 $token->userid = $uid;
135 $token->token = $token->genToken();
136 $token->setExpiration();
137 $token->expendable = 1;
138 $token->context = serialize(array(
140 "action" =>
"CALLBACKREQPASSWD"
142 $token->description=
___(
"Forget password",
"authent");
143 $err = $token->add();
145 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error token->add() : " .
$err);
148 $err = $token->modify();
150 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " .
"Error token->modify() : " .
$err);
154 $callback_token = $token->getToken();
158 $mt = new_doc($action->dbaccess, $action->GetParam(
"AUTHENT_MAILASKPWD"));
159 if (!$mt->isAlive()) {
160 return sprintf(
"Cannot found mail template from AUTHENT_MAILASKPWD parameter");
162 if (!is_a($mt,
'_MAILTEMPLATE')) {
163 return sprintf(
"AUTHENT_MAILASKPWD parameter not reference a mail template");
166 "LINK_CHANGE_PASSWORD" => sprintf(
"%sguest.php?app=AUTHENT&action=CALLBACKREQPASSWD&token=%s", $action->GetParam(
"CORE_EXTERNURL") , $callback_token)
168 $err = $mt->sendDocument($userdoc, $keys);
if(!function_exists('pgettext')) ___($message, $context="")
submitreqpasswd(Action &$action)
getParam($name, $def="")
must be in core or global type
static getArgument($k, $def= '')
getIdFromName($dbaccess, $name)
if($file) if($subject==""&&$file) if($subject=="") $err
getAuthProviderList($freedomctx="")