bludit/bl-kernel/admin/controllers/user-password.php

51 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2015-11-07 01:23:50 +01:00
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Functions
// ============================================================================
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
2018-05-15 20:12:15 +02:00
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Prevent non-administrators to change other users
$username = $_POST['username'];
if ($login->role()!=='admin') {
$username = $login->username();
}
2018-05-15 20:12:15 +02:00
if (changeUserPassword(array(
'username'=>$username,
2018-05-15 20:12:15 +02:00
'newPassword'=>$_POST['newPassword'],
'confirmPassword'=>$_POST['confirmPassword']
))) {
2018-11-09 00:59:06 +01:00
if ($login->role()==='admin') {
Redirect::page('users');
}
Redirect::page('edit-user/'.$login->username());
2015-11-07 01:23:50 +01:00
}
}
// ============================================================================
// Main after POST
// ============================================================================
2018-05-15 20:12:15 +02:00
// Prevent non-administrators to change other users
if ($login->role()!=='admin') {
$layout['parameters'] = $login->username();
2015-11-07 01:23:50 +01:00
}
2018-07-25 23:42:00 +02:00
try {
$username = $layout['parameters'];
$user = new User($username);
} catch (Exception $e) {
Redirect::page('users');
2015-11-07 01:23:50 +01:00
}
// Title of the page
$layout['title'] = $L->g('Change password').' - '.$layout['title'];