Rename user sign up to registration

This commit is contained in:
Igor Scheller 2023-11-12 17:40:21 +01:00
parent 6564056f16
commit 9e3adf6179
16 changed files with 77 additions and 83 deletions

View File

@ -233,8 +233,8 @@ return [
// Users are able to sign up
'registration_enabled' => (bool) env('REGISTRATION_ENABLED', true),
// Required fields on sign-up page
'signup_required_fields' => [
// Required user fields
'required_user_fields' => [
'pronoun' => (bool) env('PRONOUN_REQUIRED', false),
'firstname' => (bool) env('FIRSTNAME_REQUIRED', false),
'lastname' => (bool) env('LASTNAME_REQUIRED', false),

View File

@ -8,8 +8,8 @@ use FastRoute\RouteCollector;
// Pages
$route->get('/', 'HomeController@index');
$route->get('/register', 'SignUpController@view');
$route->post('/register', 'SignUpController@save');
$route->get('/register', 'RegistrationController@view');
$route->post('/register', 'RegistrationController@save');
$route->get('/credits', 'CreditsController@index');
$route->get('/health', 'HealthController@index');

View File

@ -174,7 +174,7 @@ function Users_view(
unset($user_table_headers[$key]);
}
$link = button(url('register'), icon('plus-lg'), 'add');
$link = button(url('/register'), icon('plus-lg'), 'add');
return page_with_title(__('All users') . ' ' . $link, [
msg(),
table($user_table_headers, $usersList),
@ -954,7 +954,7 @@ function render_user_tshirt_hint()
$goodie_tshirt = $goodie === GoodieType::Tshirt;
if (
$goodie_tshirt
&& config('signup_required_fields')['tshirt_size']
&& config('required_user_fields')['tshirt_size']
&& !auth()->user()->personalData->shirt_size
) {
$text = __('You need to specify a tshirt size in your settings!');

View File

@ -274,3 +274,9 @@ msgstr "Ort erfolgreich gelöscht."
msgid "validation.name.exists"
msgstr "Der Name wird bereits verwendet."
msgid "registration.disabled"
msgstr "Die Registrierung ist deaktiviert."
msgid "registration.successful"
msgstr "Registrierung erfolgreich. Du kannst dich jetzt anmelden!"

View File

@ -1988,23 +1988,17 @@ msgstr "Tag %1$d"
msgid "dashboard.day"
msgstr "Tag"
msgid "page.sign-up.title"
msgstr "Engelregistrierung"
msgid "registration.title"
msgstr "Engel-Registrierung"
msgid "page.sign-up.login-data"
msgid "registration.login_data"
msgstr "Anmeldedaten"
msgid "page.sign-up.event-data"
msgid "registration.event_data"
msgstr "Eventdaten"
msgid "page.sign-up.what-do-you-want-to-do"
msgid "registration.what_todo"
msgstr "Was möchtest Du machen?"
msgid "page.sign-up.sign-up"
msgid "registration.register"
msgstr "Registrieren"
msgid "pages.sign-up.disabled"
msgstr "Die Engelregistrierung ist deaktiviert"
msgid "pages.sign-up.successful"
msgstr "Engelregistrierung erfolgreich! Du kannst dich jetzt anmelden!"

View File

@ -273,3 +273,9 @@ msgstr "Location successfully deleted."
msgid "validation.name.exists"
msgstr "The name is already used."
msgid "registration.disabled"
msgstr "The registration is disabled."
msgid "registration.successful"
msgstr "Registration successful. You can now log in!"

View File

@ -576,23 +576,17 @@ msgstr "Day %1$d"
msgid "dashboard.day"
msgstr "Day"
msgid "page.sign-up.title"
msgid "registration.title"
msgstr "Angel registration"
msgid "page.sign-up.login-data"
msgid "registration.login_data"
msgstr "Login data"
msgid "page.sign-up.event-data"
msgid "registration.event_data"
msgstr "Event data"
msgid "page.sign-up.what-do-you-want-to-do"
msgid "registration.what_todo"
msgstr "What do you want to do?"
msgid "page.sign-up.sign-up"
msgid "registration.register"
msgstr "Register"
msgid "pages.sign-up.disabled"
msgstr "The angel registration is disabled"
msgid "pages.sign-up.successful"
msgstr "Angel registration success. You can now log in."

View File

@ -2,7 +2,7 @@
{% import 'macros/base.twig' as m %}
{% import 'macros/form.twig' as f %}
{% block title %}{{ __('page.sign-up.title') }}{% endblock %}
{% block title %}{{ __('registration.title') }}{% endblock %}
{% block content %}
<div class="container">
@ -12,7 +12,7 @@
? m.button(m.icon('chevron-left'), url('/users'), null, 'sm')
: ''
}}
{{ __('page.sign-up.title') }}
{{ __('registration.title') }}
</h1>
</div>
@ -22,7 +22,7 @@
{{ csrf() }}
<div class="mb-5">
<h2>{{ __('page.sign-up.login-data') }}</h2>
<h2>{{ __('registration.login_data') }}</h2>
<div class="row">
{% if isPronounEnabled %}
<div class="col-md-6">
@ -188,7 +188,7 @@
{% endif %}
<div class="mb-5">
<h2>{{ __('page.sign-up.event-data') }}</h2>
<h2>{{ __('registration.event_data') }}</h2>
<div class="row">
{% if isGoodieEnabled %}
<div class="col-md-6">
@ -284,7 +284,7 @@
</div>
<div class="mb-5">
<h2>{{ __('page.sign-up.what-do-you-want-to-do') }}</h2>
<h2>{{ __('registration.what_todo') }}</h2>
<div class="row mb-3">
{% for angelType in angelTypes %}
<div class="col-sm-6 col-md-4 col-lg-3 col-xl-2">
@ -318,7 +318,7 @@
By assigning a name here, some magic™ will create a session var
"form-data-register-submit" with the value 1 on submit.
#}
{{ f.submit(__('page.sign-up.sign-up'), {
{{ f.submit(__('registration.register'), {
'name': 'register-submit',
}) }}
</form>

View File

@ -15,7 +15,7 @@ use Engelsystem\Http\Response;
use Engelsystem\Models\AngelType;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class SignUpController extends BaseController
class RegistrationController extends BaseController
{
use HasUserNotifications;
@ -48,7 +48,7 @@ class SignUpController extends BaseController
$rawData = $request->getParsedBody();
$user = $this->userFactory->createFromData($rawData);
$this->addNotification('pages.sign-up.successful');
$this->addNotification('registration.successful');
if ($this->config->get('welcome_msg')) {
// Set a session marker to display the welcome message on the next page
@ -71,7 +71,7 @@ class SignUpController extends BaseController
private function notifySignUpDisabledAndRedirectToHome(): Response
{
$this->addNotification('pages.sign-up.disabled', NotificationType::INFORMATION);
$this->addNotification('registration.disabled', NotificationType::INFORMATION);
return $this->redirect->to('/');
}
@ -79,7 +79,7 @@ class SignUpController extends BaseController
{
$goodieType = GoodieType::from($this->config->get('goodie_type'));
$preselectedAngelTypes = $this->determinePreselectedAngelTypes();
$requiredFields = $this->config->get('signup_required_fields');
$requiredFields = $this->config->get('required_user_fields');
// form-data-register-submit is a marker, that the form was submitted.
// It will be used for instance to use the default angel types or the user selected ones.
@ -87,7 +87,7 @@ class SignUpController extends BaseController
$this->session->remove('form-data-register-submit');
return $this->response->withView(
'pages/sign-up',
'pages/registration',
[
'tShirtSizes' => $this->config->get('tshirt_sizes'),
'angelTypes' => AngelType::whereHideRegister(false)->get(),

View File

@ -35,7 +35,7 @@ class SettingsController extends BaseController
public function profile(): Response
{
$user = $this->auth->user();
$requiredFields = $this->config->get('signup_required_fields');
$requiredFields = $this->config->get('required_user_fields');
return $this->response->withView(
'pages/settings/profile',
@ -368,7 +368,7 @@ class SettingsController extends BaseController
private function isRequired(string $key): string
{
$requiredFields = $this->config->get('signup_required_fields');
$requiredFields = $this->config->get('required_user_fields');
return $requiredFields[$key] ? 'required' : 'optional';
}

View File

@ -40,7 +40,7 @@ class User
* Takes some arbitrary data, validates it and tries to create a user from it.
*
* @param Array<string, mixed> $rawData Raw data from which a user should be created
* @return The user if successful
* @return EngelsystemUser The user if successful
* @throws
*/
public function createFromData(array $rawData): EngelsystemUser
@ -69,7 +69,7 @@ class User
private function isRequired(string $key): string
{
$requiredFields = $this->config->get('signup_required_fields');
$requiredFields = $this->config->get('required_user_fields');
return $requiredFields[$key] ? 'required' : 'optional';
}

View File

@ -6,7 +6,7 @@ namespace Engelsystem\Test\Feature\Controllers;
use Engelsystem\Application;
use Engelsystem\Config\Config;
use Engelsystem\Controllers\SignUpController;
use Engelsystem\Controllers\RegistrationController;
use Engelsystem\Events\Listener\OAuth2;
use Engelsystem\Models\AngelType;
use Engelsystem\Models\BaseModel;
@ -17,9 +17,9 @@ use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
/**
* @group sign-up-controller-tests
* @group registration-controller-tests
*/
final class SignUpControllerTest extends ApplicationFeatureTest
final class RegistrationControllerTest extends ApplicationFeatureTest
{
private Application $application;
private Config $config;
@ -32,7 +32,7 @@ final class SignUpControllerTest extends ApplicationFeatureTest
* @var Array<BaseModel>
*/
private array $modelsToBeDeleted;
private SignUpController $subject;
private RegistrationController $subject;
public function setUp(): void
{
@ -45,7 +45,7 @@ final class SignUpControllerTest extends ApplicationFeatureTest
$this->application->instance(OAuth2::class, $this->oauth);
$this->config = $this->application->get(Config::class);
$this->session = $this->application->get(SessionInterface::class);
$this->subject = $this->application->make(SignUpController::class);
$this->subject = $this->application->make(RegistrationController::class);
}
public function tearDown(): void
@ -55,10 +55,10 @@ final class SignUpControllerTest extends ApplicationFeatureTest
}
/**
* Renders the sign-up page with a minimum fields config.
* Renders the registration page with a minimum fields config.
* Asserts that the basic fields are there while the other fields are not there.
*
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testViewMinimumConfig(): void
{
@ -87,10 +87,10 @@ final class SignUpControllerTest extends ApplicationFeatureTest
}
/**
* Renders the sign-up page with a maximum fields config.
* Renders the registration page with a maximum fields config.
* Asserts that all fields are there.
*
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testViewMaximumConfig(): void
{
@ -117,7 +117,7 @@ final class SignUpControllerTest extends ApplicationFeatureTest
}
/**
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testViewAngelTypesOAuthPreselection(): void
{
@ -154,7 +154,7 @@ final class SignUpControllerTest extends ApplicationFeatureTest
}
/**
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testViewAngelTypesPreselection(): void
{
@ -180,7 +180,7 @@ final class SignUpControllerTest extends ApplicationFeatureTest
/**
* Asserts that values are prefilled after submit
*
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testViewValuesAfterSubmit(): void
{
@ -207,7 +207,7 @@ final class SignUpControllerTest extends ApplicationFeatureTest
* Creates three angel types:
* - unrestricted
* - restricted
* - unrestricted, hidden on sign-up
* - unrestricted, hidden on registration
*
* @return Array<AngelType>
*/

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Engelsystem\Test\Unit\Controllers;
use Engelsystem\Controllers\SignUpController;
use Engelsystem\Controllers\RegistrationController;
use Engelsystem\Factories\User;
use Engelsystem\Helpers\Authenticator;
use Engelsystem\Models\OAuth;
@ -12,9 +12,9 @@ use Engelsystem\Models\User\User as EngelsystemUser;
use PHPUnit\Framework\MockObject\MockObject;
/**
* @group sign-up-controller-tests
* @group registration-controller-tests
*/
final class SignUpControllerTest extends ControllerTest
final class RegistrationControllerTest extends ControllerTest
{
/**
* @var Authenticator&MockObject
@ -26,7 +26,7 @@ final class SignUpControllerTest extends ControllerTest
*/
private User $userFactory;
private SignUpController $subject;
private RegistrationController $subject;
public function setUp(): void
{
@ -44,11 +44,11 @@ final class SignUpControllerTest extends ControllerTest
->getMock();
$this->config->set('oauth', []);
$this->app->instance(User::class, $this->userFactory);
$this->subject = $this->app->make(SignUpController::class);
$this->subject = $this->app->make(RegistrationController::class);
}
/**
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testSave(): void
{
@ -75,7 +75,7 @@ final class SignUpControllerTest extends ControllerTest
// Assert that the success notification is there
self::assertEquals(
[
'messages.message' => ['pages.sign-up.successful'],
'messages.message' => ['registration.successful'],
],
$this->session->all()
);
@ -86,7 +86,7 @@ final class SignUpControllerTest extends ControllerTest
}
/**
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testSaveAlreadyLoggedIn(): void
{
@ -96,7 +96,7 @@ final class SignUpControllerTest extends ControllerTest
// Fake logged in user
$this->authenticator->method('user')->willReturn(new EngelsystemUser());
// Assert that the user is redirected to /sign-up again
// Assert that the user is redirected to /register again
$this->response
->expects(self::once())
->method('redirectTo')
@ -106,7 +106,7 @@ final class SignUpControllerTest extends ControllerTest
}
/**
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testSaveOAuth(): void
{
@ -136,7 +136,7 @@ final class SignUpControllerTest extends ControllerTest
}
/**
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testSaveWithWelcomeMesssage(): void
{
@ -153,7 +153,7 @@ final class SignUpControllerTest extends ControllerTest
}
/**
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testSaveRegistrationDisabled(): void
{
@ -176,14 +176,14 @@ final class SignUpControllerTest extends ControllerTest
// Assert that the error notification is there
self::assertEquals(
[
'messages.information' => ['pages.sign-up.disabled'],
'messages.information' => ['registration.disabled'],
],
$this->session->all()
);
}
/**
* @covers \Engelsystem\Controllers\SignUpController
* @covers \Engelsystem\Controllers\RegistrationController
*/
public function testViewRegistrationDisabled(): void
{
@ -206,7 +206,7 @@ final class SignUpControllerTest extends ControllerTest
// Assert that the error notification is there
self::assertEquals(
[
'messages.information' => ['pages.sign-up.disabled'],
'messages.information' => ['registration.disabled'],
],
$this->session->all()
);

View File

@ -949,7 +949,7 @@ class SettingsControllerTest extends ControllerTest
'locales' => $languages,
'tshirt_sizes' => $tshirt_sizes,
'goodie_type' => GoodieType::Goodie->value,
'signup_required_fields' => $requiredFields,
'required_user_fields' => $requiredFields,
]);
$this->app->instance('config', $this->config);
$this->app->instance(Config::class, $this->config);

View File

@ -337,7 +337,7 @@ class UserTest extends ServiceProviderTest
$user->userAngelTypes->contains('name', $angelTypes[0]->name)
);
// Do not expect an assignment of the angel type hidden on sign-up
// Do not expect an assignment of the angel type hidden on registration
$this->assertFalse(
$user->userAngelTypes->contains('name', $angelTypes[1]->name)
);
@ -461,7 +461,7 @@ class UserTest extends ServiceProviderTest
/**
* Creates two AngelTypes:
* 1. Normal angel type
* 2. Angel type hidden on sign-up
* 2. Angel type hidden on registration
*
* @return Array<AngelType>
*/

View File

@ -35,7 +35,7 @@ final class SignUpConfig
$config->set('enable_user_name', true);
$config->set('enable_mobile_show', true);
$config->set('enable_dect', true);
$config->set('signup_required_fields', $requiredFields);
$config->set('required_user_fields', $requiredFields);
}
public static function setMinimumConfig(Config $config): void
@ -48,12 +48,6 @@ final class SignUpConfig
'mobile' => false,
'dect' => false,
];
$requiredFields['pronoun'] = false;
$requiredFields['firstname'] = false;
$requiredFields['lastname'] = false;
$requiredFields['tshirt_size'] = true;
$requiredFields['mobile'] = false;
$requiredFields['dect'] = false;
$config->set('registration_enabled', true);
$config->set('enable_password', true);
$config->set('enable_pronoun', false);
@ -66,6 +60,6 @@ final class SignUpConfig
$config->set('enable_user_name', false);
$config->set('enable_mobile_show', false);
$config->set('enable_dect', false);
$config->set('signup_required_fields', $requiredFields);
$config->set('required_user_fields', $requiredFields);
}
}