From 298e78ab1b30831172ddb9900602105aeda48129 Mon Sep 17 00:00:00 2001 From: xfarrow Date: Thu, 29 Feb 2024 15:10:57 +0100 Subject: [PATCH] update --- backend/apis/BlinkApiUsageExample.json | 2 +- backend/apis/nodejs/src/app.js | 2 +- backend/apis/nodejs/src/routes/person_routes.js | 17 ++++++++++------- frontend/vanilla/css/profile.css | 13 +++++++++++++ frontend/vanilla/html/userprofile.html | 10 ++++++++-- 5 files changed, 33 insertions(+), 11 deletions(-) diff --git a/backend/apis/BlinkApiUsageExample.json b/backend/apis/BlinkApiUsageExample.json index 141672a..dd689e1 100644 --- a/backend/apis/BlinkApiUsageExample.json +++ b/backend/apis/BlinkApiUsageExample.json @@ -1 +1 @@ -{"_type":"export","__export_format":4,"__export_date":"2024-02-29T11:21:08.589Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_669e832796b74afea190895704e22bcf","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1698055538103,"created":1698054725162,"url":"localhost:3000/api/organization/removeadmin","name":"RemoveOrganizationAdmin","description":"","method":"DELETE","body":{"mimeType":"application/json","text":"{\n\t\"person_id\" : \"1\",\n\t\"organization_id\" : \"1\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_5b4b316379204e8a9f34ad6b8520cf02"},{"id":"pair_0f33ba2fe5aa4a9c9610531991a08fff","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIxLCJpYXQiOjE2OTgwNTQ3MTgsImV4cCI6MTY5ODA4MzUxOH0.G_x80CDHn3VcJDFewLm6hZb4M9lLEdMmW5rrbE4rHjc","description":""}],"authentication":{},"metaSortKey":-1698054725162,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_b556db78148e4b629915a6d75477c798","parentId":null,"modified":1709111680485,"created":1709111680485,"name":"Blink","description":"","scope":"collection","_type":"workspace"},{"_id":"req_26de24ee47a34b0a8365fde07b12f6d1","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1708355145723,"created":1697612039148,"url":"localhost:3000/api/organization/admin","name":"AddOrganizationAdmin","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"person_id\" : \"1\",\n\t\"organization_id\" : \"1\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_7f6436f6c14046f881b4325c0401f678"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_17a5c397cc2d44d58a70ad0f3ef13d5b"},{"id":"pair_56656674434c4b5f9eb6616c7b662fc1","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDgwMTEzODMsImV4cCI6MTcwODA0MDE4M30.XNPXoLwuU58HSN8wkjoCN0h-2HmMUfhkNSVCnLI5W4M","description":""}],"authentication":{},"metaSortKey":-1697612039148,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_afbde66ccaa9438da0c5bb30735693a0","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1708010369224,"created":1697439750530,"url":"localhost:3000/api/organization/post/7","name":"DeleteOrganizationPost","description":"","method":"DELETE","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_1cf0a9865fc54eb28b06b007dcfb87b6"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_e116a62c90714a2fa936db757b86345a"},{"id":"pair_af07de8a9e584d74bf22de772a1a5116","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDgwMTAzNjAsImV4cCI6MTcwODAzOTE2MH0.iD8e1MdkZ-M1x7A3l0Ocmqyjf_nRCyAqMNVMSa7eZYA","description":""}],"authentication":{},"metaSortKey":-1697439750530,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_3ac98a862c7241f48d7e82fc714965e8","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1708009405122,"created":1697443352055,"url":"localhost:3000/api/organization/post/","name":"CreateOrganizationPost","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"organization_id\" : \"18\",\n\t\"content\" : \"Reach to us on Blink!\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_6e74726d8b9d4be883fb296363f27e4c"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_e355a0ac56664aaa95d1fba431f09a9c"},{"id":"pair_639ce915c16a4e36b23c5eec89acb7c2","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIzLCJpYXQiOjE3MDgwMDkzNjIsImV4cCI6MTcwODAzODE2Mn0.qG1XBiHGxpTIBom_A7WkpfXBkXAW8_1fwolW_-Eensc","description":""}],"authentication":{},"metaSortKey":-1697439606468.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_38c899c967c84a619b34b8c7818a051a","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1698054768000,"created":1697536019056,"url":"localhost:3000/api/organization/1","name":"DeleteOrganization","description":"","method":"DELETE","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_b65bf581b26e4d73b696c173b04c04a2"},{"id":"pair_5b4068cf97244ee8b89f977adaec08a1","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEwLCJpYXQiOjE2OTc0NTI3NDksImV4cCI6MTY5NzQ1NjM0OX0.1Gx13rTRDVVZItkjVHs_RI4w3sxRXammkJpZcP1VXHE","description":""}],"authentication":{},"metaSortKey":-1697439534437.75,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_ffe156a5773249fab1e6a4c05bc7a7b2","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1708007365087,"created":1697722213218,"url":"localhost:3000/api/organization/18","name":"UpdateOrganization","description":"","method":"PUT","body":{"mimeType":"application/json","text":"{\n\t\"name\" : \"Edited Company Inc.\",\n\t\"location\" : \"Boswwwwton\",\n\t\"description\" : \"We are a great company. Join us.\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_fc5a2e2b439942a6ae18401fd037d0b9"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_164bb1219a27446fa2f897510640bb94"},{"id":"pair_e998ceb2025440638d70aa62f0cba85b","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDgwMDczNTcsImV4cCI6MTcwODAzNjE1N30.Gt23DzZVar883j1P0uwAJU72DuHUclpq4GHbWOqsr98","description":""}],"authentication":{},"metaSortKey":-1697439516430.0625,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_968318ce61344e6793e96dec1f22aae8","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709205536574,"created":1697614353582,"url":"localhost:3000/api/organization/17","name":"GetOrganization","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_bf5a8e159b4440ad92054d78cf787432"}],"authentication":{},"metaSortKey":-1697439498422.375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_f8ec3d6839fe4947845671f7fd55fdbf","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1707997338829,"created":1697439462407,"url":"localhost:3000/api/organization","name":"CreateOrganization","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"name\" : \"Company Inc.\",\n\t\"location\" : \"Los Angeles, USA\",\n\t\"description\" : \"Company Inc. is a company specialized in companies\",\n\t\"is_hiring\" : false\n}"},"parameters":[{"id":"pair_fbb851a173414199aabb5612a4afbe79","name":"","value":"","description":""}],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_e97d33e8311c469d9930459e52897eea"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_d25e174d5f1f4268a348f03b3df16cb7"},{"id":"pair_1718cff2285c40649a4f026ffd5f66aa","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDc5ODQ2OTIsImV4cCI6MTcwODAxMzQ5Mn0.GhUuLd4iNY-MO9wfMBH4FBVaLW5n5Nix7lei8PkEye8","description":""}],"authentication":{},"metaSortKey":-1697439462407,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_6f76fbcacefd48c59071f97601437691","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1698054753115,"created":1697535452268,"url":"localhost:3000/api/person/delete","name":"DeletePerson","description":"","method":"DELETE","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_f6ccd1a246fd4f468bc67d1d93aaeba9"},{"id":"pair_3c52bb529c5641758476066fbf9420a2","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjMsImlhdCI6MTY5NzUzNTQyNywiZXhwIjoxNjk3NTY0MjI3fQ.rF8xIQElw45fkmOdXaGFiVqMXQvINc1uPkde6-As8-I","description":""}],"authentication":{},"metaSortKey":-1697235183758.625,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_de3a25c274fd44319bd9ef6a6e4353c2","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709111909016,"created":1697719914121,"url":"localhost:3000/api/person/1","name":"UpdatePerson","description":"","method":"PUT","body":{"mimeType":"application/json","text":"{\n\t\"displayName\": \"John J. Doe\",\n\t\"dateOfBirth\": \"1970-01-01\",\n\t\"available\": \"false\",\n\t\"placeOfLiving\": \"New York City, NY\",\n\t\"oldPassword\": \"password\",\n\t\"newPassword\" : \"password\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_48550a7ad35b41778139f1efea6d6d52"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_050cd5497a3247779057ebfa8df9f7af"},{"id":"pair_009590274cc1470b9265940e398e8c40","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDc5ODQ2OTIsImV4cCI6MTcwODAxMzQ5Mn0.GhUuLd4iNY-MO9wfMBH4FBVaLW5n5Nix7lei8PkEye8","description":""}],"authentication":{},"metaSortKey":-1697133044434.4375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_42a99668d8b54875b30d262fd2c879cd","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709203549709,"created":1708354567080,"url":"localhost:3000/api/person/myself","name":"GetMyself","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_fbdfeef3bb9b45b0aaa4d137cd9cd56c"},{"id":"pair_2d3b8d4c6a48459789363053fc3a5c3e","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDkyMDM1MzksImV4cCI6MTcwOTIzMjMzOX0.AI7eTo1wLxZ0-aNc08P0UbGrkz7K6WXE2q9wjyFfW14","description":""}],"authentication":{},"metaSortKey":-1697081974772.3438,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_dae96bd469c843f598826a48a84cc163","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709204442012,"created":1697452790733,"url":"localhost:3000/api/person/22/details","name":"GetPerson","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_f979eeb78d5d484b87bb2142931bfe88"}],"authentication":{},"metaSortKey":-1697030905110.25,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_d8ac8e10c0024e26a9eb1aaafaffb243","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709118498194,"created":1697439499759,"url":"localhost:3000/api/login","name":"Login","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"email\": \"johndoe@mail.org\",\n\t\"password\": \"password\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1696622347813.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_00e6ecfd87ef4f3a8b3b026b7e8d515b","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709111850398,"created":1695805233220,"url":"localhost:3000/api/register","name":"Register","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"email\" : \"johndoe@mail.org\",\n\t\"password\" : \"password\",\n\t\"displayName\" : \"John Doe\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_4995c469a16542358ad1b61eb49793f1"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_85a8fc0b1f9540cf9b89da7b801ec746"}],"authentication":{"type":"bearer"},"metaSortKey":-1695805233220,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_1bad359b6b8146de8a5d9a444aa06428","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1695805230956,"created":1695805230956,"name":"Base Environment","data":{},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1695805230956,"_type":"environment"},{"_id":"jar_a60b179878784b6d87f4472cd274e0c0","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1695805230957,"created":1695805230957,"name":"Default Jar","cookies":[],"_type":"cookie_jar"}]} \ No newline at end of file +{"_type":"export","__export_format":4,"__export_date":"2024-02-29T14:10:41.622Z","__export_source":"insomnia.desktop.app:v2023.5.8","resources":[{"_id":"req_669e832796b74afea190895704e22bcf","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1698055538103,"created":1698054725162,"url":"localhost:3000/api/organization/removeadmin","name":"RemoveOrganizationAdmin","description":"","method":"DELETE","body":{"mimeType":"application/json","text":"{\n\t\"person_id\" : \"1\",\n\t\"organization_id\" : \"1\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_5b4b316379204e8a9f34ad6b8520cf02"},{"id":"pair_0f33ba2fe5aa4a9c9610531991a08fff","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIxLCJpYXQiOjE2OTgwNTQ3MTgsImV4cCI6MTY5ODA4MzUxOH0.G_x80CDHn3VcJDFewLm6hZb4M9lLEdMmW5rrbE4rHjc","description":""}],"authentication":{},"metaSortKey":-1698054725162,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"wrk_b556db78148e4b629915a6d75477c798","parentId":null,"modified":1709111680485,"created":1709111680485,"name":"Blink","description":"","scope":"collection","_type":"workspace"},{"_id":"req_26de24ee47a34b0a8365fde07b12f6d1","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1708355145723,"created":1697612039148,"url":"localhost:3000/api/organization/admin","name":"AddOrganizationAdmin","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"person_id\" : \"1\",\n\t\"organization_id\" : \"1\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_7f6436f6c14046f881b4325c0401f678"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_17a5c397cc2d44d58a70ad0f3ef13d5b"},{"id":"pair_56656674434c4b5f9eb6616c7b662fc1","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDgwMTEzODMsImV4cCI6MTcwODA0MDE4M30.XNPXoLwuU58HSN8wkjoCN0h-2HmMUfhkNSVCnLI5W4M","description":""}],"authentication":{},"metaSortKey":-1697612039148,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_afbde66ccaa9438da0c5bb30735693a0","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1708010369224,"created":1697439750530,"url":"localhost:3000/api/organization/post/7","name":"DeleteOrganizationPost","description":"","method":"DELETE","body":{"mimeType":"application/json","text":""},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_1cf0a9865fc54eb28b06b007dcfb87b6"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_e116a62c90714a2fa936db757b86345a"},{"id":"pair_af07de8a9e584d74bf22de772a1a5116","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDgwMTAzNjAsImV4cCI6MTcwODAzOTE2MH0.iD8e1MdkZ-M1x7A3l0Ocmqyjf_nRCyAqMNVMSa7eZYA","description":""}],"authentication":{},"metaSortKey":-1697439750530,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_3ac98a862c7241f48d7e82fc714965e8","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1708009405122,"created":1697443352055,"url":"localhost:3000/api/organization/post/","name":"CreateOrganizationPost","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"organization_id\" : \"18\",\n\t\"content\" : \"Reach to us on Blink!\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_6e74726d8b9d4be883fb296363f27e4c"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_e355a0ac56664aaa95d1fba431f09a9c"},{"id":"pair_639ce915c16a4e36b23c5eec89acb7c2","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIzLCJpYXQiOjE3MDgwMDkzNjIsImV4cCI6MTcwODAzODE2Mn0.qG1XBiHGxpTIBom_A7WkpfXBkXAW8_1fwolW_-Eensc","description":""}],"authentication":{},"metaSortKey":-1697439606468.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_38c899c967c84a619b34b8c7818a051a","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1698054768000,"created":1697536019056,"url":"localhost:3000/api/organization/1","name":"DeleteOrganization","description":"","method":"DELETE","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_b65bf581b26e4d73b696c173b04c04a2"},{"id":"pair_5b4068cf97244ee8b89f977adaec08a1","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjEwLCJpYXQiOjE2OTc0NTI3NDksImV4cCI6MTY5NzQ1NjM0OX0.1Gx13rTRDVVZItkjVHs_RI4w3sxRXammkJpZcP1VXHE","description":""}],"authentication":{},"metaSortKey":-1697439534437.75,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_ffe156a5773249fab1e6a4c05bc7a7b2","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709207586070,"created":1697722213218,"url":"localhost:3000/api/organization/18","name":"UpdateOrganization","description":"","method":"PUT","body":{"mimeType":"application/json","text":"{\n\t\"name\" : \"Blink Inc.\",\n\t\"location\" : \"Naples, Italy\",\n\t\"description\" : \"Blink is a privacy-respecting business-oriented social media platform focused on fostering connections between businesses and individuals, propelling careers and sparking innovation in the professional world. Think of it as an open-source alternative to LinkedIn.\",\n\"is_hiring\": true\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_fc5a2e2b439942a6ae18401fd037d0b9"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_164bb1219a27446fa2f897510640bb94"},{"id":"pair_e998ceb2025440638d70aa62f0cba85b","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDkyMDU4MzIsImV4cCI6MTcwOTIzNDYzMn0.03C3maxYKvwb8oVS9zirCMrZzrVYctVNfDK6pRgUQu0","description":""}],"authentication":{},"metaSortKey":-1697439516430.0625,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_968318ce61344e6793e96dec1f22aae8","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709205536574,"created":1697614353582,"url":"localhost:3000/api/organization/17","name":"GetOrganization","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_bf5a8e159b4440ad92054d78cf787432"}],"authentication":{},"metaSortKey":-1697439498422.375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_f8ec3d6839fe4947845671f7fd55fdbf","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1707997338829,"created":1697439462407,"url":"localhost:3000/api/organization","name":"CreateOrganization","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"name\" : \"Company Inc.\",\n\t\"location\" : \"Los Angeles, USA\",\n\t\"description\" : \"Company Inc. is a company specialized in companies\",\n\t\"is_hiring\" : false\n}"},"parameters":[{"id":"pair_fbb851a173414199aabb5612a4afbe79","name":"","value":"","description":""}],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_e97d33e8311c469d9930459e52897eea"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_d25e174d5f1f4268a348f03b3df16cb7"},{"id":"pair_1718cff2285c40649a4f026ffd5f66aa","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDc5ODQ2OTIsImV4cCI6MTcwODAxMzQ5Mn0.GhUuLd4iNY-MO9wfMBH4FBVaLW5n5Nix7lei8PkEye8","description":""}],"authentication":{},"metaSortKey":-1697439462407,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_6f76fbcacefd48c59071f97601437691","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1698054753115,"created":1697535452268,"url":"localhost:3000/api/person/delete","name":"DeletePerson","description":"","method":"DELETE","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_f6ccd1a246fd4f468bc67d1d93aaeba9"},{"id":"pair_3c52bb529c5641758476066fbf9420a2","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjMsImlhdCI6MTY5NzUzNTQyNywiZXhwIjoxNjk3NTY0MjI3fQ.rF8xIQElw45fkmOdXaGFiVqMXQvINc1uPkde6-As8-I","description":""}],"authentication":{},"metaSortKey":-1697235183758.625,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_de3a25c274fd44319bd9ef6a6e4353c2","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709215568257,"created":1697719914121,"url":"localhost:3000/api/person/","name":"UpdatePerson","description":"","method":"PUT","body":{"mimeType":"application/json","text":"{\n\t\"display_name\": \"Alessandro Ferro\",\n\t\"date_of_birth\": \"1970-01-01\",\n\t\"available\": \"false\",\n\t\"place_of_living\": \"New York City, NY\",\n\t\"new_password\": \"password\",\n\t\"old_password\": \"password\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_48550a7ad35b41778139f1efea6d6d52"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_050cd5497a3247779057ebfa8df9f7af"},{"id":"pair_009590274cc1470b9265940e398e8c40","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDkyMTUwNTMsImV4cCI6MTcwOTI0Mzg1M30.1LID1Xw7WHeOf1v3OQwqkYakbdcpJJcVZieAwYik8qE","description":""}],"authentication":{},"metaSortKey":-1697133044434.4375,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_42a99668d8b54875b30d262fd2c879cd","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709203549709,"created":1708354567080,"url":"localhost:3000/api/person/myself","name":"GetMyself","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_fbdfeef3bb9b45b0aaa4d137cd9cd56c"},{"id":"pair_2d3b8d4c6a48459789363053fc3a5c3e","name":"authorization","value":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwZXJzb25faWQiOjIyLCJpYXQiOjE3MDkyMDM1MzksImV4cCI6MTcwOTIzMjMzOX0.AI7eTo1wLxZ0-aNc08P0UbGrkz7K6WXE2q9wjyFfW14","description":""}],"authentication":{},"metaSortKey":-1697081974772.3438,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_dae96bd469c843f598826a48a84cc163","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709204442012,"created":1697452790733,"url":"localhost:3000/api/person/22/details","name":"GetPerson","description":"","method":"GET","body":{},"parameters":[],"headers":[{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_f979eeb78d5d484b87bb2142931bfe88"}],"authentication":{},"metaSortKey":-1697030905110.25,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_d8ac8e10c0024e26a9eb1aaafaffb243","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709118498194,"created":1697439499759,"url":"localhost:3000/api/login","name":"Login","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"email\": \"johndoe@mail.org\",\n\t\"password\": \"password\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json"},{"name":"User-Agent","value":"insomnia/2023.5.8"}],"authentication":{},"metaSortKey":-1696622347813.5,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"req_00e6ecfd87ef4f3a8b3b026b7e8d515b","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1709215311815,"created":1695805233220,"url":"localhost:3000/api/register","name":"Register","description":"","method":"POST","body":{"mimeType":"application/json","text":"{\n\t\"email\" : \"johndoe@mail.org\",\n\t\"password\" : \"password\",\n\t\"display_name\" : \"John Doe\"\n}"},"parameters":[],"headers":[{"name":"Content-Type","value":"application/json","id":"pair_4995c469a16542358ad1b61eb49793f1"},{"name":"User-Agent","value":"insomnia/2023.5.8","id":"pair_85a8fc0b1f9540cf9b89da7b801ec746"}],"authentication":{"type":"bearer"},"metaSortKey":-1695805233220,"isPrivate":false,"settingStoreCookies":true,"settingSendCookies":true,"settingDisableRenderRequestBody":false,"settingEncodeUrl":true,"settingRebuildPath":true,"settingFollowRedirects":"global","_type":"request"},{"_id":"env_1bad359b6b8146de8a5d9a444aa06428","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1695805230956,"created":1695805230956,"name":"Base Environment","data":{},"dataPropertyOrder":null,"color":null,"isPrivate":false,"metaSortKey":1695805230956,"_type":"environment"},{"_id":"jar_a60b179878784b6d87f4472cd274e0c0","parentId":"wrk_b556db78148e4b629915a6d75477c798","modified":1695805230957,"created":1695805230957,"name":"Default Jar","cookies":[],"_type":"cookie_jar"}]} \ No newline at end of file diff --git a/backend/apis/nodejs/src/app.js b/backend/apis/nodejs/src/app.js index bd3e456..45aaf11 100644 --- a/backend/apis/nodejs/src/app.js +++ b/backend/apis/nodejs/src/app.js @@ -60,7 +60,7 @@ publicRoutes.get('/organization/:id', organizationRoutes.getOrganization); const protectedRoutes = express.Router(); protectedRoutes.use(jwtUtils.verifyToken); protectedRoutes.get('/person/myself', personRoutes.getMyself); -protectedRoutes.put('/person/:id', personRoutes.updatePerson); +protectedRoutes.put('/person/', personRoutes.updatePerson); protectedRoutes.delete('/person/delete', personRoutes.deletePerson); protectedRoutes.post('/organization/admin', organizationAdminRoutes.addOrganizationAdmin); protectedRoutes.delete('/organization/removeadmin', organizationAdminRoutes.removeOrganizationAdmin); diff --git a/backend/apis/nodejs/src/routes/person_routes.js b/backend/apis/nodejs/src/routes/person_routes.js index 0b982af..cb6cd18 100644 --- a/backend/apis/nodejs/src/routes/person_routes.js +++ b/backend/apis/nodejs/src/routes/person_routes.js @@ -145,17 +145,14 @@ async function getMyself (req, res) { * PUT request * * Updates a Person's details. If some details are - * not present, they shall be ignored. + * not present, they shall be ignored. An user can + * only update themselves * * Required field(s): none. Both old_password and * new_password if updating the password. * */ async function updatePerson (req, res) { - if (req.jwt.person_id != req.params.id) { - return res.status(403).json({ error: 'Forbidden' }); - } - const updatePerson = {}; if (req.body.display_name) { @@ -179,7 +176,13 @@ async function updatePerson (req, res) { } // If we are tying to change password, the old password must be provided - if (req.body.old_password && req.body.new_password) { + if (req.body.old_password || req.body.new_password) { + if(!req.body.old_password){ + return res.status(401).json({ error: 'The old password must be specified' }); + } + if(!req.body.new_password){ + return res.status(401).json({ error: 'The new password must be specified' }); + } const user = await personModel.getPersonById(req.jwt.person_id); const passwordMatches = await bcrypt.compare(req.body.old_password, user.password); if (passwordMatches) { @@ -194,7 +197,7 @@ async function updatePerson (req, res) { } try { - await personModel.updatePerson(updatePerson, req.params.id); + await personModel.updatePerson(updatePerson, req.jwt.person_id); return res.status(200).json({ success: 'true' }); } catch (error) { console.error(`Error in function ${updatePerson.name}: ${error}`); diff --git a/frontend/vanilla/css/profile.css b/frontend/vanilla/css/profile.css index 8402796..9bfdf65 100644 --- a/frontend/vanilla/css/profile.css +++ b/frontend/vanilla/css/profile.css @@ -12,6 +12,7 @@ body { padding: 20px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + position: relative; } header { @@ -60,3 +61,15 @@ footer { margin-bottom: 10px; } +.edit-badge { + position: absolute; + top: 20px; + right: 20px; + background-color: #008CFF; + color: #fff; + padding: 5px 10px; + border-radius: 5px; + font-weight: bold; + cursor: pointer; +} + diff --git a/frontend/vanilla/html/userprofile.html b/frontend/vanilla/html/userprofile.html index e79f698..3c83986 100644 --- a/frontend/vanilla/html/userprofile.html +++ b/frontend/vanilla/html/userprofile.html @@ -8,6 +8,7 @@
+
Profile Picture

Name Surname

@@ -56,6 +57,7 @@ // Retrieving the logged in user's profile if(!idToDisplay || idToDisplay === 'myself'){ + document.getElementById('editBadge').style.display = 'block'; // show edit button const token = getCookie('token'); // Check whether the token exists if(!token){ @@ -79,19 +81,23 @@ const data = await response.json(); if(response.ok){ populateFields(data.display_name, data.email); - document.body.style.display = "block"; // Show page + document.body.style.display = 'block'; // Show page } else{ alert(data.error); } } - function populateFields(displayName, email){ + function populateFields (displayName, email) { document.getElementById('displayName').textContent = displayName; document.title = `${displayName} - Blink` document.getElementById('email').textContent = email; } + function editProfile () { + alert('Editing'); + } +