Skip to content

Commit

Permalink
Fixed issue with oauth lastname decoding. Ui fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marios Venetsianos committed Mar 7, 2023
1 parent be0c33d commit 51c4b77
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 12 deletions.
1 change: 0 additions & 1 deletion lib/ministries.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ async function getMinisters(ministries) {
}
}
}
console.log(ministers);
return ministers;
}

Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"express-session": "^1.17.1",
"express-validator": "^6.7.0",
"fast-xml-parser": "^4.0.8",
"html-entities": "^2.3.3",
"html-to-pdfmake": "^2.2.6",
"jsdom": "^16.6.0",
"multer": "^1.4.2",
Expand Down
1 change: 1 addition & 0 deletions routes/edit_user.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ routes.get("/:taxId", authUser, authAdmin, async (req, res, next) => {

res.render("user_views/edit_user", {
user: entry.dataValues,
authUser: req.session.user,
ministries: ministriesResult,
}); // TODO: fix bug where user here is referenced in frontend as logged in user and not as to-be-edited user, which results in bugs with permissions
} else {
Expand Down
5 changes: 2 additions & 3 deletions routes/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ const routes = require("express").Router();
let database = require("../services/database");
const { body, check, validationResult } = require("express-validator");
const bcrypt = require("bcrypt");
const { user } = require("../services/database");

routes.get("/", async function (req, res, next) {
const valid_errors = req.session.errors;
const validation_errors = req.session.errors;
delete req.session.errors;
res.render("login", { errors: valid_errors });
res.render("login", { errors: validation_errors });
});

routes.post(
Expand Down
2 changes: 1 addition & 1 deletion routes/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ routes.get("/", async function (req, res, next) {
req.session.destroy();
if (!req.session) {
res.send({
redirect: `https://${process.env.SITE}/login`,
redirect: `${process.env.SITE}/login`,
});
}
} else {
Expand Down
3 changes: 2 additions & 1 deletion routes/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fetch = (...args) =>
import("node-fetch").then(({ default: fetch }) => fetch(...args)); // consider upgrage nodejs to use internal fetch
const fxmlparser = require("fast-xml-parser");
let database = require("../services/database");
const entities = require("html-entities");

let debug = process.env.DEBUG || false;

Expand Down Expand Up @@ -298,7 +299,7 @@ const gsispa = async (req, res) => {
} else {
await database.user.create({
fname: userinfo.firstname,
lname: userinfo.lastname,
lname: entities.decode(userinfo.lastname),
taxId: userinfo.taxid,
});
req.session.errors = {
Expand Down
2 changes: 1 addition & 1 deletion views/user_views/dashboard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<script>
const user = JSON.parse(' <%- JSON.stringify(user) %> ');
let isAdmin = user.isAdmin;
const isAdmin = user.isAdmin;
setUserRestrictions(user.role);
</script>
Expand Down
8 changes: 5 additions & 3 deletions views/user_views/edit_user.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@
<script type="text/javascript" src="/js/nav_scripts.js"></script>
<script type="text/javascript" src="/js/enums.js"></script>
<script>
const user = JSON.parse(' <%- JSON.stringify(user) %> ');
const user = JSON.parse(' <%- JSON.stringify(authUser) %> ');
setUserRestrictions(user.role);
const isAdmin = '<%= user.isAdmin %>';
const isAdmin = user.isAdmin;
let username = $("#username").val();
$("#delete_user").on("click", function (ev) {
Expand Down Expand Up @@ -288,7 +288,9 @@
$("#agency").append(`<option value="${ministries[i]}">${ministries[i]}</option>`);
}
$("#agency").append('<option value="Άλλος">Άλλος</option>');
$("#agency").val(user.agency);
let agency = "<%= user.agency %>";
console.log(agency);
$("#agency").val(agency);
if (!$("#agency").val()) {
$('#other_agency_div').show();
$("#agency").val('Άλλος');
Expand Down
3 changes: 2 additions & 1 deletion views/user_views/profile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@
<script type="text/javascript" src="/js/enums.js"></script>
<script>
const user = JSON.parse(' <%- JSON.stringify(user) %> ');
const lname = user.lname;
setUserRestrictions(user.role);
let isAdmin = '<%= user.isAdmin %>';
const isAdmin = user.isAdmin;
let username = $("#username").val();
let validationErrors;
Expand Down
2 changes: 1 addition & 1 deletion views/user_views/search_user.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<th class="govgr-table__header" scope="col">Όνομα</th>
<th class="govgr-table__header" scope="col">Επώνυμο</th>
<th class="govgr-table__header" scope="col">Ρόλος</th>
<th class="govgr-table__header" scope="col">Υπουργείο</th>
<th class="govgr-table__header" scope="col">Φορέας</th>
</tr>
</thead>
<tbody class="govgr-table__body">
Expand Down

0 comments on commit 51c4b77

Please sign in to comment.