return to test
This commit is contained in:
parent
d632c29641
commit
d641c3f67a
|
@ -13,7 +13,6 @@
|
||||||
"@tailwindcss/forms": "^0.2.1",
|
"@tailwindcss/forms": "^0.2.1",
|
||||||
"autoprefixer": "^10.2.4",
|
"autoprefixer": "^10.2.4",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"cookie": "^0.4.1",
|
|
||||||
"dayjs": "^1.10.4",
|
"dayjs": "^1.10.4",
|
||||||
"express-jwt": "^6.0.0",
|
"express-jwt": "^6.0.0",
|
||||||
"formik": "^2.2.6",
|
"formik": "^2.2.6",
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
import superagent from "superagent";
|
import superagent from "superagent";
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
console.log(Object.keys(req));
|
if (!req.cookies.ory_kratos_session) {
|
||||||
console.log(req.url);
|
res.redirect(302, "/auth/login"); // redirect to login page if kratos session is missing
|
||||||
console.log(req.cookies);
|
}
|
||||||
console.log(req.rawHeaders);
|
|
||||||
try {
|
try {
|
||||||
const auth = await superagent
|
const auth = await superagent
|
||||||
.get("http://oathkeeper:4455/user")
|
.get("http://oathkeeper:4455/user")
|
||||||
.set("cookie", `ory_kratos_session=${req.cookies.ory_kratos_session}`);
|
.set("cookie", `ory_kratos_session=${req.cookies.ory_kratos_session}`);
|
||||||
|
|
||||||
console.log(auth.header);
|
|
||||||
|
|
||||||
res.setHeader("Set-Cookie", auth.header["set-cookie"]);
|
res.setHeader("Set-Cookie", auth.header["set-cookie"]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
res.redirect(302, "/error"); // credentials were correct but accounts service failed
|
||||||
}
|
}
|
||||||
|
|
||||||
res.redirect(302, req.query.return_to);
|
res.redirect(302, req.query.return_to ?? "/");
|
||||||
};
|
};
|
|
@ -8,7 +8,7 @@ const kratos = new PublicApi(new Configuration({ basePath: config.kratos.public
|
||||||
|
|
||||||
export async function getServerSideProps(context) {
|
export async function getServerSideProps(context) {
|
||||||
const flow = context.query.flow;
|
const flow = context.query.flow;
|
||||||
const redirect = encodeURIComponent(`/api/redirect?return_to=${context.query.return_to ?? "/"}`);
|
const redirect = encodeURIComponent(`/api/accounts/authenticate?return_to=${context.query.return_to ?? "/"}`);
|
||||||
|
|
||||||
if (process.env.NODE_ENV === "development") {
|
if (process.env.NODE_ENV === "development") {
|
||||||
return { props: { flow: require("../../../stubs/login.json") } };
|
return { props: { flow: require("../../../stubs/login.json") } };
|
||||||
|
|
Reference in New Issue