Skip to content

Commit

Permalink
Apply new formatting rules to the project
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogoncalves03 committed Jan 21, 2024
1 parent 6666aa3 commit 1ec3b61
Show file tree
Hide file tree
Showing 85 changed files with 15,147 additions and 14,942 deletions.
12,918 changes: 6,459 additions & 6,459 deletions backend/package-lock.json

Large diffs are not rendered by default.

90 changes: 45 additions & 45 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
{
"name": "hs_tms_backend",
"version": "1.0.0",
"description": "HackerSchool's Treasury Management System",
"main": "index.js",
"scripts": {
"start": "nodemon src/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"prettier:check": "prettier --check \"**/*.{js,json,md}\"",
"prettier:format": "prettier --write \"**/*.{js,json,md}\""
},
"repository": {
"type": "git",
"url": "https://github.com/HackerSchool/HS-TMS.git"
},
"author": "HackerSchool",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/HackerSchool/HS-TMS/issues"
},
"homepage": "https://github.com/HackerSchool/HS-TMS#readme",
"dependencies": {
"adm-zip": "^0.5.10",
"axios": "^1.6.0",
"cors": "^2.8.5",
"cron": "^3.1.6",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"express-fileupload": "^1.4.0",
"express-session": "^1.17.3",
"fs": "^0.0.1-security",
"moment-timezone": "^0.5.44",
"morgan": "^1.10.0",
"passport": "^0.6.0",
"passport-local": "^1.0.0",
"passport-oauth2": "^1.7.0",
"pdf-lib": "^1.17.1",
"pdfmake": "^0.2.7",
"pg": "^8.10.0",
"resend": "^2.0.0",
"winston": "^3.11.0"
},
"devDependencies": {
"nodemon": "^2.0.22",
"prettier": "3.2.4"
}
"name": "hs_tms_backend",
"version": "1.0.0",
"description": "HackerSchool's Treasury Management System",
"main": "index.js",
"scripts": {
"start": "nodemon src/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"prettier:check": "prettier --check \"**/*.{js,json,md}\"",
"prettier:format": "prettier --write \"**/*.{js,json,md}\""
},
"repository": {
"type": "git",
"url": "https://github.com/HackerSchool/HS-TMS.git"
},
"author": "HackerSchool",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/HackerSchool/HS-TMS/issues"
},
"homepage": "https://github.com/HackerSchool/HS-TMS#readme",
"dependencies": {
"adm-zip": "^0.5.10",
"axios": "^1.6.0",
"cors": "^2.8.5",
"cron": "^3.1.6",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"express-fileupload": "^1.4.0",
"express-session": "^1.17.3",
"fs": "^0.0.1-security",
"moment-timezone": "^0.5.44",
"morgan": "^1.10.0",
"passport": "^0.6.0",
"passport-local": "^1.0.0",
"passport-oauth2": "^1.7.0",
"pdf-lib": "^1.17.1",
"pdfmake": "^0.2.7",
"pg": "^8.10.0",
"resend": "^2.0.0",
"winston": "^3.11.0"
},
"devDependencies": {
"nodemon": "^2.0.22",
"prettier": "3.2.4"
}
}
22 changes: 11 additions & 11 deletions backend/src/auth/demoLocal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ const passport = require("passport");
const LocalStrategy = require("passport-local").Strategy;

passport.use(
"demo",
new LocalStrategy(function (username, password, done) {
if (username === "demo" && password === "demo") {
const name = "Demo User";
done(null, { username, name });
} else {
done(null, null);
}
})
"demo",
new LocalStrategy(function (username, password, done) {
if (username === "demo" && password === "demo") {
const name = "Demo User";
done(null, { username, name });
} else {
done(null, null);
}
}),
);

passport.serializeUser(function (user, done) {
done(null, user);
done(null, user);
});

passport.deserializeUser(function (user, done) {
done(null, user);
done(null, user);
});
100 changes: 47 additions & 53 deletions backend/src/auth/fenixOAuth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,61 @@ const axios = require("axios");
const { emailLoggerFn } = require("../modules/logging");

passport.use(
"fenix",
new OAuth2Strategy(
{
authorizationURL: "https://fenix.tecnico.ulisboa.pt/oauth/userdialog",
tokenURL: "https://fenix.tecnico.ulisboa.pt/oauth/access_token",
clientID: process.env.FENIX_CLIENT_ID,
clientSecret: process.env.FENIX_CLIENT_SECRET,
callbackURL: `http://localhost:${process.env.PORT}/auth/fenix/callback`,
scope: ["Informação"]
},
function (accessToken, refreshToken, profile, cb) {
axios
.get("https://fenix.tecnico.ulisboa.pt/api/fenix/v1/person", {
headers: {
Authorization: `Bearer ${accessToken}`
}
})
.then(async (response) => {
let { username, name, photo, email } = response.data;
"fenix",
new OAuth2Strategy(
{
authorizationURL: "https://fenix.tecnico.ulisboa.pt/oauth/userdialog",
tokenURL: "https://fenix.tecnico.ulisboa.pt/oauth/access_token",
clientID: process.env.FENIX_CLIENT_ID,
clientSecret: process.env.FENIX_CLIENT_SECRET,
callbackURL: `http://localhost:${process.env.PORT}/auth/fenix/callback`,
scope: ["Informação"],
},
function (accessToken, refreshToken, profile, cb) {
axios
.get("https://fenix.tecnico.ulisboa.pt/api/fenix/v1/person", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
})
.then(async (response) => {
let { username, name, photo, email } = response.data;

const fullName = name.split(" ");
name = `${fullName[0]} ${fullName[fullName.length - 1]}`;
photo = photo.data;
const fullName = name.split(" ");
name = `${fullName[0]} ${fullName[fullName.length - 1]}`;
photo = photo.data;

const user = await User.getOne(require("../models/pool"), username);
if (user) {
const updatedUser = await User.updateOne(
require("../models/pool"),
username,
true,
name,
photo,
email
);
const user = await User.getOne(require("../models/pool"), username);
if (user) {
const updatedUser = await User.updateOne(
require("../models/pool"),
username,
true,
name,
photo,
email,
);

if (!user.active) {
delete user.photo;
delete updatedUser.photo;
emailLoggerFn(
name,
"User",
"PUT",
user,
updatedUser
);
}
}
if (!user.active) {
delete user.photo;
delete updatedUser.photo;
emailLoggerFn(name, "User", "PUT", user, updatedUser);
}
}

cb(null, { username, name, photo, email });
})
.catch((error) => {
cb(error, null);
});
}
)
cb(null, { username, name, photo, email });
})
.catch((error) => {
cb(error, null);
});
},
),
);

passport.serializeUser(function (user, done) {
done(null, user);
done(null, user);
});

passport.deserializeUser(function (user, done) {
done(null, user);
done(null, user);
});
Loading

0 comments on commit 1ec3b61

Please sign in to comment.