Further work on #62

Added ability to resend activation mail
This commit is contained in:
Marcin Kurczewski 2013-11-16 18:51:34 +01:00
parent 76a60ed5d7
commit 039d56c260
5 changed files with 87 additions and 10 deletions

View file

@ -11,3 +11,20 @@ form.auth p {
text-align: center; text-align: center;
margin: 10px 0; margin: 10px 0;
} }
form.auth .help {
opacity: .5;
margin-top: 1em;
font-size: small;
}
form.auth .help p {
margin: 0;
text-align: left;
}
form.auth .help label+div {
float: left;
}
form.auth .help ul {
margin: 0;
padding: 0;
}

View file

@ -550,4 +550,31 @@ class UserController
AuthController::doReLog(); AuthController::doReLog();
} }
} }
/**
* @route /activation-retry/
*/
public function activationRetryAction()
{
$this->context->subTitle = 'activation retry';
$this->context->stylesheets []= 'auth.css';
$this->context->viewName = 'user-select';
if (InputHelper::get('submit'))
{
$name = InputHelper::get('name');
$user = Model_User::locate($name);
if (empty($user->email_unconfirmed))
{
if (!empty($user->email_confirmed))
throw new SimpleException('E-mail was already confirmed; activation skipped');
else
throw new SimpleException('This user has no e-mail specified; activation cannot proceed');
}
self::sendEmailChangeConfirmation($user);
StatusHelper::success('Activation e-mail resent.');
}
}
} }

View file

@ -4,14 +4,18 @@ class Model_User extends AbstractModel
public static function locate($key, $throw = true) public static function locate($key, $throw = true)
{ {
$user = R::findOne(self::getTableName(), 'name = ?', [$key]); $user = R::findOne(self::getTableName(), 'name = ?', [$key]);
if (!$user) if ($user)
{ return $user;
$user = R::findOne(self::getTableName(), 'LOWER(email_confirmed) = LOWER(?)', [trim($key)]);
if ($user)
return $user;
if ($throw) if ($throw)
throw new SimpleException('Invalid user name "' . $key . '"'); throw new SimpleException('Invalid user name "' . $key . '"');
return null; return null;
} }
return $user;
}
public function getAvatarUrl($size = 32) public function getAvatarUrl($size = 32)
{ {

View file

@ -16,6 +16,8 @@
<div> <div>
<label class="left">&nbsp;</label> <label class="left">&nbsp;</label>
<div class="input-wrapper"> <div class="input-wrapper">
<button type="submit">Log in</button>
&nbsp;
<input type="hidden" name="remember" value="0"/> <input type="hidden" name="remember" value="0"/>
<label> <label>
<input type="checkbox" name="remember" value="1"/> <input type="checkbox" name="remember" value="1"/>
@ -28,8 +30,14 @@
<input type="hidden" name="submit" value="1"/> <input type="hidden" name="submit" value="1"/>
<div class="help">
<label class="left">&nbsp;</label>
<div> <div>
<label class="left"></label> <p>Problems logging in?</p>
<button type="submit">Log in</button> <ul>
<li><a href="<?php echo \Chibi\UrlHelper::route('user', 'activation-retry') ?>">I haven't received activation e-mail</a></li>
<li><a href="<?php echo \Chibi\UrlHelper::route('user', 'registration') ?>">I don't have account</a></li>
</ul>
</div>
</div> </div>
</form> </form>

View file

@ -0,0 +1,21 @@
<?php if ($this->context->transport->success === true): ?>
<?php $this->renderFile('message') ?>
<?php else: ?>
<form action="<?php echo \Chibi\UrlHelper::route($this->context->route->simpleControllerName, $this->context->route->simpleActionName) ?>" method="post" class="auth aligned" autocomplete="off">
<div>
<label class="left">User:</label>
<div class="input-wrapper">
<input name="name" placeholder="Name or e-mail address" type="text"/>
</div>
</div>
<input type="hidden" name="submit" value="1"/>
<?php $this->renderFile('message') ?>
<div>
<label class="left">&nbsp;</label>
<button type="submit">Continue</button>
</div>
</form>
<?php endif ?>