Skip to content

Commit

Permalink
Merge pull request #286 from nextcloud/improve-registration-submissio…
Browse files Browse the repository at this point in the history
…n-form

Improve registration submission form
  • Loading branch information
nickvergessen authored Apr 7, 2021
2 parents 2e40251 + 8aa573b commit 9dd50b4
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 38 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module.exports = {
extends: [
'@nextcloud'
]
],
globals: {
'$': true
}
};
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/js/registration-settings.js binary
/js/registration-settings.js.map binary
/js/*.js binary
/js/*.js.map binary
3 changes: 1 addition & 2 deletions .l10nignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# compiled vue templates
js/registration-settings.js
js/registration-settings.js.map
js/
14 changes: 0 additions & 14 deletions js/form.js

This file was deleted.

2 changes: 2 additions & 0 deletions js/registration-form.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/registration-form.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions js/registration-settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/registration-settings.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/Controller/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,10 @@ public function showUserForm(string $secret, string $token, string $loginname =
'loginname' => $loginname,
'fullname' => $fullname,
'show_fullname' => $this->config->getAppValue('registration', 'show_fullname', 'no') === 'yes',
'enforce_fullname' => $this->config->getAppValue('registration', 'enforce_fullname', 'no') === 'yes',
'phone' => $phone,
'show_phone' => $this->config->getAppValue('registration', 'show_phone', 'no') === 'yes',
'enforce_phone' => $this->config->getAppValue('registration', 'enforce_phone', 'no') === 'yes',
'message' => $message,
'password' => $password,
'additional_hint' => $additional_hint,
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "1.0.0",
"description": "",
"license": "AGPL-3.0-or-later",
"main": "main.js",
"scripts": {
"build": "NODE_ENV=production webpack --progress --config webpack.js",
"dev": "NODE_ENV=development webpack --progress --config webpack.js",
Expand All @@ -25,6 +24,7 @@
"devDependencies": {
"@babel/eslint-parser": "^7.13.14",
"@nextcloud/babel-config": "^1.0.0-beta.0",
"@nextcloud/browserslist-config": "^1.0.0",
"@nextcloud/eslint-config": "^5.0.0",
"@nextcloud/eslint-plugin": "^2.0.0",
"@nextcloud/webpack-vue-config": "^4.0.1",
Expand All @@ -51,5 +51,8 @@
"vue-template-compiler": "^2.6.12",
"webpack": "^5.28.0",
"webpack-cli": "^4.6.0"
}
},
"browserslist": [
"extends @nextcloud/browserslist-config"
]
}
18 changes: 18 additions & 0 deletions src/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
document.addEventListener('DOMContentLoaded', function() {
// Password toggle
$('#showadminpass').click(() => {
const passwordTextField = $('#password')
if (passwordTextField.attr('type') === 'password') {
passwordTextField.attr('type', 'text')
} else {
passwordTextField.attr('type', 'password')
}
})

// Disable submit after first click
$('form').submit(() => {
// prevent duplicate form submissions
$(this).find(':submit').attr('disabled', 'disabled')
$(this).find(':submit')[0].value = t('registration', 'Loading …')
})
})
1 change: 1 addition & 0 deletions templates/form/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/** @var array $_ */
/** @var \OCP\IL10N $l */
style('registration', 'style');
script('registration', 'registration-form');
?>
<form action="" method="post">
<fieldset>
Expand Down
14 changes: 9 additions & 5 deletions templates/form/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/** @var array $_ */
/** @var \OCP\IL10N $l */
style('registration', 'style');
script('registration', 'form');
script('registration', 'registration-form');
?><form action="" method="post">
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
<fieldset>
Expand Down Expand Up @@ -33,7 +33,7 @@
<p class="groupmiddle">
<input type="text" name="loginname" id="loginname" value="<?php if (!empty($_['loginname'])) {
p($_['loginname']);
} ?>" placeholder="<?php p($l->t('Login name')); ?>" />
} ?>" placeholder="<?php p($l->t('Login name')); ?>" required />
<label for="loginname" class="infield"><?php p($l->t('Login name')); ?></label>
<img id="loginname-icon" class="svg" src="<?php print_unescaped(image_path('', 'categories/auth.svg')); ?>" alt=""/>
</p>
Expand All @@ -45,7 +45,9 @@
<p class="groupmiddle">
<input type="text" name="fullname" id="fullname" value="<?php if (!empty($_['fullname'])) {
p($_['fullname']);
} ?>" placeholder="<?php p($l->t('Full name')); ?>" />
} ?>" placeholder="<?php p($l->t('Full name')); ?>" <?php if ($_['enforce_fullname']) {
p('required');
} ?> />
<label for="fullname" class="infield"><?php p($l->t('Full name')); ?></label>
<img id="fullname-icon" class="svg" src="<?php print_unescaped(image_path('', 'actions/user.svg')); ?>" alt=""/>
</p>
Expand All @@ -57,7 +59,9 @@
<p class="groupmiddle">
<input type="text" name="phone" id="phone" value="<?php if (!empty($_['phone'])) {
p($_['phone']);
} ?>" placeholder="<?php p($l->t('Phone number')); ?>" />
} ?>" placeholder="<?php p($l->t('Phone number')); ?>" <?php if ($_['enforce_phone']) {
p('required');
} ?> />
<label for="phone" class="infield"><?php p($l->t('Phone number')); ?></label>
<img id="phone-icon" class="svg" src="<?php print_unescaped(image_path('', 'clients/phone.svg')); ?>" alt=""/>
</p>
Expand All @@ -68,7 +72,7 @@
<p class="groupbottom">
<input type="password" name="password" id="password" value="<?php if (!empty($_['password'])) {
p($_['password']);
} ?>" placeholder="<?php p($l->t('Password')); ?>"/>
} ?>" placeholder="<?php p($l->t('Password')); ?>" required />
<label for="password" class="infield"><?php p($l->t('Password')); ?></label>
<img id="password-icon" class="svg" src="<?php print_unescaped(image_path('', 'actions/password.svg')); ?>" alt=""/>
<a id="showadminpass" href="#" class="toggle-password">
Expand Down
1 change: 1 addition & 0 deletions templates/form/verification.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/** @var array $_ */
/** @var \OCP\IL10N $l */
style('registration', 'style');
script('registration', 'registration-form');
?>
<form action="" method="post">
<fieldset>
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Controller/RegisterControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,10 @@ public function testShowUserForm(string $username, string $message): void {
'loginname' => $username,
'fullname' => $fullname,
'show_fullname' => true,
'enforce_fullname' => false,
'phone' => $phone,
'show_phone' => true,
'enforce_phone' => false,
'message' => $message,
'password' => $password,
'additional_hint' => null,
Expand Down
1 change: 1 addition & 0 deletions webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const webpackConfig = require('@nextcloud/webpack-vue-config')

webpackConfig.entry = {
settings: path.join(__dirname, 'src', 'settings'),
form: path.join(__dirname, 'src', 'form'),
}

module.exports = webpackConfig

0 comments on commit 9dd50b4

Please sign in to comment.