This commit is contained in:
Marcin Kurczewski 2013-10-15 20:31:38 +02:00
parent a03d7179ba
commit 23ac43ecac
2 changed files with 13 additions and 14 deletions

View file

@ -84,19 +84,18 @@ class UserController
$this->context->stylesheets []= 'user-view.css';
$this->context->subTitle = $name;
$this->context->suppliedOldPassword = $suppliedOldPassword = InputHelper::get('old-password');
$this->context->suppliedCurrentPassword = $suppliedCurrentPassword = InputHelper::get('current-password');
if (InputHelper::get('remove'))
{
if ($this->context->user->id == $user->id)
{
$suppliedPasswordHash = Model_User::hashPassword($suppliedOldPassword, $user->pass_salt);
$suppliedPasswordHash = Model_User::hashPassword($suppliedCurrentPassword, $user->pass_salt);
if ($suppliedPasswordHash != $user->pass_hash)
throw new SimpleException('Must supply valid password');
}
$user->ownFavoritee = [];
R::store($user);
#R::trashAll(R::findAll('favoritee', 'user_id = ?', [$user->id]));
R::trash($user);
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('index', 'index'));
$this->context->transport->success = true;
@ -123,13 +122,13 @@ class UserController
$this->context->stylesheets []= 'user-view.css';
$this->context->subTitle = $name;
$this->context->suppliedOldPassword = $suppliedOldPassword = InputHelper::get('old-password');
$this->context->suppliedCurrentPassword = $suppliedCurrentPassword = InputHelper::get('current-password');
$this->context->suppliedName = $suppliedName = InputHelper::get('name');
$this->context->suppliedPassword1 = $suppliedPassword1 = InputHelper::get('password1');
$this->context->suppliedPassword2 = $suppliedPassword2 = InputHelper::get('password2');
$this->context->suppliedEmail = $suppliedEmail = InputHelper::get('email');
$this->context->suppliedAccessRank = $suppliedAccessRank = InputHelper::get('access-rank');
$oldPasswordHash = $user->pass_hash;
$currentPasswordHash = $user->pass_hash;
if ($suppliedName != '' and $suppliedName != $user->name)
{
@ -169,9 +168,9 @@ class UserController
{
if ($this->context->user->id == $user->id)
{
$suppliedPasswordHash = Model_User::hashPassword($suppliedOldPassword, $user->pass_salt);
if ($suppliedPasswordHash != $oldPasswordHash)
throw new SimpleException('Must supply valid old password');
$suppliedPasswordHash = Model_User::hashPassword($suppliedCurrentPassword, $user->pass_salt);
if ($suppliedPasswordHash != $currentPasswordHash)
throw new SimpleException('Must supply valid current password');
}
R::store($user);
$this->context->transport->success = true;

View file

@ -164,9 +164,9 @@
<?php if ($this->context->transport->tab == 'edit'): ?>
<form action="<?php echo \Chibi\UrlHelper::route('user', 'edit', ['name' => $this->context->transport->user->name]) ?>" method="post" class="edit aligned" autocomplete="off">
<?php if ($this->context->user->id == $this->context->transport->user->id): ?>
<div class="old-password">
<label class="left" for="old-password">Old password:</label>
<input type="password" name="old-password" id="old-password" placeholder="Old password"/>
<div class="current-password">
<label class="left" for="current-password">Current password:</label>
<input type="password" name="current-password" id="current-password" placeholder="Current password"/>
</div>
<hr>
<?php endif ?>
@ -229,9 +229,9 @@
<form action="<?php echo \Chibi\UrlHelper::route('user', 'delete', ['name' => $this->context->transport->user->name]) ?>" method="post" class="edit aligned" autocomplete="off" data-confirm-text="Are you sure you want to delete your account?">
<?php if ($this->context->user->id == $this->context->transport->user->id): ?>
<div class="old-password">
<label class="left" for="old-password">Old password:</label>
<input type="password" name="old-password" id="old-password" placeholder="Old password"/>
<div class="current-password">
<label class="left" for="current-password">Current password:</label>
<input type="password" name="current-password" id="current-password" placeholder="Current password"/>
</div>
<?php endif ?>