feature/accept-email-and-username-in-forms #77
@ -81,13 +81,11 @@ class LoginController
|
|||||||
|
|
||||||
if (\Container::$request->session()->has('tmp_user_data')) {
|
if (\Container::$request->session()->has('tmp_user_data')) {
|
||||||
$tmpUserData = \Container::$request->session()->get('tmp_user_data');
|
$tmpUserData = \Container::$request->session()->get('tmp_user_data');
|
||||||
|
|
||||||
$data = ['email' => $tmpUserData['email']];
|
|
||||||
} else {
|
} else {
|
||||||
$data = [];
|
$tmpUserData = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HtmlContent('login/signup', $data);
|
return new HtmlContent('login/signup', $tmpUserData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSignupSuccess()
|
public function getSignupSuccess()
|
||||||
@ -173,10 +171,14 @@ class LoginController
|
|||||||
$tmpUser = new User();
|
$tmpUser = new User();
|
||||||
$tmpUser->setPlainPassword(\Container::$request->post('password'));
|
$tmpUser->setPlainPassword(\Container::$request->post('password'));
|
||||||
|
|
||||||
\Container::$request->session()->set('tmp_user_data', [
|
$tmpUserData = ['password_hashed' => $tmpUser->getPassword()];
|
||||||
'email' => \Container::$request->post('email'),
|
if (filter_var(\Container::$request->post('email'), FILTER_VALIDATE_EMAIL) === false) {
|
||||||
'password_hashed' => $tmpUser->getPassword()
|
$tmpUserData['username'] = \Container::$request->post('email');
|
||||||
]);
|
} else {
|
||||||
|
$tmpUserData['email'] = \Container::$request->post('email');
|
||||||
|
}
|
||||||
|
|
||||||
|
\Container::$request->session()->set('tmp_user_data', $tmpUserData);
|
||||||
|
|
||||||
return new JsonContent([
|
return new JsonContent([
|
||||||
'redirect' => [
|
'redirect' => [
|
||||||
|
@ -7,16 +7,25 @@
|
|||||||
<h2>Sign up</h2>
|
<h2>Sign up</h2>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<form id="signupForm" action="/signup" method="post" data-redirect-on-success="/signup/success">
|
<form id="signupForm" action="/signup" method="post" data-redirect-on-success="/signup/success">
|
||||||
<?php if (isset($email)): ?>
|
<?php if (isset($email) || isset($username)): ?>
|
||||||
<p class="justify">No user found with the given email address / username. Sign up with one click!</p>
|
<p class="justify">No user found with the given email address / username. Sign up with one click!</p>
|
||||||
<input type="email" class="text big fullWidth marginTop" name="email" placeholder="Email address" autocomplete="username" value="<?= $email ?>" required>
|
<?php if (isset($email)): ?>
|
||||||
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password confirmation" autocomplete="new-password" required minlength="6" autofocus>
|
<input type="email" class="text big fullWidth marginTop" name="email" placeholder="Email address" autocomplete="username" value="<?= $email ?>" required>
|
||||||
|
<?php else: ?>
|
||||||
|
<input type="email" class="text big fullWidth marginTop" name="email" placeholder="Email address" autocomplete="username" required autofocus>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (isset($username)): ?>
|
||||||
|
<input type="username" class="text big fullWidth marginTop" name="username" placeholder="Username" value="<?= $username ?>">
|
||||||
|
<?php else: ?>
|
||||||
|
<input type="username" class="text big fullWidth marginTop" name="username" placeholder="Username" autofocus>
|
||||||
|
<?php endif; ?>
|
||||||
|
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password confirmation" autocomplete="new-password" required minlength="6">
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" autocomplete="username" required autofocus>
|
<input type="email" class="text big fullWidth" name="email" placeholder="Email address" autocomplete="username" required autofocus>
|
||||||
|
<input type="username" class="text big fullWidth marginTop" name="username" placeholder="Username">
|
||||||
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" autocomplete="new-password" required minlength="6">
|
<input type="password" class="text big fullWidth marginTop" name="password" placeholder="Password" autocomplete="new-password" required minlength="6">
|
||||||
<input type="password" class="text big fullWidth marginTop" name="password_confirm" placeholder="Password confirmation" autocomplete="new-password" minlength="6">
|
<input type="password" class="text big fullWidth marginTop" name="password_confirm" placeholder="Password confirmation" autocomplete="new-password" minlength="6">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<input type="username" class="text big fullWidth marginTop" name="username" placeholder="Username">
|
|
||||||
<?php if (!empty($_ENV['RECAPTCHA_SITEKEY'])): ?>
|
<?php if (!empty($_ENV['RECAPTCHA_SITEKEY'])): ?>
|
||||||
<div class="marginTop">
|
<div class="marginTop">
|
||||||
<div class="g-recaptcha" data-sitekey="<?= $_ENV['RECAPTCHA_SITEKEY'] ?>"></div>
|
<div class="g-recaptcha" data-sitekey="<?= $_ENV['RECAPTCHA_SITEKEY'] ?>"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user