Skip to content

Commit

Permalink
Fix error handling in invite request form
Browse files Browse the repository at this point in the history
  • Loading branch information
grishka committed Aug 3, 2022
1 parent d4b9cf1 commit a585c94
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/main/java/smithereen/routes/SessionRoutes.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,13 @@ public static Object requestSignupInvite(Request req, Response resp){
context(req).getUsersController().requestSignupInvite(req, firstName, lastName, email, reason);
return new RenderedTemplateResponse("generic_message", req).with("message", lang(req).get("signup_request_submitted"));
}catch(UserErrorException x){
return wrapForm(req, resp, "register_form_request_invite", "/account/requestInvite", lang(req).get("signup_title"), "request_invitation", "requestInvite", List.of("first_name", "last_name", "email", "reason"), req::queryParams, lang(req).get(x.getMessage()));
return new RenderedTemplateResponse("register_request_invite", req)
.with("first_name", req.queryParams("first_name"))
.with("last_name", req.queryParams("last_name"))
.with("email", req.queryParams("email"))
.with("reason", req.queryParams("reason"))
.with("message", lang(req).get(x.getMessage()))
.pageTitle(lang(req).get("signup_title"));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{%extends "page"%}
{%block content%}
<div class="singleColumn">
{%include "register_form_request_invite"%}
</div>
{%endblock%}
2 changes: 1 addition & 1 deletion src/main/resources/templates/desktop/forms.twig
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<label for="{{name}}">{{label}}</label>:
</td>
<td>
<textarea id="{{name}}" name="{{name}}" rows="3" class="control">{{value}}</textarea>
<textarea id="{{name}}" name="{{name}}" rows="3" class="control"{% if options.required %} required{% endif %}>{{value}}</textarea>
{%if options.explanation is not null%}
<br/><span class="formExplanation">{{options.explanation}}</span>
{%endif%}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/templates/mobile/forms.twig
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<div class="label">
<label for="{{name}}">{{label}}</label>:
</div>
<textarea id="{{name}}" name="{{name}}" rows="3">{{value}}</textarea>
<textarea id="{{name}}" name="{{name}}" rows="3"{% if options.required %} required{% endif %}>{{value}}</textarea>
{%if options.explanation is not null%}
<br/><span class="formExplanation">{{options.explanation}}</span>
{%endif%}
Expand Down

0 comments on commit a585c94

Please sign in to comment.