Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

Commit 3f9acce

Browse files
feat: add password ändern button (#82)
Fix: A password can be changed by a "password ändern" button Co-authored-by: Maximilian Laue <65015235+mlaue-tech@users.noreply.github.com>
1 parent 0e232db commit 3f9acce

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

src/main/java/app/coronawarn/verification/portal/controller/VerificationPortalController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ public class VerificationPortalController {
9090
*/
9191
private static final String ATTR_TELETAN = "teleTAN";
9292
private static final String ATTR_USER = "userName";
93+
private static final String ATTR_PW_RESET_URL = "pwResetUrl";
94+
95+
/**
96+
* The Keycloak password reset URL.
97+
*/
98+
@Value("${keycloak-pw.reset-url}")
99+
private String pwResetUrl;
93100

94101
private static final Map<String, LocalDateTime> rateLimitingUserMap = new ConcurrentHashMap<String, LocalDateTime>();
95102

@@ -133,6 +140,7 @@ public String start(HttpServletRequest request, Model model) {
133140

134141
if (model != null) {
135142
model.addAttribute(ATTR_USER, user.replace("<", "").replace(">", ""));
143+
model.addAttribute(ATTR_PW_RESET_URL, pwResetUrl);
136144
}
137145

138146
HttpSession session = request.getSession();
@@ -176,9 +184,9 @@ public String teletan(HttpServletRequest request, Model model) {
176184
session.setAttribute(SESSION_ATTR_TELETAN, "TeleTAN");
177185
}
178186
if (model != null) {
179-
// set thymeleaf attributes (teleTAN and user name)
180187
model.addAttribute(ATTR_TELETAN, teleTan.getValue().replace("<", "").replace(">", ""));
181188
model.addAttribute(ATTR_USER, user.replace("<", "").replace(">", ""));
189+
model.addAttribute(ATTR_PW_RESET_URL, pwResetUrl);
182190
}
183191
return template;
184192
}

src/main/resources/application.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ keycloak:
1717
realm: cwa
1818
resource: verification-portal
1919

20+
keycloak-pw:
21+
reset-url: http://localhost:8080/auth/realms/cwa/account/password
22+
2023
server:
2124
error:
2225
whitelabel:

src/main/resources/static/logout.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
function showUserPopup() {
2-
var popup = document.getElementById("logout");
3-
popup.classList.toggle("show");
2+
var popup_logout = document.getElementById("logout");
3+
var popup_password_reset = document.getElementById("password_reset");
4+
popup_logout.classList.toggle("show");
5+
popup_password_reset.classList.toggle("show");
46
}

src/main/resources/static/teletan.css

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,29 @@
171171
color: #262626;
172172
}
173173

174-
.button-logout {
174+
.button-menu {
175175
position: fixed;
176176
right: 40px;
177-
top: 150px;
178-
width: 100px;
179177
visibility: hidden;
180178
font-family: "Telegrotesk Next Regular";
181179
font-size: 18px;
182-
color: #262626;
180+
color: #262626;
183181
border-width: 1px;
184182
border-radius: 4px;
185183
border-color: #dddddd;
186184
background-color: #ffffff;
187185
}
188186

187+
.button-logout {
188+
top: 150px;
189+
width: 100px;
190+
}
191+
192+
.button-pw-reset {
193+
top: 180px;
194+
width: 140px;
195+
}
196+
189197
.show {
190198
visibility: visible;
191199
}

src/main/resources/templates/start.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
</tr>
4444
</table>
4545
<form action="/cwa/logout" method="post">
46-
<button class="button-logout" id="logout">Abmelden</button>
46+
<button class="button-menu button-logout" id="logout">Abmelden</button>
4747
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
4848
</form>
49-
49+
<a th:href="${pwResetUrl}" target="_blank"><button class="button-menu button-pw-reset" id="password_reset">Passwort Ändern</button></a>
5050
<!-- END page specific content -->
5151
</body>
5252
</html>

src/main/resources/templates/teletan.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@
4646
</tr>
4747
</table>
4848
<form action="/cwa/logout" method="post">
49-
<button class="button-logout" id="logout">Abmelden</button>
49+
<button class="button-menu button-logout" id="logout">Abmelden</button>
5050
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
5151
</form>
52+
<a th:href="${pwResetUrl}" target="_blank"><button class="button-menu button-pw-reset" id="password_reset">Passwort Ändern</button></a>
5253

5354
<!-- END page specific content -->
5455
</body>

0 commit comments

Comments
 (0)