fix steam login
This commit is contained in:
parent
5a27070437
commit
ea2ebfb612
2 changed files with 28 additions and 10 deletions
13
index.js
13
index.js
|
@ -21,7 +21,8 @@ const indexRouter = require("./routes/index"),
|
||||||
uploadRouter = require("./routes/upload"),
|
uploadRouter = require("./routes/upload"),
|
||||||
adminRouter = require("./routes/admin"),
|
adminRouter = require("./routes/admin"),
|
||||||
apiRouter = require("./routes/api"),
|
apiRouter = require("./routes/api"),
|
||||||
statsRouter = require("./routes/stats");
|
statsRouter = require("./routes/stats"),
|
||||||
|
authRouter = require("./routes/auth");
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
@ -87,15 +88,7 @@ app.use("/upload", uploadRouter);
|
||||||
app.use("/admin", adminRouter);
|
app.use("/admin", adminRouter);
|
||||||
app.use("/api", apiRouter);
|
app.use("/api", apiRouter);
|
||||||
app.use("/stats", statsRouter);
|
app.use("/stats", statsRouter);
|
||||||
app.get("/auth", passport.authenticate("steam"), () => {});
|
app.use("/auth", authRouter);
|
||||||
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");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
/* catch 404 and forward to error handler
|
/* catch 404 and forward to error handler
|
||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
|
|
25
routes/auth.js
Normal file
25
routes/auth.js
Normal 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;
|
Loading…
Reference in a new issue