use post
This commit is contained in:
parent
9f9db78a8f
commit
f2e6b028cc
|
@ -1,13 +1,10 @@
|
||||||
import superagent from "superagent";
|
import superagent from "superagent";
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
if (!req.cookies.ory_kratos_session) {
|
if (req.cookies.ory_kratos_session) {
|
||||||
res.redirect(302, "/auth/login"); // redirect to login page if kratos session is missing
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const auth = await superagent
|
const auth = await superagent
|
||||||
.get("http://oathkeeper:4455/login")
|
.post("http://oathkeeper:4455/login")
|
||||||
.set("cookie", `ory_kratos_session=${req.cookies.ory_kratos_session}`);
|
.set("cookie", `ory_kratos_session=${req.cookies.ory_kratos_session}`);
|
||||||
|
|
||||||
res.setHeader("Set-Cookie", auth.header["set-cookie"]);
|
res.setHeader("Set-Cookie", auth.header["set-cookie"]);
|
||||||
|
@ -16,4 +13,7 @@ export default async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
res.redirect(302, req.query.return_to ?? "/");
|
res.redirect(302, req.query.return_to ?? "/");
|
||||||
|
} else {
|
||||||
|
res.redirect(302, "/auth/login"); // redirect to login page if kratos session is missing
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in New Issue