fixing
This commit is contained in:
parent
3c7b8e5484
commit
42184cb442
1 changed files with 10 additions and 16 deletions
26
sso.js
26
sso.js
|
|
@ -85,7 +85,7 @@ app.post("/api/v1/sso/kcauth", async (req, res) => {
|
||||||
const clientSecret = process.env.KC_CLIENT_SECRET;
|
const clientSecret = process.env.KC_CLIENT_SECRET;
|
||||||
const clientId = process.env.KC_CLIENT_ID;
|
const clientId = process.env.KC_CLIENT_ID;
|
||||||
|
|
||||||
// const cookies = req.cookies;
|
const cookies = req.cookies;
|
||||||
const uid = req.body.uid;
|
const uid = req.body.uid;
|
||||||
|
|
||||||
// const tokenSSO = cookies[cookieName];
|
// const tokenSSO = cookies[cookieName];
|
||||||
|
|
@ -112,10 +112,10 @@ app.post("/api/v1/sso/kcauth", async (req, res) => {
|
||||||
const username = decrypted;
|
const username = decrypted;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const oldssotoken = cookies['oldssotoken'];
|
// const oldssotoken = cookies['oldssotoken'];
|
||||||
const oldcid = cookies['oldcid'];
|
const olduid = cookies['olduid'];
|
||||||
|
|
||||||
if (tokenSSO !== oldssotoken && username !== oldcid) {
|
if (username !== olduid) {
|
||||||
// create body for admin token
|
// create body for admin token
|
||||||
let body = {
|
let body = {
|
||||||
client_id: clientId,
|
client_id: clientId,
|
||||||
|
|
@ -160,13 +160,13 @@ app.post("/api/v1/sso/kcauth", async (req, res) => {
|
||||||
// console.log("==== user token ====");
|
// console.log("==== user token ====");
|
||||||
// console.log(tokenResponse.data);
|
// console.log(tokenResponse.data);
|
||||||
// await postLog('เข้าสู่ระบบ', tokenResponse.data.access_token);
|
// await postLog('เข้าสู่ระบบ', tokenResponse.data.access_token);
|
||||||
res.cookie('oldssotoken', tokenSSO, {
|
// res.cookie('oldssotoken', tokenSSO, {
|
||||||
maxAge: 1000 * 60 * 60 * 24, // กำหนด timeout หน่วยเป็น millisecond
|
// maxAge: 1000 * 60 * 60 * 24, // กำหนด timeout หน่วยเป็น millisecond
|
||||||
path: "/",
|
// path: "/",
|
||||||
httpOnly: true,
|
// httpOnly: true,
|
||||||
});
|
// });
|
||||||
|
|
||||||
res.cookie('oldcid', username, {
|
res.cookie('olduid', username, {
|
||||||
maxAge: 1000 * 60 * 60 * 24, // กำหนด timeout หน่วยเป็น millisecond
|
maxAge: 1000 * 60 * 60 * 24, // กำหนด timeout หน่วยเป็น millisecond
|
||||||
path: "/",
|
path: "/",
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
|
|
@ -184,11 +184,5 @@ app.post("/api/v1/sso/kcauth", async (req, res) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// app.use(express.static(path.join(__dirname, "public-sso")));
|
|
||||||
|
|
||||||
// app.get("/", (_req, res) => {
|
|
||||||
// res.sendFile(`${process.cwd()}/sso.js`);
|
|
||||||
// });
|
|
||||||
|
|
||||||
console.log("Start BMA SSO Simulator at port " + port);
|
console.log("Start BMA SSO Simulator at port " + port);
|
||||||
app.listen(port);
|
app.listen(port);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue