add email to register and also save input status after error
This commit is contained in:
parent
837a990f59
commit
7b8fda4f10
9 changed files with 36 additions and 12 deletions
|
@ -37,12 +37,17 @@ class Action extends Show
|
|||
$newUser = null;
|
||||
|
||||
try {
|
||||
$newUser = $user->createSuperuser($this->post('username'), $this->post('password'));
|
||||
$newUser = $user->createSuperuser($this->post('username'), $this->post('email'), $this->post('password'));
|
||||
} catch (\Exception $e) {
|
||||
$segment->setFlash("error", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($newUser === null) {
|
||||
$segment->setFlash('email', $this->post('email'));
|
||||
$segment->setFlash('username', $this->post('username'));
|
||||
$segment->setFlash('hostnameWithPort', $this->post('domainWithPort'));
|
||||
$segment->setFlash('hostname', $caCN);
|
||||
|
||||
return $this->redirect('/install');
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,11 @@ class Show extends Main
|
|||
'hasOpenSsl' => $hasOpenSsl,
|
||||
'hasOpenSslExtension' => extension_loaded('openssl'),
|
||||
'hasZipExtension' => extension_loaded('zip'),
|
||||
'hostname' => parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST),
|
||||
'hostnameWithPort' => $_SERVER['HTTP_HOST'],
|
||||
'error' => $segment->getFlash('error')
|
||||
'hostname' => $segment->getFlash('hostname', parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST)),
|
||||
'hostnameWithPort' => $segment->getFlash('hostnameWithPort', $_SERVER['HTTP_HOST']),
|
||||
'error' => $segment->getFlash('error'),
|
||||
'username' => $segment->getFlash('username'),
|
||||
'email' => $segment->getFlash('email')
|
||||
];
|
||||
|
||||
return $this->render('install.html.twig', $data);
|
||||
|
|
|
@ -29,6 +29,7 @@ class Action extends Main
|
|||
|
||||
if ($loggedUser === null) {
|
||||
$segment->setFlash("error", "Login failed, username or password are incorrect");
|
||||
$segment->setFlash('username', $username);
|
||||
|
||||
return $this->redirect('/login');
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ class Show extends Main
|
|||
/** @var Segment $segment */
|
||||
$segment = $this->get('session')->getSegment('main');
|
||||
|
||||
$this->get('twig-vars')->def('username', $segment->getFlash('username'));
|
||||
$this->get('twig-vars')->def('error', $segment->getFlash('error'));
|
||||
|
||||
return $this->render(
|
||||
|
|
|
@ -19,6 +19,7 @@ class Action extends Main
|
|||
$invite = $this->post('invite');
|
||||
$username = $this->post('username');
|
||||
$password = $this->post('password');
|
||||
$email = $this->post('email');
|
||||
|
||||
/** @var User $user */
|
||||
$user = $this->get('user');
|
||||
|
@ -30,12 +31,16 @@ class Action extends Main
|
|||
$newUser = null;
|
||||
|
||||
try {
|
||||
$newUser = $user->register($invite, $username, $password);
|
||||
$newUser = $user->register($invite, $username, $email, $password);
|
||||
} catch (\Exception $e) {
|
||||
$segment->setFlash("error", $e->getMessage());
|
||||
}
|
||||
|
||||
if ($newUser === null) {
|
||||
$segment->setFlash('username', $username);
|
||||
$segment->setFlash('email', $email);
|
||||
$segment->setFlash('invite', $invite);
|
||||
|
||||
return $this->redirect('/register');
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
namespace Eater\Glim\Handler\Register;
|
||||
|
||||
|
||||
use Aura\Session\Segment;
|
||||
use Eater\Glim\Handler\Main;
|
||||
|
||||
class Show extends Main
|
||||
|
@ -18,8 +19,11 @@ class Show extends Main
|
|||
/** @var Segment $segment */
|
||||
$segment = $this->get('session')->getSegment('main');
|
||||
|
||||
$this->get('twig-vars')->def('error', $segment->getFlash('error'));
|
||||
|
||||
return $this->render('register.html.twig');
|
||||
return $this->render('register.html.twig', [
|
||||
'error' => $segment->getFlash('error'),
|
||||
'username' => $segment->getFlash('username'),
|
||||
'invite' => $segment->getFlash('invite'),
|
||||
'email' => $segment->getFlash('email')
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -55,7 +55,11 @@
|
|||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input id="username" class="form-control" type="text" name="username">
|
||||
<input value="{{ username }}" id="username" class="form-control" type="text" name="username">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">E-mail</label>
|
||||
<input value="{{ email }}" id="email" class="form-control" type="text" name="email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Password</label>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
{% endif %}
|
||||
|
||||
<form method="post" action="/login">
|
||||
<input id="username" type="text" placeholder="Username" name="username">
|
||||
<input value="{{ username }}" id="username" type="text" placeholder="Username" name="username">
|
||||
<br><br>
|
||||
<input id="password" type="password" placeholder="Password" name="password">
|
||||
<br><br>
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
{% endif %}
|
||||
|
||||
<form method="post" action="/register">
|
||||
<input id="invite" type="text" placeholder="Invitation code" name="invite">
|
||||
<input id="invite" type="text" placeholder="Invitation code" value="{{ invite }}" name="invite">
|
||||
<br><br>
|
||||
<input id="username" type="text" placeholder="Your username" name="username">
|
||||
<input id="email" type="text" value="{{ email }}" placeholder="Your e-mail" name="email">
|
||||
<br><br>
|
||||
<input id="username" type="text" value="{{ username }}" placeholder="Your username" name="username">
|
||||
<br><br>
|
||||
<input id="password" type="password" placeholder="Password" name="password">
|
||||
<br><br>
|
||||
|
|
Loading…
Reference in a new issue