|
@@ -858,12 +858,10 @@ class Route_Users extends RouteBase {
|
|
|
$usrLogin = V::get('usrLogin', '', $_GET);
|
|
$usrLogin = V::get('usrLogin', '', $_GET);
|
|
|
UI::startContainer();
|
|
UI::startContainer();
|
|
|
try {
|
|
try {
|
|
|
- if (empty($usrLogin)) throw new Exception("Empty user login");
|
|
|
|
|
|
|
+ if (empty($usrLogin)) throw new Exception("Missing user login");
|
|
|
|
|
|
|
|
$usrStorageDB = UserStorageFactory::getStorage('DB');
|
|
$usrStorageDB = UserStorageFactory::getStorage('DB');
|
|
|
- $usrStorageLdap = UserStorageFactory::getStorage('MacOSX');
|
|
|
|
|
if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
|
|
if (!$usrStorageDB) throw new Exception("Error storage DB not exists");
|
|
|
- if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
|
|
|
|
|
|
|
|
|
|
echo UI::h('h4', [], "Synchronizacja do LDAP");
|
|
echo UI::h('h4', [], "Synchronizacja do LDAP");
|
|
|
$usrFrom = $usrStorageDB->getUser($usrLogin);
|
|
$usrFrom = $usrStorageDB->getUser($usrLogin);
|
|
@@ -883,6 +881,54 @@ class Route_Users extends RouteBase {
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ Lib::loadClass('LDAP');
|
|
|
|
|
+ $ldap = LDAP::getInstance();
|
|
|
|
|
+
|
|
|
|
|
+ if (null === $ldap) {
|
|
|
|
|
+ if (User::isAdmin()) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if ('adminUpdatePass' === V::get('_postTask', '', $_POST)) {
|
|
|
|
|
+ $pass = V::get('pass', '', $_POST);
|
|
|
|
|
+ if (strlen($pass) < 8) throw new Exception("Hasło jest za krótkie - wymagane co najmniej 8 znaków");
|
|
|
|
|
+ try {
|
|
|
|
|
+ $affected = DB::getPDO()->update('ADMIN_USERS', 'ADM_ACCOUNT', $usrLogin, [
|
|
|
|
|
+ 'ADM_PASSWD_AES' => hash('sha512', $pass), // Mysql: SHA2('{$pass}', 512)
|
|
|
|
|
+ ]);
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ DBG::log($e);
|
|
|
|
|
+ throw new Exception("Wystąpił problem podczas zmiany hasła");
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($affected < 0) throw new Exception("Wystąpił problem podczas zmiany hasła");
|
|
|
|
|
+ throw new AlertSuccessException("Hasło zostało zmienione");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (AlertSuccessException $e) {
|
|
|
|
|
+ UI::alert('success', $e->getMessage());
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ UI::alert('danger', $e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ echo UI::startDetails([
|
|
|
|
|
+ 'style' => "width:400px; margin:10px auto; border:1px solid #ddd; background-color:#eee",
|
|
|
|
|
+ 'summary.style' => "padding:6px; outline:none; cursor:pointer",
|
|
|
|
|
+ 'content.style' => "padding:6px",
|
|
|
|
|
+ ], [
|
|
|
|
|
+ "Ustaw nowe hasło"
|
|
|
|
|
+ ]);
|
|
|
|
|
+ echo UI::h('form', [ 'method' => "POST", 'action' => "", 'class' => "form-inline" ], [
|
|
|
|
|
+ UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => "adminUpdatePass" ]),
|
|
|
|
|
+ UI::h('input', [ 'type' => "password", 'name' => "pass", 'class' => "form-control" ]),
|
|
|
|
|
+ UI::h('input', [ 'type' => "submit", 'value' => "zapisz", 'class' => "btn btn-primary" ]),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ echo UI::endDetails();
|
|
|
|
|
+
|
|
|
|
|
+ UI::endContainer();
|
|
|
|
|
+ UI::dol();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ throw new Exception("Brak LDAP");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $usrStorageLdap = UserStorageFactory::getStorage('MacOSX');
|
|
|
|
|
+ if (!$usrStorageLdap) throw new Exception("Error storage Ldap not exists");
|
|
|
$this->syncUser($usrLogin, $usrStorageDB, $usrStorageLdap);
|
|
$this->syncUser($usrLogin, $usrStorageDB, $usrStorageLdap);
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
DBG::log($e);
|
|
DBG::log($e);
|