Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewstech committed Jul 17, 2024
1 parent 69a10d7 commit 0bf73e9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
4 changes: 2 additions & 2 deletions util/jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async function authenticateToken(req, res, next) {

if (token == null) {
let redirect = req.originalUrl;
return res.redirect(`/login?redirect=${redirect}`);
return res.redirect(`https://github.com/login/oauth/authorize?client_id=37ca1e9a943e32b00ac8&scope=public_repo%20user:email&redirect_uri=https://api.open-domains.net/__/auth/handler?redirect=${redirect}`);
}

// Verify the token
Expand Down Expand Up @@ -35,7 +35,7 @@ async function authenticateStaffToken(req, res, next) {

if (token == null) {
let redirect = req.originalUrl;
return res.redirect(`/login?redirect=${redirect}`);
return res.redirect(`https://github.com/login/oauth/authorize?client_id=37ca1e9a943e32b00ac8&scope=public_repo%20user:email&redirect_uri=https://api.open-domains.net/__/auth/handler?redirect=${redirect}`);
}

// Verify the token
Expand Down
25 changes: 1 addition & 24 deletions util/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,7 @@ router.get("/login", (req, res) => {
routes.loginRedirect(req, res);
});

router.post("/login", upload.any(), (req, res) => {
routes.login(req, res);
});

router.get("/register", (req, res) => {
res.render("register", { message: "" });
});

router.post("/register", upload.any(), (req, res) => {
routes.register(req, res);
});

router.get("/domains", authenticateToken, (req, res) => {
routes.domain(req, res);
Expand All @@ -43,9 +33,6 @@ router.get("/settings", authenticateToken, (req, res) => {
res.render("settings", { message: "" });
});

router.get("/verify", (req, res) => {
routes.verify(req, res);
});

router.get("/logout", (req, res) => {
routes.logout(req, res);
Expand All @@ -55,9 +42,7 @@ router.get("/staff", authenticateStaffToken, (req, res) => {
routes.staff(req, res);
});

router.get("/mfa-setup", authenticateToken, (req, res) => {
routes.mfa(req, res);
});


router.post("/password", authenticateToken, upload.any(), (req, res) => {
routes.password(req, res);
Expand All @@ -79,14 +64,6 @@ router.get("/admin/del", authenticateStaffToken, (req, res) => {
routes.adminUser(req, res);
});

router.get("/login/magic", (req, res) => {
const key = req.query.key;
if (!key) {
return res.redirect("/login");
}
res.cookie("token", key, { httpsOnly: true });
res.redirect("/domains");
});


module.exports = router;
3 changes: 1 addition & 2 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
<p class="mt-3"><a class="border-b font-bold hover:border-none" >Open Domains</a> is a service where you can register subdomains for free. Our service offers the opportunity to register subdomains such as <code class="bg-slate-700 py-1 px-2 rounded text-sm">foo.is-cool.dev</code> or <code class="bg-slate-700 py-1 px-2 rounded text-sm">bar.is-not-a.dev</code> and more! Our subdomains support the use of A, AAAA, CNAME, MX, NS and TXT records.</p>

<div class="mt-10">
<a href="/register" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded">Register</a>
<a href="/login" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded">Login</a>
<a href="https://github.com/login/oauth/authorize?client_id=37ca1e9a943e32b00ac8&scope=public_repo%20user:email&redirect_uri=https://api.open-domains.net/__/auth/handler" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded">Login</a>
</div>

</main>
Expand Down

0 comments on commit 0bf73e9

Please sign in to comment.