diff --git a/src/assets/js/profile.js b/src/assets/js/profile.js index d3978bd5..2d408b51 100644 --- a/src/assets/js/profile.js +++ b/src/assets/js/profile.js @@ -1,14 +1,15 @@ $(function() { $('.ui.calendar').calendar({ - type : 'date', - firstDayOfWeek: 1, - startMode : 'year' + type : 'date', + firstDayOfWeek : 1, + startMode : 'year' }); $('.ui.form').form({ fields: { - 'user-email': 'email', - match: { + 'user-email' : 'email', + 'user-password' : ['minLength[8]', 'empty'], + match : { identifier : 'user-password-repeat', depends : 'user-password', rules : [ diff --git a/src/pages/install.php b/src/pages/install.php index bf67dea1..e56669cb 100644 --- a/src/pages/install.php +++ b/src/pages/install.php @@ -124,7 +124,8 @@ switch ($step) { `password_reset_token` VARCHAR(128) NULL DEFAULT NULL, `password_reset_valid_until` DATETIME NOT NULL DEFAULT NOW(), `last_login` DATETIME NOT NULL DEFAULT NOW(), - `power` INT NOT NULL DEFAULT 0 + `power` INT NOT NULL DEFAULT 0, + `birthdate` DATE NULL DEFAULT NULL );'); $database->query('CREATE INDEX `idx_password` ON `users` (`password`);'); diff --git a/src/pages/profile.php b/src/pages/profile.php index b3a8c20c..45811946 100644 --- a/src/pages/profile.php +++ b/src/pages/profile.php @@ -6,7 +6,32 @@ * @author Jay Trees */ -use wishthis\Page; +use wishthis\{Page, User}; + +if (isset($_POST['user-id'])) { + $set = array(); + + if (!empty($_POST['user-email'])) { + $set[] = '`email` = "' . $_POST['user-email'] . '"'; + } + + if (!empty($_POST['user-password']) && !empty($_POST['user-password-repeat'])) { + $set[] = '`password` = "' . User::generatePassword($_POST['user-password']) . '"'; + } + + if (!empty($_POST['user-birthdate'])) { + $set[] = '`birthdate` = "' . date('Y-m-d', strtotime($_POST['user-birthdate'])) . '"'; + } + + $database + ->query('UPDATE `users` + SET ' . implode(',', $set) . ' + WHERE `id` = ' . $_POST['user-id']); + + session_destroy(); + header('Location: /?page=home'); + die(); +} $page = new Page(__FILE__, __('Profile')); $page->header(); @@ -19,7 +44,9 @@ $page->navigation();

title ?>

-
+ + +
@@ -46,7 +73,11 @@ $page->navigation();
- +