Files
status-board/source/webui/pages/usercp.php

55 lines
1.9 KiB
PHP

<?php
$main = StatusBoard_Main::instance();
$request = $main->request();
$auth = $main->auth();
$session = $main->session();
$activity = null;
if ($request->exists('do')) {
$activity = $request->get('do');
switch ($activity) {
case 'change-password': {
$current_password = StatusBoard_Main::issetelse($_POST['currentpassword'], 'Sihnon_Exception_InvalidParameters');
$new_password = StatusBoard_Main::issetelse($_POST['newpassword'], 'Sihnon_Exception_InvalidParameters');
$confirm_password = StatusBoard_Main::issetelse($_POST['confirmpassword'], 'Sihnon_Exception_InvalidParameters');
$user = $auth->authenticatedUser();
if ($user->checkPassword($current_password)) {
if ($new_password == $confirm_password) {
$auth->changePassword($new_password);
$messages[] = array(
'severity' => 'success',
'content' => 'The password has been changed successfully.',
);
} else {
$messages[] = array(
'severity' => 'error',
'content' => 'The passwords did not match.',
);
}
} else {
$messages[] = array(
'severity' => 'error',
'content' => 'The current password was incorrect.',
);
}
} break;
default: {
$messages[] = array(
'severity' => 'error',
'content' => "The activity '{$activity}' was not recognised.",
);
} break;
}
$session->set('messages', $messages);
StatusBoard_Page::redirect("usercp/");
}
$this->smarty->assign('activity', $activity);
$this->smarty->assign('messages', $messages);
?>