Skip to content
Snippets Groups Projects
Commit ae19bbb1 authored by Arie Peterson's avatar Arie Peterson
Browse files

Merge branch '124-improve-ux-of-sign-up-errors-for-the-demo-instance' into 'main'

Resolve "Improve UX of sign up errors for the demo instance"

Closes #124

See merge request !104
parents e42ed859 f7ca5134
No related branches found
No related tags found
1 merge request!104Resolve "Improve UX of sign up errors for the demo instance"
Pipeline #38570 passed with stages
in 3 minutes and 7 seconds
...@@ -43,7 +43,13 @@ ...@@ -43,7 +43,13 @@
window.console.log("Error in sign-up request."); window.console.log("Error in sign-up request.");
result.classList.remove('alert-success'); result.classList.remove('alert-success');
result.classList.add('alert-danger'); result.classList.add('alert-danger');
result.innerHTML = this.response.errorMessage; if (this.response.errorMessage == '[KratosError] Unable to insert or update resource because a resource with that value exists already') {
result.innerHTML = "A user with that email address already exists.";
} else if (this.response.errorMessage == '[KratosError] The request was malformed or contained invalid parameters') {
result.innerHTML = "That doesn't appear to be a valid email address.";
} else {
result.innerHTML = this.response.errorMessage;
}
} else { } else {
result.classList.add('alert-success'); result.classList.add('alert-success');
result.classList.remove('alert-danger'); result.classList.remove('alert-danger');
...@@ -56,7 +62,16 @@ ...@@ -56,7 +62,16 @@
var data = JSON.stringify({"email": email.value }); var data = JSON.stringify({"email": email.value });
// Sending data with the request // Sending data with the request
xhr.send(data); xhr.send(data);
} }
$(() => {
// Submit the sign-up form via ajax so we can show the result on the same
// page.
$('#signup-form').submit((event) => {
event.preventDefault();
window.console.log("signup submit");
submitSignup();
});
})
</script> </script>
<h4>Sign up for this demo instance</h4> <h4>Sign up for this demo instance</h4>
Enter your email address here to create an account on this Stackspin Enter your email address here to create an account on this Stackspin
...@@ -73,14 +88,16 @@ ...@@ -73,14 +88,16 @@
destroyed.</li> destroyed.</li>
</ul> </ul>
</div> </div>
<div class="form-group"> <form id="signup-form">
<label for="signup-email">Email address</label> <div class="form-group">
<input type="email" class="form-control" id="signup-email" name="signup-email" placeholder="Your email address to sign up with."> <label for="signup-email">Email address</label>
</div> <input type="email" class="form-control" id="signup-email" name="signup-email" placeholder="Your email address to sign up with.">
<div class="form-group"> </div>
<button class="btn btn-primary" onclick="submitSignup()">Sign up</button> <div class="form-group">
<div id="signup-result" class="alert" style="visibility: hidden; margin-top: 1em;"></div> <input type="submit" class="btn btn-primary" value="Sign up">
</div> <div id="signup-result" class="alert" style="visibility: hidden; margin-top: 1em;"></div>
</div>
</form>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment