Skip to content

Commit b63e672

Browse files
committed
Bugfix: Added text box for registration comment. Avoid captcha reject during registration with authorization provider
1 parent be2ca93 commit b63e672

File tree

3 files changed

+41
-28
lines changed

3 files changed

+41
-28
lines changed

resources/views/register-with-provider-page.phtml

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use Jefferson49\Webtrees\Module\OAuth2Client\RequestHandlers\RegisterWithProvide
2222
* @var string $real_name
2323
* @var string $user_name
2424
* @var string $provider_name
25+
* @var string $comments
2526
*/
2627
?>
2728

@@ -37,36 +38,46 @@ use Jefferson49\Webtrees\Module\OAuth2Client\RequestHandlers\RegisterWithProvide
3738
</div>
3839
<?php endif ?>
3940

40-
<div class="wt-page-options wt-page-options-login">
41-
<div class="row mb-3">
41+
<form method="post" class="wt-page-options wt-page-options-register-with-provider" action="<?= e(route(RegisterWithProviderAction::class, [
42+
'tree' => $tree instanceof Tree ? $tree->name() : null,
43+
'password_token' => $password_token,
44+
'email' => $email,
45+
'real_name' => $real_name,
46+
'user_name' => $user_name,
47+
])) ?>" >
48+
49+
<?= $captcha ?>
50+
51+
<div class="row">
52+
<label class="col-sm-3 col-form-label wt-page-options-label" for="comment">
53+
<?= MoreI18N::xlate('Comments') ?>
54+
</label>
55+
<div class="col-sm-9 wt-page-options-value">
56+
<textarea class="form-control" id="comments" name="comments" placeholder="<?php /* I18N: placeholder text for registration-comments field */
57+
MoreI18N::xlate('Explain why you are requesting an account.') ?>" rows="4" maxlength="255" dir="auto" required="required"><?= e($comments) ?></textarea>
58+
<div class="form-text">
59+
<?= MoreI18N::xlate('Use this field to tell the site administrator why you are requesting an account and how you are related to the genealogy displayed on this site. You can also use this to enter any other comments you may have for the site administrator.') ?>
60+
</div>
61+
</div>
62+
</div>
63+
64+
<div class="row mb">
4265
<label class="col-sm-3 col-form-label wt-page-options-label">
4366
<?= I18N::translate('Request a new account with') . ' ' . $provider_name ?>
4467
</label>
4568

4669
<div class="col-sm-9 wt-page-options-value">
47-
<form method="post" class="wt-page-options wt-page-options-register-with-provider" action="<?= e(route(RegisterWithProviderAction::class, [
48-
'tree' => $tree instanceof Tree ? $tree->name() : null,
49-
'password_token' => $password_token,
50-
'email' => $email,
51-
'real_name' => $real_name,
52-
'user_name' => $user_name,
53-
])) ?>" >
54-
55-
<?= $captcha ?>
56-
57-
<button class="btn btn-primary">
58-
<?= MoreI18N::xlate('continue') ?>
59-
</button>
60-
61-
<a href="<?= e(route(LoginPage::class, [
62-
'tree' => $tree instanceof Tree ? $tree->name() : null,
63-
'url' => $url,
64-
])) ?>" type="submit" class="btn btn-secondary">
65-
<?= MoreI18N::xlate('cancel') ?>
66-
</a>
67-
68-
<?= csrf_field() ?>
69-
</form>
70+
<button class="btn btn-primary">
71+
<?= MoreI18N::xlate('continue') ?>
72+
</button>
73+
<a href="<?= e(route(LoginPage::class, [
74+
'tree' => $tree instanceof Tree ? $tree->name() : null,
75+
'url' => $url,
76+
])) ?>" type="submit" class="btn btn-secondary">
77+
<?= MoreI18N::xlate('cancel') ?>
78+
</a>
7079
</div>
71-
</div>
72-
</div>
80+
</div>
81+
82+
<?= csrf_field() ?>
83+
</form>

src/LoginWithAuthorizationProviderAction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
348348
'password_token' => $accessToken->getToken(),
349349
'real_name' => $real_name,
350350
'user_name' => $user_name,
351+
'comments' => '',
351352
]);
352353
}
353354

src/RequestHandlers/RegisterWithProviderAction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
8989
$email = Validator::queryParams($request)->string('email', '');
9090
$real_name = Validator::queryParams($request)->string('real_name', '');
9191
$user_name = Validator::queryParams($request)->string('user_name', '');
92+
$comments = Validator::parsedBody($request)->string('comments');
9293

9394
try {
9495
if ($this->captcha_service->isRobot($request)) {
@@ -105,7 +106,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
105106
$random_password = md5($password_token . time());
106107

107108
$params = [
108-
'comments' => I18N::translate('Automatic user registration after sign in with authorization provider'),
109+
'comments' => $comments,
109110
'email' => $email,
110111
'password' => $random_password,
111112
'realname' => $real_name,

0 commit comments

Comments
 (0)