redirect to profile page after first login; informational banner when password is blank; do not enforce password change; rename Home -> Dashboard

This commit is contained in:
Evgeny Gryaznov 2011-04-15 01:24:33 +02:00
parent 68f0e13e09
commit 65b00240d3
17 changed files with 37 additions and 52 deletions

View File

@ -116,12 +116,6 @@ function update_operator($operatorid, $login, $email, $password, $localename, $c
perform_query($query, $link); perform_query($query, $link);
mysql_close($link); mysql_close($link);
// update the session password
if (isset($password))
{
$_SESSION[$mysqlprefix.'operator']['vcpassword']=md5($password);
}
} }
function update_operator_avatar($operatorid, $avatar) function update_operator_avatar($operatorid, $avatar)
@ -241,17 +235,6 @@ function check_login($redirect = true)
return $_SESSION["${mysqlprefix}operator"]; return $_SESSION["${mysqlprefix}operator"];
} }
// Force the admin to set a password after the installation
function force_password($operator)
{
global $webimroot;
if($operator['vcpassword']==md5(''))
{
header("Location: $webimroot/operator/operator.php?op=1");
exit;
}
}
function get_logged_in() function get_logged_in()
{ {
global $mysqlprefix; global $mysqlprefix;

View File

@ -212,7 +212,6 @@ menu.translate=Regionalisieren
menu.updates.content=Auf Nachrichten und Updates prüfen. menu.updates.content=Auf Nachrichten und Updates prüfen.
menu.updates=Updates menu.updates=Updates
my_settings.error.password_match=Die Passwörter stimmen nicht überein my_settings.error.password_match=Die Passwörter stimmen nicht überein
my_settings.error.no_password=Es ist noch kein Passwort für den Administrator gesetzt
no_such_operator=Kein solcher Operator no_such_operator=Kein solcher Operator
operator.group.no_description=<keine Beschreibung> operator.group.no_description=<keine Beschreibung>
operator.groups.intro=Wähle Gruppen nach Operator Qualifikation. operator.groups.intro=Wähle Gruppen nach Operator Qualifikation.

View File

@ -122,6 +122,8 @@ errors.prefix=<li class="error">
errors.required=Please fill "{0}". errors.required=Please fill "{0}".
errors.suffix=</li> errors.suffix=</li>
errors.wrong_field=Please fill "{0}" correctly. errors.wrong_field=Please fill "{0}" correctly.
error.no_password=This is your first time logging in and your password is blank. For security reasons you have to change it.
error.no_password.visit_profile=Visit your <a href="{0}">Profile Page</a>.
features.saved=Features activated features.saved=Features activated
form.field.address.description=Ex: 12.23.45.123 or todo.com form.field.address.description=Ex: 12.23.45.123 or todo.com
form.field.address=Visitor's Address form.field.address=Visitor's Address
@ -236,7 +238,6 @@ menu.profile=Profile
menu.translate=Localize menu.translate=Localize
menu.updates.content=Check for news and updates. menu.updates.content=Check for news and updates.
menu.updates=Updates menu.updates=Updates
my_settings.error.no_password=No Password set for the Administrator
my_settings.error.password_match=Entered passwords do not match my_settings.error.password_match=Entered passwords do not match
no_such_operator=No such operator no_such_operator=No such operator
operator.group.no_description=&lt;no description&gt; operator.group.no_description=&lt;no description&gt;
@ -495,9 +496,9 @@ time.never=Never
time.timeformat=%I:%M %p time.timeformat=%I:%M %p
time.today.at=Today at time.today.at=Today at
time.yesterday.at=Yesterday at time.yesterday.at=Yesterday at
topMenu.admin=Home topMenu.admin=Dashboard
topMenu.logoff=Exit topMenu.logoff=Exit
topMenu.main=Home topMenu.main=Dashboard
topMenu.users.nomenu=without menu topMenu.users.nomenu=without menu
topMenu.users=Visitors topMenu.users=Visitors
translate.direction=Direction: translate.direction=Direction:

View File

@ -26,8 +26,6 @@ require_once('../libs/groups.php');
require_once('../libs/pagination.php'); require_once('../libs/pagination.php');
$operator = check_login(); $operator = check_login();
force_password($operator);
loadsettings(); loadsettings();
$errors = array(); $errors = array();

View File

@ -25,8 +25,6 @@ require_once('../libs/groups.php');
require_once('../libs/getcode.php'); require_once('../libs/getcode.php');
$operator = check_login(); $operator = check_login();
force_password($operator);
loadsettings(); loadsettings();
$imageLocales = get_image_locales_map("../locales"); $imageLocales = get_image_locales_map("../locales");

View File

@ -26,8 +26,6 @@ require_once('../libs/userinfo.php');
require_once('../libs/pagination.php'); require_once('../libs/pagination.php');
$operator = check_login(); $operator = check_login();
force_password($operator);
loadsettings(); loadsettings();
setlocale(LC_TIME, getstring("time.locale")); setlocale(LC_TIME, getstring("time.locale"));

View File

@ -23,7 +23,6 @@ require_once('../libs/common.php');
require_once('../libs/operator.php'); require_once('../libs/operator.php');
$operator = check_login(); $operator = check_login();
force_password($operator);
$link = connect(); $link = connect();
loadsettings_($link); loadsettings_($link);
@ -34,6 +33,8 @@ $page = array(
'version' => $version, 'version' => $version,
'localeLinks' => get_locale_links("$webimroot/operator/index.php"), 'localeLinks' => get_locale_links("$webimroot/operator/index.php"),
'needUpdate' => $settings['dbversion'] != $dbversion, 'needUpdate' => $settings['dbversion'] != $dbversion,
'needChangePassword' => $operator['vcpassword'] == md5(''),
'profilePage' => "$webimroot/operator/operator.php?op=".$operator['operatorid'],
'updateWizard' => "$webimroot/install/", 'updateWizard' => "$webimroot/install/",
'newFeatures' => $settings['featuresversion'] != $featuresversion, 'newFeatures' => $settings['featuresversion'] != $featuresversion,
'featuresPage' => "$webimroot/operator/features.php", 'featuresPage' => "$webimroot/operator/features.php",

View File

@ -33,9 +33,11 @@ if (isset($_POST['login']) && isset($_POST['password'])) {
$operator = operator_by_login($login); $operator = operator_by_login($login);
if ($operator && isset($operator['vcpassword']) && $operator['vcpassword'] == md5($password)) { if ($operator && isset($operator['vcpassword']) && $operator['vcpassword'] == md5($password)) {
$target = isset($_SESSION['backpath']) $target = $password == ''
? $_SESSION['backpath'] ? "$webimroot/operator/operator.php?op=" . $operator['operatorid']
: "$webimroot/operator/index.php"; : (isset($_SESSION['backpath'])
? $_SESSION['backpath']
: "$webimroot/operator/index.php");
login_operator($operator, $remember); login_operator($operator, $remember);
header("Location: $target"); header("Location: $target");

View File

@ -77,6 +77,15 @@ if (isset($_POST['login']) && isset($_POST['password'])) {
exit; exit;
} else { } else {
update_operator($opId, $login, $email, $password, $localname, $commonname); update_operator($opId, $login, $email, $password, $localname, $commonname);
// update the session password
if (isset($password) && $opId == $operator['operatorid']) {
$toDashboard = $operator['vcpassword'] == md5('') && $password != '';
$_SESSION["${mysqlprefix}operator"]['vcpassword'] = md5($password);
if($toDashboard) {
header("Location: $webimroot/operator/index.php");
exit;
}
}
header("Location: $webimroot/operator/operator.php?op=$opId&stored"); header("Location: $webimroot/operator/operator.php?op=$opId&stored");
exit; exit;
} }
@ -96,12 +105,6 @@ if (isset($_POST['login']) && isset($_POST['password'])) {
$errors[] = getlocal("no_such_operator"); $errors[] = getlocal("no_such_operator");
$page['opid'] = topage($opId); $page['opid'] = topage($opId);
} else { } else {
//show an error if the admin password hasn't been set yet.
if ($operator['vcpassword']==md5('') && !isset($_GET['stored']))
{
$errors[] = getlocal("my_settings.error.no_password");
}
$page['formlogin'] = topage($op['vclogin']); $page['formlogin'] = topage($op['vclogin']);
$page['formname'] = topage($op['vclocalename']); $page['formname'] = topage($op['vclocalename']);
$page['formemail'] = topage($op['vcemail']); $page['formemail'] = topage($op['vcemail']);
@ -119,9 +122,10 @@ $canmodify = ($opId == $operator['operatorid'] && is_capable($can_modifyprofile,
$page['stored'] = isset($_GET['stored']); $page['stored'] = isset($_GET['stored']);
$page['canmodify'] = $canmodify ? "1" : ""; $page['canmodify'] = $canmodify ? "1" : "";
$page['needChangePassword'] = $operator['vcpassword'] == md5('');
prepare_menu($operator); prepare_menu($operator);
setup_operator_settings_tabs($opId, 0); setup_operator_settings_tabs($opId, 0);
start_html_output(); start_html_output();
require('../view/agent.php'); require('../view/agent.php');
?> ?>

View File

@ -23,8 +23,6 @@ require_once('../libs/common.php');
require_once('../libs/operator.php'); require_once('../libs/operator.php');
$operator = check_login(); $operator = check_login();
force_password($operator);
if (isset($_GET['act']) && $_GET['act'] == 'del') { if (isset($_GET['act']) && $_GET['act'] == 'del') {
$operatorid = isset($_GET['id']) ? $_GET['id'] : ""; $operatorid = isset($_GET['id']) ? $_GET['id'] : "";

View File

@ -24,7 +24,6 @@ require_once('../libs/operator.php');
require_once('../libs/settings.php'); require_once('../libs/settings.php');
$operator = check_login(); $operator = check_login();
force_password($operator);
$page = array('agentId' => ''); $page = array('agentId' => '');
$errors = array(); $errors = array();

View File

@ -24,7 +24,6 @@ require_once('../libs/chat.php');
require_once('../libs/operator.php'); require_once('../libs/operator.php');
$operator = check_login(); $operator = check_login();
force_password($operator);
setlocale(LC_TIME, getstring("time.locale")); setlocale(LC_TIME, getstring("time.locale"));

View File

@ -119,8 +119,6 @@ function get_auxiliary($s)
} }
$operator = check_login(); $operator = check_login();
force_password($operator);
$source = verifyparam("source", "/^[\w-]{2,5}$/", $default_locale); $source = verifyparam("source", "/^[\w-]{2,5}$/", $default_locale);
$target = verifyparam("target", "/^[\w-]{2,5}$/", $current_locale); $target = verifyparam("target", "/^[\w-]{2,5}$/", $current_locale);

View File

@ -24,7 +24,6 @@ require_once('../libs/operator.php');
require_once('../libs/settings.php'); require_once('../libs/settings.php');
$operator = check_login(); $operator = check_login();
force_password($operator);
$default_extensions = array('mysql', 'gd', 'iconv'); $default_extensions = array('mysql', 'gd', 'iconv');

View File

@ -24,7 +24,6 @@ require_once('../libs/operator.php');
require_once('../libs/groups.php'); require_once('../libs/groups.php');
$operator = check_login(); $operator = check_login();
force_password($operator);
$status = isset($_GET['away']) ? 1 : 0; $status = isset($_GET['away']) ? 1 : 0;

View File

@ -39,15 +39,20 @@ function tpl_content() { global $page, $webimroot, $errors;
<?php <?php
require_once('inc_errors.php'); require_once('inc_errors.php');
?> ?>
<?php if( $page['stored'] ) { ?> <?php if( $page['needChangePassword'] ) { ?>
<div id="formmessage"><?php echo getlocal("error.no_password") ?></div>
<br/>
<?php } else if( $page['stored'] ) { ?>
<div id="formmessage"><?php echo getlocal("data.saved") ?></div> <div id="formmessage"><?php echo getlocal("data.saved") ?></div>
<?php } ?> <?php } ?>
<?php if( $page['opid'] || $page['canmodify'] ) { ?> <?php if( $page['opid'] || $page['canmodify'] ) { ?>
<form name="agentForm" method="post" action="<?php echo $webimroot ?>/operator/operator.php"> <form name="agentForm" method="post" action="<?php echo $webimroot ?>/operator/operator.php">
<input type="hidden" name="opid" value="<?php echo $page['opid'] ?>"/> <input type="hidden" name="opid" value="<?php echo $page['opid'] ?>"/>
<div> <div>
<?php print_tabbar(); ?> <?php if(!$page['needChangePassword']) { print_tabbar(); } ?>
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner"> <div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
<div class="fieldForm"> <div class="fieldForm">
@ -70,7 +75,7 @@ require_once('inc_errors.php');
</div> </div>
<div class="field"> <div class="field">
<div class="flabel"><?php echo getlocal('form.field.password') ?><?php if( !$page['opid'] ) { ?><span class="required">*</span><?php } ?></div> <div class="flabel"><?php echo getlocal('form.field.password') ?><?php if( !$page['opid'] || $page['needChangePassword'] ) { ?><span class="required">*</span><?php } ?></div>
<div class="fvalue"> <div class="fvalue">
<input type="password" name="password" size="40" value="" class="formauth"<?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/> <input type="password" name="password" size="40" value="" class="formauth"<?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div> </div>
@ -79,7 +84,7 @@ require_once('inc_errors.php');
</div> </div>
<div class="field"> <div class="field">
<div class="flabel"><?php echo getlocal('form.field.password_confirm') ?><?php if( !$page['opid'] ) { ?><span class="required">*</span><?php } ?></div> <div class="flabel"><?php echo getlocal('form.field.password_confirm') ?><?php if( !$page['opid'] || $page['needChangePassword'] ) { ?><span class="required">*</span><?php } ?></div>
<div class="fvalue"> <div class="fvalue">
<input type="password" name="passwordConfirm" size="40" value="" class="formauth"<?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/> <input type="password" name="passwordConfirm" size="40" value="" class="formauth"<?php echo $page['canmodify'] ? "" : " disabled=\"disabled\"" ?>/>
</div> </div>

View File

@ -41,8 +41,12 @@ function menuseparator() {
function tpl_content() { global $page, $webimroot, $current_locale, $menuItemsCount, $version; function tpl_content() { global $page, $webimroot, $current_locale, $menuItemsCount, $version;
?> ?>
<br/> <br/>
<?php if( $page['needUpdate'] ) { ?>
<?php if( $page['needChangePassword'] ) { ?>
<div id="formmessage"><?php echo getlocal("error.no_password") ?> <?php echo getlocal2("error.no_password.visit_profile", array($page['profilePage'])) ?></div>
<br/>
<?php } else if( $page['needUpdate'] ) { ?>
<div id="formmessage"><?php echo getlocal2("install.updatedb",array($page['updateWizard'])) ?></div> <div id="formmessage"><?php echo getlocal2("install.updatedb",array($page['updateWizard'])) ?></div>
<br/> <br/>
<?php } else if($page['newFeatures']) { ?> <?php } else if($page['newFeatures']) { ?>