version 1.225, 2018/04/27 20:14:16
|
version 1.229, 2019/04/24 02:00:23
|
Line 1263 sub verify_and_change_colors {
|
Line 1263 sub verify_and_change_colors {
|
# password handler subroutines # |
# password handler subroutines # |
###################################################### |
###################################################### |
sub passwordchanger { |
sub passwordchanger { |
my ($r,$errormessage,$caller,$mailtoken) = @_; |
my ($r,$errormessage,$caller,$mailtoken,$timelimit,$extrafields) = @_; |
# This function is a bit of a mess.... |
# This function is a bit of a mess.... |
# Passwords are encrypted using londes.js (DES encryption) |
# Passwords are encrypted using londes.js (DES encryption) |
$errormessage = ($errormessage || ''); |
$errormessage = ($errormessage || ''); |
Line 1288 sub passwordchanger {
|
Line 1288 sub passwordchanger {
|
$caller = 'preferences'; |
$caller = 'preferences'; |
} |
} |
} elsif ($caller eq 'reset_by_email') { |
} elsif ($caller eq 'reset_by_email') { |
my %data = &Apache::lonnet::tmpget($mailtoken); |
my %data = &Apache::lonnet::tmpget($mailtoken); |
if (keys(%data) == 0) { |
if (keys(%data) == 0) { |
$r->print( |
$r->print( |
'<p class="LC_warning">' |
'<p class="LC_warning">' |
.&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.' |
.&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.' |
,'<a href="/adm/resetpw">','</a>') |
,'<a href="/adm/resetpw">','</a>') |
.'</p>' |
.'</p>' |
); |
); |
return; |
return; |
} |
} |
if (defined($data{time})) { |
if (defined($data{time})) { |
if (time - $data{'time'} < 7200) { |
if (time - $data{'time'} < $timelimit) { |
$user = $data{'username'}; |
$user = $data{'username'}; |
$domain = $data{'domain'}; |
$domain = $data{'domain'}; |
$currentpass = $data{'temppasswd'}; |
$currentpass = $data{'temppasswd'}; |
} else { |
|
$r->print( |
|
'<p class="LC_warning">' |
|
.&mt('Sorry, the token generated when you requested' |
|
.' a password reset has expired.') |
|
.'</p>' |
|
); |
|
return; |
|
} |
|
} else { |
} else { |
$r->print( |
$r->print( |
'<p class="LC_warning">' |
'<p class="LC_warning">' |
.&mt('Sorry, the URL generated when you requested reset of' |
.&mt('Sorry, the token generated when you requested' |
.' your password contained incomplete information.') |
.' a password reset has expired.') |
.'</p>' |
.'</p>' |
); |
); |
return; |
return; |
} |
} |
if (&Apache::lonnet::domain($domain) eq '') { |
} else { |
$domain = $r->dir_config('lonDefDomain'); |
$r->print( |
} |
'<p class="LC_warning">' |
|
.&mt('Sorry, the URL generated when you requested reset of' |
|
.' your password contained incomplete information.') |
|
.'</p>' |
|
); |
|
return; |
|
} |
|
if (&Apache::lonnet::domain($domain) eq '') { |
|
$domain = $r->dir_config('lonDefDomain'); |
|
} |
} else { |
} else { |
$r->print( |
$r->print( |
'<p class="LC_error">' |
'<p class="LC_error">' |
Line 1362 sub passwordchanger {
|
Line 1362 sub passwordchanger {
|
my $jsh=Apache::File->new($include."/londes.js"); |
my $jsh=Apache::File->new($include."/londes.js"); |
$r->print(<$jsh>); |
$r->print(<$jsh>); |
} |
} |
$r->print(&jscript_send($caller)); |
$r->print(&jscript_send($caller,$extrafields)); |
$r->print(<<ENDFORM); |
$r->print(<<ENDFORM); |
$errormessage |
$errormessage |
|
|
Line 1371 $errormessage
|
Line 1371 $errormessage
|
ensure that unencrypted passwords will not be sent out by a |
ensure that unencrypted passwords will not be sent out by a |
crappy browser --> |
crappy browser --> |
ENDFORM |
ENDFORM |
$r->print(&server_form($logtoken,$caller,$mailtoken)); |
$r->print(&server_form($logtoken,$caller,$mailtoken,$extrafields)); |
$r->print(&client_form($caller,\%hexkey,$currentpass,$domain)); |
$r->print(&client_form($caller,\%hexkey,$currentpass,$domain,$extrafields)); |
|
|
# |
# |
return; |
return; |
} |
} |
|
|
sub jscript_send { |
sub jscript_send { |
my ($caller) = @_; |
my ($caller,$extrafields) = @_; |
my $output = qq| |
my $output = qq| |
<script type="text/javascript" language="JavaScript"> |
<script type="text/javascript" language="JavaScript"> |
|
|
Line 1401 sub jscript_send {
|
Line 1401 sub jscript_send {
|
=getCrypted(this.document.client.elements.newpass_2.value); |
=getCrypted(this.document.client.elements.newpass_2.value); |
|; |
|; |
if ($caller eq 'reset_by_email') { |
if ($caller eq 'reset_by_email') { |
$output .= qq| |
if ((ref($extrafields) eq 'HASH') && ($extrafields->{'username'})) { |
|
$output .= qq| |
this.document.pserver.elements.uname.value = |
this.document.pserver.elements.uname.value = |
this.document.client.elements.uname.value; |
this.document.client.elements.uname.value; |
this.document.pserver.elements.udom.value = |
this.document.pserver.elements.udom.value = |
this.document.client.elements.udom.options[this.document.client.elements.udom.selectedIndex].value; |
this.document.client.elements.udom.options[this.document.client.elements.udom.selectedIndex].value; |
|
|; |
|
} |
|
if ((ref($extrafields) eq 'HASH') && ($extrafields->{'email'})) { |
|
$output .= qq| |
this.document.pserver.elements.email.value = |
this.document.pserver.elements.email.value = |
this.document.client.elements.email.value; |
this.document.client.elements.email.value; |
|; |
|; |
|
} |
} |
} |
$ output .= qq| |
$ output .= qq| |
this.document.pserver.submit(); |
this.document.pserver.submit(); |
Line 1419 sub jscript_send {
|
Line 1425 sub jscript_send {
|
} |
} |
|
|
sub client_form { |
sub client_form { |
my ($caller,$hexkey,$currentpass,$defdom) = @_; |
my ($caller,$hexkey,$currentpass,$defdom,$extrafields) = @_; |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'email' => 'E-mail Address', |
'email' => 'E-mail Address', |
'username' => 'Username', |
'username' => 'Username', |
Line 1433 sub client_form {
|
Line 1439 sub client_form {
|
my $output = '<form name="client" action="">' |
my $output = '<form name="client" action="">' |
.&Apache::lonhtmlcommon::start_pick_box(); |
.&Apache::lonhtmlcommon::start_pick_box(); |
if ($caller eq 'reset_by_email') { |
if ($caller eq 'reset_by_email') { |
my $mobileargs; |
if ((ref($extrafields) eq 'HASH') && ($extrafields->{'email'})) { |
(undef,undef,undef,undef,undef,undef,my $clientmobile) = |
$output .= &Apache::lonhtmlcommon::row_title( |
&Apache::loncommon::decode_user_agent(); |
|
if ($clientmobile) { |
|
$mobileargs = 'autocapitalize="off" autocorrect="off" '; |
|
} |
|
$output .= &Apache::lonhtmlcommon::row_title( |
|
'<label for="email">'.$lt{'email'}.'</label>') |
'<label for="email">'.$lt{'email'}.'</label>') |
.'<input type="text" name="email" size="30" '.$mobileargs.'/>' |
.'<input type="text" name="email" size="30" autocapitalize="off" autocorrect="off" />' |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure(); |
.&Apache::lonhtmlcommon::row_title( |
} |
|
if ((ref($extrafields) eq 'HASH') && ($extrafields->{'username'})) { |
|
$output .= &Apache::lonhtmlcommon::row_title( |
'<label for="uname">'.$lt{'username'}.'</label>') |
'<label for="uname">'.$lt{'username'}.'</label>') |
.'<input type="text" name="uname" size="20" '.$mobileargs.'/>' |
.'<input type="text" name="uname" size="20" autocapitalize="off" autocorrect="off" />' |
.'<input type="hidden" name="currentpass" value="'.$currentpass.'" />' |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_title( |
.&Apache::lonhtmlcommon::row_title( |
|
'<label for="udom">'.$lt{'domain'}.'</label>') |
'<label for="udom">'.$lt{'domain'}.'</label>') |
.&Apache::loncommon::select_dom_form($defdom,'udom') |
.&Apache::loncommon::select_dom_form($defdom,'udom') |
.&Apache::lonhtmlcommon::row_closure(); |
.&Apache::lonhtmlcommon::row_closure(); |
|
} |
} else { |
} else { |
$output .= &Apache::lonhtmlcommon::row_title( |
$output .= &Apache::lonhtmlcommon::row_title( |
'<label for="currentpass">'.$lt{'currentpass'}.'</label>') |
'<label for="currentpass">'.$lt{'currentpass'}.'</label>') |
Line 1467 sub client_form {
|
Line 1470 sub client_form {
|
.'<input type="password" name="newpass_2" size="20" />' |
.'<input type="password" name="newpass_2" size="20" />' |
.&Apache::lonhtmlcommon::row_closure(1) |
.&Apache::lonhtmlcommon::row_closure(1) |
.&Apache::lonhtmlcommon::end_pick_box(); |
.&Apache::lonhtmlcommon::end_pick_box(); |
|
if ($caller eq 'reset_by_email') { |
|
$output .= '<input type="hidden" name="currentpass" value="'.$currentpass.'" />'; |
|
} |
$output .= '<p><input type="button" value="'.$lt{'changepass'}.'" onclick="send();" /></p>' |
$output .= '<p><input type="button" value="'.$lt{'changepass'}.'" onclick="send();" /></p>' |
.qq| |
.qq| |
<input type="hidden" name="ukey_cpass" value="$hexkey->{'ukey_cpass'}" /> |
<input type="hidden" name="ukey_cpass" value="$hexkey->{'ukey_cpass'}" /> |
Line 1482 sub client_form {
|
Line 1488 sub client_form {
|
} |
} |
|
|
sub server_form { |
sub server_form { |
my ($logtoken,$caller,$mailtoken) = @_; |
my ($logtoken,$caller,$mailtoken,$extrafields) = @_; |
my $action = '/adm/preferences'; |
my $action = '/adm/preferences'; |
if ($caller eq 'reset_by_email') { |
if ($caller eq 'reset_by_email') { |
$action = '/adm/resetpw'; |
$action = '/adm/resetpw'; |
Line 1493 sub server_form {
|
Line 1499 sub server_form {
|
<input type="hidden" name="currentpass" value="" /> |
<input type="hidden" name="currentpass" value="" /> |
<input type="hidden" name="newpass_1" value="" /> |
<input type="hidden" name="newpass_1" value="" /> |
<input type="hidden" name="newpass_2" value="" /> |
<input type="hidden" name="newpass_2" value="" /> |
|; |
|; |
if ($caller eq 'reset_by_email') { |
if ($caller eq 'reset_by_email') { |
$output .= qq| |
$output .= qq| |
<input type="hidden" name="token" value="$mailtoken" /> |
<input type="hidden" name="token" value="$mailtoken" /> |
|
|; |
|
if ((ref($extrafields) eq 'HASH') && ($extrafields->{'username'})) { |
|
$output .= qq| |
<input type="hidden" name="uname" value="" /> |
<input type="hidden" name="uname" value="" /> |
<input type="hidden" name="udom" value="" /> |
<input type="hidden" name="udom" value="" /> |
|
|; |
|
} |
|
if ((ref($extrafields) eq 'HASH') && ($extrafields->{'email'})) { |
|
$output .= qq| |
<input type="hidden" name="email" value="" /> |
<input type="hidden" name="email" value="" /> |
|
|
|; |
|; |
|
} |
} |
} |
$output .= qq| |
$output .= qq| |
<input type="hidden" name="action" value="verify_and_change_pass" /> |
<input type="hidden" name="action" value="verify_and_change_pass" /> |
Line 1511 sub server_form {
|
Line 1524 sub server_form {
|
} |
} |
|
|
sub verify_and_change_password { |
sub verify_and_change_password { |
my ($r,$caller,$mailtoken) = @_; |
my ($r,$caller,$mailtoken,$ended) = @_; |
my ($user,$domain,$homeserver); |
my ($user,$domain,$homeserver); |
my ($blocked,$blocktext) = |
my ($blocked,$blocktext) = |
&Apache::loncommon::blocking_status('passwd'); |
&Apache::loncommon::blocking_status('passwd'); |
Line 1656 ENDERROR
|
Line 1669 ENDERROR
|
$r->print($message.'<br />'); |
$r->print($message.'<br />'); |
} else { |
} else { |
&print_main_menu($r, $message); |
&print_main_menu($r, $message); |
|
if (ref($ended)) { |
|
$$ended = 1; |
|
} |
} |
} |
} else { |
} else { |
# error error: run in circles, scream and shout |
# error error: run in circles, scream and shout |
Line 1670 ENDERROR
|
Line 1686 ENDERROR
|
&mt("The password for user [_1] was not changed.",'<i>'.$user.'</i>').' '.&mt('Please make sure your old password was entered correctly.'),1); |
&mt("The password for user [_1] was not changed.",'<i>'.$user.'</i>').' '.&mt('Please make sure your old password was entered correctly.'),1); |
$message=&Apache::loncommon::confirmwrapper($message); |
$message=&Apache::loncommon::confirmwrapper($message); |
&print_main_menu($r, $message); |
&print_main_menu($r, $message); |
|
if (ref($ended)) { |
|
$$ended = 1; |
|
} |
} |
} |
} |
} |
return; |
return; |
Line 2253 sub handler {
|
Line 2272 sub handler {
|
['action','wysiwyg','returnurl','refpage']); |
['action','wysiwyg','returnurl','refpage']); |
# |
# |
Apache::lonhtmlcommon::clear_breadcrumbs(); |
Apache::lonhtmlcommon::clear_breadcrumbs(); |
my ($brlink,$brtxt,$brhelp); |
my ($brlink,$brtxt,$brhelp,$ended); |
if (($env{'form.action'} eq 'changerolespref') && ($env{'form.returnurl'} eq '/adm/roles')) { |
if (($env{'form.action'} eq 'changerolespref') && ($env{'form.returnurl'} eq '/adm/roles')) { |
$brlink ='/adm/roles'; |
$brlink ='/adm/roles'; |
$brtxt = 'User Roles'; |
$brtxt = 'User Roles'; |
Line 2280 sub handler {
|
Line 2299 sub handler {
|
help => $brhelp,}); |
help => $brhelp,}); |
if(!exists $env{'form.action'}) { |
if(!exists $env{'form.action'}) { |
&print_main_menu($r); |
&print_main_menu($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changepass'){ |
}elsif($env{'form.action'} eq 'changepass'){ |
&passwordchanger($r); |
&passwordchanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_pass'){ |
}elsif($env{'form.action'} eq 'verify_and_change_pass'){ |
&verify_and_change_password($r,'preferences'); |
&verify_and_change_password($r,'preferences','',\$ended); |
}elsif($env{'form.action'} eq 'changescreenname'){ |
}elsif($env{'form.action'} eq 'changescreenname'){ |
&screennamechanger($r); |
&screennamechanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_screenname'){ |
}elsif($env{'form.action'} eq 'verify_and_change_screenname'){ |
&verify_and_change_screenname($r); |
&verify_and_change_screenname($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changemsgforward'){ |
}elsif($env{'form.action'} eq 'changemsgforward'){ |
&msgforwardchanger($r); |
&msgforwardchanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_msgforward'){ |
}elsif($env{'form.action'} eq 'verify_and_change_msgforward'){ |
Line 2296 sub handler {
|
Line 2317 sub handler {
|
&colorschanger($r); |
&colorschanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_colors'){ |
}elsif($env{'form.action'} eq 'verify_and_change_colors'){ |
&verify_and_change_colors($r); |
&verify_and_change_colors($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changelanguages'){ |
}elsif($env{'form.action'} eq 'changelanguages'){ |
&languagechanger($r); |
&languagechanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_languages'){ |
}elsif($env{'form.action'} eq 'verify_and_change_languages'){ |
&verify_and_change_languages($r); |
&verify_and_change_languages($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changewysiwyg'){ |
}elsif($env{'form.action'} eq 'changewysiwyg'){ |
&wysiwygchanger($r); |
&wysiwygchanger($r); |
}elsif($env{'form.action'} eq 'set_wysiwyg'){ |
}elsif($env{'form.action'} eq 'set_wysiwyg'){ |
&verify_and_change_wysiwyg($r); |
&verify_and_change_wysiwyg($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changediscussions'){ |
}elsif($env{'form.action'} eq 'changediscussions'){ |
&discussionchanger($r); |
&discussionchanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_discussion'){ |
}elsif($env{'form.action'} eq 'verify_and_change_discussion'){ |
&verify_and_change_discussion($r); |
&verify_and_change_discussion($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changerolespref'){ |
}elsif($env{'form.action'} eq 'changerolespref'){ |
&rolesprefchanger($r); |
&rolesprefchanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_rolespref'){ |
}elsif($env{'form.action'} eq 'verify_and_change_rolespref'){ |
&verify_and_change_rolespref($r); |
&verify_and_change_rolespref($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changetexenginepref'){ |
}elsif($env{'form.action'} eq 'changetexenginepref'){ |
&texenginechanger($r); |
&texenginechanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_texengine'){ |
}elsif($env{'form.action'} eq 'verify_and_change_texengine'){ |
&verify_and_change_texengine($r); |
&verify_and_change_texengine($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changeicons'){ |
}elsif($env{'form.action'} eq 'changeicons'){ |
&iconchanger($r); |
&iconchanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_icons'){ |
}elsif($env{'form.action'} eq 'verify_and_change_icons'){ |
&verify_and_change_icons($r); |
&verify_and_change_icons($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changeclicker'){ |
}elsif($env{'form.action'} eq 'changeclicker'){ |
&clickerchanger($r); |
&clickerchanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_clicker'){ |
}elsif($env{'form.action'} eq 'verify_and_change_clicker'){ |
&verify_and_change_clicker($r); |
&verify_and_change_clicker($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'changedomcoord'){ |
}elsif($env{'form.action'} eq 'changedomcoord'){ |
&domcoordchanger($r); |
&domcoordchanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_domcoord'){ |
}elsif($env{'form.action'} eq 'verify_and_change_domcoord'){ |
&verify_and_change_domcoord($r); |
&verify_and_change_domcoord($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'lockwarning'){ |
}elsif($env{'form.action'} eq 'lockwarning'){ |
&lockwarning($r); |
&lockwarning($r); |
}elsif($env{'form.action'} eq 'verify_and_change_locks'){ |
}elsif($env{'form.action'} eq 'verify_and_change_locks'){ |
Line 2336 sub handler {
|
Line 2366 sub handler {
|
&coursedisplaychanger($r); |
&coursedisplaychanger($r); |
}elsif($env{'form.action'} eq 'verify_and_change_coursepage'){ |
}elsif($env{'form.action'} eq 'verify_and_change_coursepage'){ |
&verify_and_change_coursepage($r); |
&verify_and_change_coursepage($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'authorsettings'){ |
}elsif($env{'form.action'} eq 'authorsettings'){ |
&author_space_settings($r); |
&author_space_settings($r); |
}elsif($env{'form.action'} eq 'change_authoring_settings'){ |
}elsif($env{'form.action'} eq 'change_authoring_settings'){ |
&change_authoring_settings($r); |
&change_authoring_settings($r); |
|
$ended = 1; |
}elsif($env{'form.action'} eq 'debugtoggle'){ |
}elsif($env{'form.action'} eq 'debugtoggle'){ |
if (&can_toggle_debug()) { |
if (&can_toggle_debug()) { |
&toggle_debug(); |
&toggle_debug(); |
} |
} |
&print_main_menu($r); |
&print_main_menu($r); |
|
$ended = 1; |
} elsif ($env{'form.action'} eq 'changelockednames') { |
} elsif ($env{'form.action'} eq 'changelockednames') { |
&lockednameschanger($r); |
&lockednameschanger($r); |
} elsif ($env{'form.action'} eq 'verify_and_change_lockednames') { |
} elsif ($env{'form.action'} eq 'verify_and_change_lockednames') { |
&verify_and_change_lockednames($r); |
&verify_and_change_lockednames($r); |
|
$ended = 1; |
} |
} |
|
|
# Properly end the HTML page of all preference pages |
# Properly end the HTML page of all preference pages |
# started in each sub routine |
# started in each sub routine |
# Exception: print_main_menu has its own end_page call |
# Exception: print_main_menu has its own end_page call |
unless (!exists $env{'form.action'} || |
unless ($ended) { |
$env{'form.action'} eq 'debugtoggle') { |
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
|
|