-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
andrewstech
committed
Mar 17, 2024
1 parent
c0c2e87
commit 2ae5c5f
Showing
18 changed files
with
162 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = async (req, res) => { | ||
res.clearCookie("token"); | ||
res.redirect("/login"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,45 @@ | ||
module.exports = (req, res) => { | ||
res.render("register"); | ||
module.exports = async (req, res) => { | ||
const username = req.body.username; | ||
const password = req.body.password; | ||
const confirmPassword = req.body.cpassword; | ||
const email = req.body.email; | ||
|
||
if (!username || !password || !confirmPassword || !email) { | ||
return res.render("register", { message: "Missing username, email, or password." }); | ||
} | ||
|
||
if (password !== confirmPassword) { | ||
return res.render("register", { message: "Passwords do not match." }); | ||
} | ||
|
||
const data = { | ||
"username": username, | ||
"password": password, | ||
"email": email, | ||
}; | ||
|
||
const response = await fetch("https://api.open-domains.net/register", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(data), | ||
}); | ||
|
||
if (response) { | ||
if (response.status === 409) { | ||
return res.render("register", { message: "Username or email already exists." }); | ||
} | ||
if (response.status === 400) { | ||
return res.render("register", { message: "Invalid username, password, or email." }); | ||
} | ||
if (response.status === 500) { | ||
return res.render("register", { message: "Internal server error." }); | ||
} | ||
if (response.status === 200) { | ||
return res.render("registered"); | ||
} | ||
} else { | ||
return res.render("register", { message: "Internal server error." }); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
<head> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet"> | ||
<link rel="icon" | ||
type="image/png" | ||
href="/assets/logo.png" /> | ||
|
||
</head> | ||
<div class="min-h-full"> | ||
|
@@ -56,7 +59,7 @@ | |
<!-- Active: "bg-gray-100", Not Active: "" --> | ||
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-0">Your Profile</a> | ||
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-1">Settings</a> | ||
<a href="#" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-2">Sign out</a> | ||
<a href="/logout/" class="block px-4 py-2 text-sm text-gray-700" role="menuitem" tabindex="-1" id="user-menu-item-2">Sign out</a> | ||
</div> | ||
</div> | ||
</div> | ||
|
@@ -109,7 +112,7 @@ | |
<div class="mt-3 space-y-1 px-2"> | ||
<a href="#" class="block rounded-md px-3 py-2 text-base font-medium text-gray-400 hover:bg-gray-700 hover:text-white">Your Profile</a> | ||
<a href="#" class="block rounded-md px-3 py-2 text-base font-medium text-gray-400 hover:bg-gray-700 hover:text-white">Settings</a> | ||
<a href="#" class="block rounded-md px-3 py-2 text-base font-medium text-gray-400 hover:bg-gray-700 hover:text-white">Sign out</a> | ||
<a href="/logout/" class="block rounded-md px-3 py-2 text-base font-medium text-gray-400 hover:bg-gray-700 hover:text-white">Sign out</a> | ||
</div> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ | |
<title>Open-Domains Authentication</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet"> | ||
<script src="https://www.google.com/recaptcha/api.js" async defer></script> | ||
<link rel="icon" | ||
type="image/png" | ||
href="/assets/logo.png" /> | ||
<style> | ||
|
@@ -55,7 +58,7 @@ | |
<div class="g-recaptcha" data-sitekey="6LdvAnwpAAAAAEjOh8Kb_Zj3uDHkPgAyYoeR7rXt" required></div> | ||
</div> | ||
|
||
<button type="submit" class="bg-yellow-500 text-white px-4 py-2 rounded-md focus:outline-none focus:shadow-outline">Login</button> | ||
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded-md focus:outline-none focus:shadow-outline">Login</button> | ||
</form> | ||
|
||
<hr class="my-6"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ | |
<title>Open-Domains Register</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet"> | ||
<script src="https://www.google.com/recaptcha/api.js" async defer></script> | ||
<link rel="icon" | ||
type="image/png" | ||
href="/assets/logo.png" /> | ||
<style> | ||
|
@@ -33,25 +36,36 @@ | |
<div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md"> | ||
<h1 class="text-3xl mb-6 flex items-center justify-center"><span class="fa fa-sign-in mr-2"></span> Register</h1> | ||
|
||
<% if (message && message.length > 0) { %> | ||
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert"> | ||
<strong class="font-bold">Error!</strong> | ||
<span class="block sm:inline"><%= message %></span> | ||
</div> | ||
<% } %> | ||
|
||
<!-- LOGIN FORM --> | ||
<form action="/register/" method="post"> | ||
<div class="mb-4"> | ||
<label class="block text-gray-700 text-sm font-bold mb-2" for="username">Username</label> | ||
<input type="text" id="username" name="username" class="appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" required> | ||
</div> | ||
<div class="mb-4"> | ||
<label class="block text-gray-700 text-sm font-bold mb-2" for="email">email</label> | ||
<input type="text" id="email" name="email" class="appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" required> | ||
</div> | ||
<div class="mb-4"> | ||
<label class="block text-gray-700 text-sm font-bold mb-2" for="password">Password</label> | ||
<input type="password" id="password" name="password" class="appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" required> | ||
</div> | ||
<div class="mb-4"> | ||
<label class="block text-gray-700 text-sm font-bold mb-2" for="password">Confirm Password</label> | ||
<input type="password" id="cpassword" name="password" class="appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" required> | ||
<input type="password" id="cpassword" name="cpassword" class="appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" required> | ||
</div> | ||
<div class="mb-4"> | ||
<div class="g-recaptcha" data-sitekey="6LdvAnwpAAAAAEjOh8Kb_Zj3uDHkPgAyYoeR7rXt" required></div> | ||
</div> | ||
|
||
<button type="submit" class="bg-yellow-500 text-white px-4 py-2 rounded-md focus:outline-none focus:shadow-outline">Login</button> | ||
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded-md focus:outline-none focus:shadow-outline">Register</button> | ||
</form> | ||
|
||
<hr class="my-6"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Email Verification</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet"> | ||
<link rel="icon" | ||
type="image/png" | ||
href="/assets/logo.png" /> | ||
</head> | ||
<body> | ||
<div class="min-h-screen bg-gray-900 flex justify-center items-center"> | ||
<div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md text-center"> | ||
<h1 class="text-3xl mb-6 flex items-center justify-center"> | ||
<span class="fas fa-exclamation-triangle text-red-500 mr-2"></span> Registration Complete | ||
</h1> | ||
|
||
<p class="text-gray-700">Please Confirm your email by clicking the link we just sent you.</p> | ||
|
||
<hr class="my-6"> | ||
|
||
<p class="text-gray-700">Want to <a href="/register/" class="text-blue-500">Register</a>?</p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Email Verification</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet"> | ||
<link rel="icon" | ||
type="image/png" | ||
href="/assets/logo.png" /> | ||
</head> | ||
<body> | ||
<div class="min-h-screen bg-gray-900 flex justify-center items-center"> | ||
|