add email to register and also save input status after error

master
Corne Oppelaar 9 years ago
parent 837a990f59
commit 7b8fda4f10
No known key found for this signature in database
GPG Key ID: FF32F66315D2E8E5

@ -37,12 +37,17 @@ class Action extends Show
$newUser = null; $newUser = null;
try { 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) { } catch (\Exception $e) {
$segment->setFlash("error", $e->getMessage()); $segment->setFlash("error", $e->getMessage());
} }
if ($newUser === null) { 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'); return $this->redirect('/install');
} }

@ -32,9 +32,11 @@ class Show extends Main
'hasOpenSsl' => $hasOpenSsl, 'hasOpenSsl' => $hasOpenSsl,
'hasOpenSslExtension' => extension_loaded('openssl'), 'hasOpenSslExtension' => extension_loaded('openssl'),
'hasZipExtension' => extension_loaded('zip'), 'hasZipExtension' => extension_loaded('zip'),
'hostname' => parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST), 'hostname' => $segment->getFlash('hostname', parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST)),
'hostnameWithPort' => $_SERVER['HTTP_HOST'], 'hostnameWithPort' => $segment->getFlash('hostnameWithPort', $_SERVER['HTTP_HOST']),
'error' => $segment->getFlash('error') 'error' => $segment->getFlash('error'),
'username' => $segment->getFlash('username'),
'email' => $segment->getFlash('email')
]; ];
return $this->render('install.html.twig', $data); return $this->render('install.html.twig', $data);

@ -29,6 +29,7 @@ class Action extends Main
if ($loggedUser === null) { if ($loggedUser === null) {
$segment->setFlash("error", "Login failed, username or password are incorrect"); $segment->setFlash("error", "Login failed, username or password are incorrect");
$segment->setFlash('username', $username);
return $this->redirect('/login'); return $this->redirect('/login');
} }

@ -35,6 +35,7 @@ class Show extends Main
/** @var Segment $segment */ /** @var Segment $segment */
$segment = $this->get('session')->getSegment('main'); $segment = $this->get('session')->getSegment('main');
$this->get('twig-vars')->def('username', $segment->getFlash('username'));
$this->get('twig-vars')->def('error', $segment->getFlash('error')); $this->get('twig-vars')->def('error', $segment->getFlash('error'));
return $this->render( return $this->render(

@ -19,6 +19,7 @@ class Action extends Main
$invite = $this->post('invite'); $invite = $this->post('invite');
$username = $this->post('username'); $username = $this->post('username');
$password = $this->post('password'); $password = $this->post('password');
$email = $this->post('email');
/** @var User $user */ /** @var User $user */
$user = $this->get('user'); $user = $this->get('user');
@ -30,12 +31,16 @@ class Action extends Main
$newUser = null; $newUser = null;
try { try {
$newUser = $user->register($invite, $username, $password); $newUser = $user->register($invite, $username, $email, $password);
} catch (\Exception $e) { } catch (\Exception $e) {
$segment->setFlash("error", $e->getMessage()); $segment->setFlash("error", $e->getMessage());
} }
if ($newUser === null) { if ($newUser === null) {
$segment->setFlash('username', $username);
$segment->setFlash('email', $email);
$segment->setFlash('invite', $invite);
return $this->redirect('/register'); return $this->redirect('/register');
} }

@ -9,6 +9,7 @@
namespace Eater\Glim\Handler\Register; namespace Eater\Glim\Handler\Register;
use Aura\Session\Segment;
use Eater\Glim\Handler\Main; use Eater\Glim\Handler\Main;
class Show extends Main class Show extends Main
@ -18,8 +19,11 @@ class Show extends Main
/** @var Segment $segment */ /** @var Segment $segment */
$segment = $this->get('session')->getSegment('main'); $segment = $this->get('session')->getSegment('main');
$this->get('twig-vars')->def('error', $segment->getFlash('error')); return $this->render('register.html.twig', [
'error' => $segment->getFlash('error'),
return $this->render('register.html.twig'); 'username' => $segment->getFlash('username'),
'invite' => $segment->getFlash('invite'),
'email' => $segment->getFlash('email')
]);
} }
} }

@ -55,7 +55,11 @@
<div class="row"> <div class="row">
<div class="form-group"> <div class="form-group">
<label for="username">Username</label> <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>
<div class="form-group"> <div class="form-group">
<label for="password">Password</label> <label for="password">Password</label>

@ -18,7 +18,7 @@
{% endif %} {% endif %}
<form method="post" action="/login"> <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> <br><br>
<input id="password" type="password" placeholder="Password" name="password"> <input id="password" type="password" placeholder="Password" name="password">
<br><br> <br><br>

@ -18,9 +18,11 @@
{% endif %} {% endif %}
<form method="post" action="/register"> <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> <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> <br><br>
<input id="password" type="password" placeholder="Password" name="password"> <input id="password" type="password" placeholder="Password" name="password">
<br><br> <br><br>

Loading…
Cancel
Save