Skip to content

Commit 57be040

Browse files
committed
Merge branch 'master' into feat/nats
2 parents 9219389 + 7568435 commit 57be040

File tree

7 files changed

+34
-12
lines changed

7 files changed

+34
-12
lines changed

locales/en.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,6 @@
8686
"resetPasswordChoice_title": "Password recovery",
8787
"resetPasswordSent_title": "Password recovery",
8888
"resetPasswordForm_title": "Password recovery",
89-
"resetPasswordSuccess_title": "Password changed"
89+
"resetPasswordSuccess_title": "Password changed",
90+
"resetPassword_title": "Password recovery"
9091
}

locales/fi.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,6 @@
8686
"resetPasswordChoice_title": "Salasanan palautus",
8787
"resetPasswordSent_title": "Salasanan palautus",
8888
"resetPasswordForm_title": "Salasanan palautus",
89-
"resetPasswordSuccess_title": "Salasana palautettu"
89+
"resetPasswordSuccess_title": "Salasana palautettu",
90+
"resetPassword_title": "Salasanan palautus"
9091
}

src/App.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,15 @@ if (process.env.NODE_ENV === "production") {
6868
const app = express();
6969

7070
// Helmet
71-
app.use(helmet());
71+
app.use(
72+
helmet({
73+
contentSecurityPolicy: {
74+
directives: {
75+
"form-action": null,
76+
},
77+
},
78+
}),
79+
);
7280

7381
app.use(morgan("tiny"));
7482

src/controllers/OAuthController.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,19 @@ class OAuthController implements Controller {
687687
});
688688
};
689689

690+
/**
691+
* Sets the language of the page.
692+
*/
693+
public setLanguage: RequestHandler = (req, res) => {
694+
res.clearCookie("tkoaly_locale");
695+
res.cookie("tkoaly_locale", req.params.lang, {
696+
maxAge: 1000 * 60 * 60 * 24 * 7,
697+
domain: process.env.COOKIE_DOMAIN,
698+
});
699+
700+
res.redirect(`/oauth/flow/${encodeURIComponent(req.params.id)}/login`);
701+
};
702+
690703
public createDiscoveryRoute(): RequestHandler {
691704
return this.discovery.bind(this);
692705
}
@@ -708,17 +721,14 @@ class OAuthController implements Controller {
708721

709722
authorizationFlowRouter.get("/flow/:id/privacy", this.privacyForm, this.redirectErrorHandler);
710723

711-
authorizationFlowRouter.post(
712-
"/flow/:id/privacy",
713-
checkCsrf,
714-
this.handlePrivacy,
715-
this.redirectErrorHandler,
716-
);
724+
authorizationFlowRouter.post("/flow/:id/privacy", checkCsrf, this.handlePrivacy, this.redirectErrorHandler);
717725

718726
authorizationFlowRouter.get("/flow/:id/gdpr", this.gdprForm, this.redirectErrorHandler);
719727

720728
authorizationFlowRouter.post("/flow/:id/gdpr", checkCsrf, this.handleGdpr, this.redirectErrorHandler);
721729

730+
authorizationFlowRouter.get("/flow/:id/lang/:lang/:serviceIdentifier?", this.setLanguage);
731+
722732
backChannelRouter.post("/token", this.requireClientAuthentication(), this.token);
723733

724734
backChannelRouter.use(this.jsonErrorHandler);

views/login.pug

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ block content
3232
li
3333
a.applyToBeAMember(href="/reset-password") #{ t("login_ForgotPassword") }
3434
li
35-
if (currentLocale === "fi")
36-
a.loginInEnglish(href="/lang/en/" + service.serviceIdentifier) #{ t("login_InEnglish") }
35+
if (language === "fi")
36+
a.loginInEnglish(href="./lang/en/" + service.serviceIdentifier) #{ t("login_InEnglish") }
3737
else
38-
a.loginInFinnish(href="/lang/fi/" + service.serviceIdentifier) #{ t("login_InFinnish") }
38+
a.loginInFinnish(href="./lang/fi/" + service.serviceIdentifier) #{ t("login_InFinnish") }

views/resetPassword.pug

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ extends layouts/common.pug
33
block content
44
form#loginForm(action=submitUrl || "/reset-password", method="POST")
55
input(type="hidden", name="method", value=method)
6+
input(type="hidden", name="_csrf", value=csrfToken)
67
if (method === "username")
78
p #{ t("resetPassword_usernameInputMessage") }
89
.form-group

views/resetPasswordForm.pug

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ block content
88
input(type="hidden", name="nonce", value=nonce)
99
input(type="hidden", name="expires", value=expires)
1010
input(type="hidden", name="signature", value=signature)
11+
input(type="hidden", name="_csrf", value=csrfToken)
1112
.form-group
1213
label.password1Label(for="password1") #{ t("resetPassword_password1Label") }
1314
input#password1.input(

0 commit comments

Comments
 (0)