Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication system #50

Merged
merged 80 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
e91eea2
Merge branch 'main' of https://github.com/kspcommunity/kspcommunity.com
g9aerospace May 20, 2024
7a8bbac
UPDATES
g9aerospace May 20, 2024
7760107
🔴 .gitignore
g9aerospace May 20, 2024
1037e63
Suiii
g9aerospace May 20, 2024
b3443b7
Merge branch 'main' into preview
g9aerospace May 21, 2024
824faa1
Merge pull request #29 from kspcommunity/preview
g9aerospace May 21, 2024
cf25856
🛠️ header.module.css -> Updated header styles
upayanmazumder May 24, 2024
f49f652
Updated footer
upayanmazumder May 24, 2024
a36fa11
Added a secondary footer
upayanmazumder May 24, 2024
7ab84b2
Added social media icons
upayanmazumder May 24, 2024
ee6c615
🛠️ footer.tsx -> Updated disclaimer text
upayanmazumder May 24, 2024
6c1fc14
🛠️ .hintrc -> Added compatibility settings for CSS
upayanmazumder May 25, 2024
323acb2
🛠️ qwik/package-lock.json -> Updated dependencies for "@qwikest/icons…
upayanmazumder May 25, 2024
7090053
auth pages
upayanmazumder May 25, 2024
2206ac5
🟢 index.tsx for new files
upayanmazumder May 25, 2024
fca2ffd
Refactored auth!
upayanmazumder May 25, 2024
0e6da39
🔴 index.tsx
upayanmazumder May 25, 2024
7acf332
🛠️ header.tsx -> Added new icons for Home, Create, and Settings
upayanmazumder May 25, 2024
e7ab3a2
🛠️ router-head.tsx -> Added import for kspcommunity image, formatted …
upayanmazumder May 25, 2024
81b9698
build(deps): delete 1 file and update 2 files
Larssies May 25, 2024
3a9c064
auth system checks
Larssies May 25, 2024
31e73e7
chore: delete signup.js
Larssies May 25, 2024
e943463
build(deps): update feedback.js, package-lock.json and package.json
Larssies May 25, 2024
6dd2fa9
Merge pull request #34 from kspcommunity/Rate-Limit-Fix
upayanmazumder May 28, 2024
4c44767
Merge pull request #31 from kspcommunity/UI
upayanmazumder May 28, 2024
6eeac86
update login.js and signup.js
Larssies May 28, 2024
ac25c0e
Merge pull request #35 from kspcommunity/Auth
g9aerospace May 28, 2024
9109d51
Merge pull request #36 from kspcommunity/Auth
upayanmazumder May 28, 2024
ea8179b
Merge pull request #37 from kspcommunity/Rate-Limit-Fix
upayanmazumder May 28, 2024
c96a601
Merge pull request #38 from kspcommunity/preview
upayanmazumder May 28, 2024
ffca751
Email verfication
Larssies May 28, 2024
757d74b
Bump firebase from 10.12.1 to 10.12.2
dependabot[bot] May 29, 2024
a591578
Fixed stuff that isnt supposed to be here
Larssies May 29, 2024
70b1e4f
whoopsie
Larssies May 29, 2024
4e22098
Merge pull request #41 from kspcommunity/dependabot/npm_and_yarn/fire…
g9aerospace May 31, 2024
c1fa82d
Merge pull request #43 from kspcommunity/main
g9aerospace May 31, 2024
e888ca4
Bump express-rate-limit from 7.2.0 to 7.3.0
dependabot[bot] Jun 3, 2024
be9da46
Merge pull request #44 from kspcommunity/dependabot/npm_and_yarn/expr…
upayanmazumder Jun 3, 2024
addf446
Merge branch 'main' into Larssies
upayanmazumder Jun 4, 2024
8ffd047
Merge pull request #42 from kspcommunity/Larssies
g9aerospace Jun 4, 2024
bdcfbae
Merge pull request #45 from kspcommunity/main
upayanmazumder Jun 4, 2024
a65d528
Merge pull request #46 from kspcommunity/preview
upayanmazumder Jun 4, 2024
8bda4cb
Merge pull request #47 from kspcommunity/fix
upayanmazumder Jun 4, 2024
50051b4
Basic signup route
upayanmazumder Jun 6, 2024
3255e6c
Updated and patched
upayanmazumder Jun 7, 2024
ba0c3a6
gggggg
upayanmazumder Jun 7, 2024
a2ff3dd
ok
upayanmazumder Jun 7, 2024
64f2433
restructured authentication
upayanmazumder Jun 7, 2024
f9d6103
experimental
upayanmazumder Jun 7, 2024
6e95545
Added return error regarding signup
dave9123 Jun 7, 2024
d3108ad
deleted that shit
upayanmazumder Jun 7, 2024
8a004a6
Fixed
upayanmazumder Jun 7, 2024
8709885
Success message
dave9123 Jun 7, 2024
ef1501d
Fixed bug
dave9123 Jun 7, 2024
40072c1
Fixed Fix code scanning alert - Clear-text logging of sensitive infor…
dave9123 Jun 7, 2024
de2bbb4
gbye
upayanmazumder Jun 7, 2024
b4c8490
Login
upayanmazumder Jun 7, 2024
a8fb7e1
better pkg.json
upayanmazumder Jun 7, 2024
3e7ea5b
redeploy
upayanmazumder Jun 7, 2024
0b02f05
Rid of unncessary pages
upayanmazumder Jun 7, 2024
eae07ad
upgrades
upayanmazumder Jun 7, 2024
cc1d297
better looks
upayanmazumder Jun 7, 2024
9ed48bb
Added auth to header. check header/auth
upayanmazumder Jun 7, 2024
4aa1e04
Merge pull request #52 from kspcommunity/auth-components
upayanmazumder Jun 7, 2024
fff6be5
buggy stuff..
upayanmazumder Jun 9, 2024
4e3f375
style
upayanmazumder Jun 13, 2024
5be3693
Added a 404
upayanmazumder Jun 13, 2024
c408322
Added privacy policy and terms of service pages
upayanmazumder Jun 13, 2024
97c5cfc
Fixed a minor spacing
upayanmazumder Jun 13, 2024
97475af
better header
upayanmazumder Jun 13, 2024
5edbf3f
better social media component
upayanmazumder Jun 13, 2024
73b22a1
Merge pull request #58 from kspcommunity/Cookie-and-better-auth
upayanmazumder Jun 13, 2024
48e2e8f
🛠️ footer.module.css -> Added padding to footer
upayanmazumder Jun 14, 2024
24fffb4
🛠️ styles.css -> Added custom scrollbar styles
upayanmazumder Jun 14, 2024
ada68e8
🛠️ socials.module.css -> Modified styles for .iconLink and .icon classes
upayanmazumder Jun 14, 2024
7a98251
🛠️ footer.module.css -> Added new styles for version and disclaimer.
upayanmazumder Jun 14, 2024
6c4f5dc
🛠️ index.tsx -> Updated icons for login button
upayanmazumder Jun 14, 2024
96d6ad4
Merge branch 'preview' into Cookie-and-better-auth
upayanmazumder Jun 14, 2024
7d51bb7
Merge pull request #59 from kspcommunity/Cookie-and-better-auth
upayanmazumder Jun 14, 2024
e20a191
Merge branch 'main' into preview
upayanmazumder Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
node_modules
api/ssl
api/firebase/firebaseconfig.json
api/firebase/firebaseServiceAccount.json
api/firebase/firebaseServiceAccount.json
.vscode/settings.json
api/logs.log
13 changes: 11 additions & 2 deletions .hintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"text-size-adjust"
]
}
]
}
],
"apple-touch-icons": "off"
},
"browserslist": [
"defaults",
"not ie 11",
"not and_ff <= 124",
"not firefox <= 124",
"not ios_saf <= 17.4",
"not safari <= 17.4"
]
}
18 changes: 18 additions & 0 deletions api/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, printf } = format;

const logger = createLogger({
level: 'info',
format: combine(
timestamp(),
printf(({ timestamp, level, message }) => {
return `${timestamp} [${level}]: ${message}`;
})
),
transports: [
new transports.Console(),
new transports.File({ filename: 'api/logs.log' })
],
});

module.exports = logger;
65 changes: 47 additions & 18 deletions api/routes/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,61 @@ const express = require('express');
const { initializeApp } = require('firebase/app');
const { getAuth, createUserWithEmailAndPassword, sendEmailVerification } = require('firebase/auth');
const firebaseConfig = require('../firebaseconfig.json');
const logger = require('../logger');

const router = express.Router();

const firebaseApp = initializeApp(firebaseConfig);
const auth = getAuth(firebaseApp);

router.post('/', (req, res) => {
router.post('/', async (req, res) => {
const { email, password } = req.body;

createUserWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
res.status(200).send({ authenticated: true, credentials: userCredential.user });

sendEmailVerification(auth.currentUser)
.then(() => {
res.status(200).send({ email: true });
})
.catch((error) => {
res.status(500).send({ email: false, error: error.message });
console.error(error);
});
})
.catch((error) => {
res.status(500).send({ authenticated: false, error: error.message });
console.error(error);
});
if (!email || !password) {
const errorMsg = 'Email and password are required.';
logger.error(errorMsg);
return res.status(400).send({ authenticated: false, email: false, error: errorMsg });
}

try {
// Create the user
const userCredential = await createUserWithEmailAndPassword(auth, email, password);
logger.info(`User created: ${userCredential.user.uid}`);

try {
// Send verification email
await sendEmailVerification(userCredential.user);
logger.info(`Verification email sent to: ${email}`);

// Send response back
res.status(200).send({ authenticated: true, email: true, credentials: userCredential.user });
} catch (emailError) {
// Log email sending failure
logger.error(`Failed to send verification email to ${email}: ${emailError.message}`);
res.status(200).send({ authenticated: true, email: false, credentials: userCredential.user, error: emailError.message });
}
} catch (error) {
// Handle and log different Firebase auth errors
let errorMsg;
switch (error.code) {
case 'auth/email-already-in-use':
errorMsg = 'The email address is already in use by another account.';
break;
case 'auth/invalid-email':
errorMsg = 'The email address is not valid.';
break;
case 'auth/operation-not-allowed':
errorMsg = 'Email/password accounts are not enabled.';
break;
case 'auth/weak-password':
errorMsg = 'The password is too weak.';
break;
default:
errorMsg = 'An unknown error occurred.';
}
logger.error(`Error creating user with email ${email}: ${error.message}`);
res.status(500).send({ authenticated: false, email: false, error: errorMsg });
}
});

module.exports = router;
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"main": "api/server.js",
"scripts": {
"test": "npm run build",
"start": "cd frontend && npm run start",
"build": "cd frontend && npm install && npm run build",
"start:backend": "node api/server.js"
"start": "cd qwik && npm run start",
"build": "cd qwik && npm install && npm run build",
"start:backend": "node api/server.js",
"dev": "cd qwik && npm run dev"
},
"repository": {
"type": "git",
Expand All @@ -28,6 +29,7 @@
"express-rate-limit": "^7.3.1",
"firebase": "^10.12.2",
"helmet": "^7.1.0",
"morgan": "^1.10.0"
"morgan": "^1.10.0",
"valibot": "^0.31.1"
}
}
Loading
Loading