Skip to content

Commit 5e8af21

Browse files
authored
UI coverage of bad actor edge use case for login button types (OpenUserJS#2079)
* Tweak non-JS registration string to include probationary user case Post OpenUserJS#1174 OpenUserJS#1893 Auto-merge
1 parent 4b390c4 commit 5e8af21

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

views/includes/scripts/loginEcho.html

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@
2020
var consent = document.querySelector('input[name="consent"]');
2121
var action = document.querySelector('button#action');
2222
var blocking = null;
23+
var icon = ' <i class="fa fa-sign-in fa-fw"></i>';
2324

2425
function onInput(aEv) {
2526
var req = new XMLHttpRequest();
2627
var wantname = cleanFilename(aEv.target.value, '');
2728

2829
function show(aConsent) {
29-
action.innerHTML = action.innerHTML.replace(/Sign Up/, 'Sign In');
30+
action.innerHTML = action.innerHTML = 'Sign In' + icon
3031
action.classList.add('btn-success');
3132
action.classList.remove('btn-info');
33+
action.classList.remove('btn-warning');
3234

3335
if (captcha) {
3436
if (!blocking) {
@@ -46,8 +48,9 @@
4648
}
4749

4850
function hide() {
49-
action.innerHTML = action.innerHTML.replace(/Sign In/, 'Sign Up');
51+
action.innerHTML = action.innerHTML = 'Sign Up' + icon;
5052
action.classList.remove('btn-success');
53+
action.classList.remove('btn-warning');
5154
action.classList.add('btn-info');
5255

5356
if (captcha) {
@@ -57,6 +60,19 @@
5760
consent.checked = false;
5861
}
5962

63+
function hideEx() {
64+
action.innerHTML = action.innerHTML = 'Sign In / Sign Up' + icon;
65+
action.classList.remove('btn-info');
66+
action.classList.remove('btn-success');
67+
action.classList.add('btn-warning');
68+
69+
if (captcha) {
70+
captcha.style.display = 'block';
71+
}
72+
73+
consent.checked = false;
74+
}
75+
6076
if (wantname) {
6177
req.open('HEAD', '/api/user/exist/' + wantname);
6278
req.onreadystatechange = function () {
@@ -72,6 +88,10 @@
7288
show(/ consent$/.test(this.getResponseHeader('Warning')));
7389
auth.value = '';
7490
break;
91+
case 429:
92+
hideEx();
93+
auth.value = 'github';
94+
break;
7595
default:
7696
hide();
7797
auth.value = 'github';
@@ -91,6 +111,8 @@
91111

92112
if (username && auth && action) {
93113
action.innerHTML = action.innerHTML.replace(/Next/, 'Sign Up');
114+
action.classList.remove('btn-danger');
115+
action.classList.add('btn-info');
94116

95117
username.addEventListener('input', onInput, {
96118
capture : true,

views/pages/loginPage.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h3>
1919
</h3>
2020
<noscript>
2121
<div class="alert alert-danger small" role="alert">
22-
<i class="fa fa-exclamation-triangle"></i> <strong>WARNING</strong>: JavaScript must be enabled for new users to register.
22+
<i class="fa fa-exclamation-triangle"></i> <strong>WARNING</strong>: JavaScript must be enabled for new and probationary users to register.
2323
</div>
2424
</noscript>
2525
<div class="input-group">
@@ -56,7 +56,7 @@ <h3>
5656
</div>
5757
</div>
5858
<div class="input-group-addon">
59-
<button class="btn btn-info" type="submit" id="action" class="pull-left">Next <i class="fa fa-sign-in fa-fw"></i></button>
59+
<button class="btn btn-danger" type="submit" id="action" class="pull-left">Next <i class="fa fa-sign-in fa-fw"></i></button>
6060
</div>
6161
</form>
6262
</div>

0 commit comments

Comments
 (0)