fix steam login

This commit is contained in:
Jonny_Bro (Nikita) 2024-12-06 18:29:09 +05:00
parent 5a27070437
commit ea2ebfb612
2 changed files with 28 additions and 10 deletions

View file

@ -21,7 +21,8 @@ const indexRouter = require("./routes/index"),
uploadRouter = require("./routes/upload"),
adminRouter = require("./routes/admin"),
apiRouter = require("./routes/api"),
statsRouter = require("./routes/stats");
statsRouter = require("./routes/stats"),
authRouter = require("./routes/auth");
const app = express();
@ -87,15 +88,7 @@ app.use("/upload", uploadRouter);
app.use("/admin", adminRouter);
app.use("/api", apiRouter);
app.use("/stats", statsRouter);
app.get("/auth", passport.authenticate("steam"), () => {});
app.get("/auth/return", passport.authenticate("steam", { failureRedirect: "/" }), (req, res) => res.redirect("/key"));
app.get("/auth/logout", (req, res, next) => {
req.logout(function (err) {
if (err) return next(err);
res.redirect("/key");
});
});
app.use("/auth", authRouter);
/* catch 404 and forward to error handler
app.use(function (req, res, next) {

25
routes/auth.js Normal file
View file

@ -0,0 +1,25 @@
const express = require("express"),
router = express.Router(),
passport = require("passport");
router.get("/", passport.authenticate("steam"), () => {});
router.get(
"/return",
function (req, res, next) {
req.url = req.originalUrl;
next();
},
passport.authenticate("steam", { failureRedirect: "/" }),
(req, res) => res.redirect("/key"),
);
router.get("/logout", (req, res, next) => {
req.logout(function (err) {
if (err) return next(err);
res.redirect("/key");
});
});
module.exports = router;