mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Add about me
This commit is contained in:
@ -78,12 +78,16 @@ app.use('/api', protectedRoutes); // Routes requiring token
|
||||
===== END ROUTE HANDLING =====
|
||||
*/
|
||||
|
||||
// Do not start the server in testing environment
|
||||
// It will be started by the test suite
|
||||
if (process.argv[2] != 'testing') {
|
||||
// Start the server
|
||||
// Default port is 3000
|
||||
const port = process.env.API_SERVER_PORT || 3000;
|
||||
app.listen(port, () => {
|
||||
console.log(`Blink API server is running on port ${port}`);
|
||||
});
|
||||
}
|
||||
|
||||
// Export the app for testing purposes
|
||||
module.exports = app;
|
||||
|
@ -18,22 +18,23 @@ const bcrypt = require('bcrypt');
|
||||
* Creates Person object by the specified fields
|
||||
* @param {*} email
|
||||
* @param {*} password
|
||||
* @param {*} display_name
|
||||
* @param {*} date_of_birth
|
||||
* @param {*} displayName
|
||||
* @param {*} dateOfBirth
|
||||
* @param {*} available
|
||||
* @param {*} enabled
|
||||
* @param {*} place_of_living
|
||||
* @param {*} placeOfLiving
|
||||
* @returns
|
||||
*/
|
||||
function createPerson (email, password, display_name, date_of_birth, available, enabled, place_of_living) {
|
||||
function createPerson (email, password, displayName, dateOfBirth, available, enabled, placeOfLiving, aboutMe) {
|
||||
const person = {
|
||||
email: email.toLowerCase(),
|
||||
password,
|
||||
display_name,
|
||||
date_of_birth,
|
||||
display_name: displayName,
|
||||
date_of_birth: dateOfBirth,
|
||||
available,
|
||||
enabled,
|
||||
place_of_living
|
||||
place_of_living: placeOfLiving,
|
||||
about_me: aboutMe
|
||||
};
|
||||
return person;
|
||||
}
|
||||
@ -72,15 +73,7 @@ async function registerPerson (person, activationLink) {
|
||||
// and in the "ActivationLink" one, or in neither
|
||||
await knex.transaction(async (tr) => {
|
||||
const personIdResult = await tr('Person')
|
||||
.insert({
|
||||
email: person.email.toLowerCase(),
|
||||
password: person.password,
|
||||
display_name: person.display_name,
|
||||
date_of_birth: person.date_of_birth,
|
||||
available: person.available,
|
||||
enabled: person.enabled,
|
||||
place_of_living: person.place_of_living
|
||||
})
|
||||
.insert(person)
|
||||
.returning('id');
|
||||
await tr('ActivationLink')
|
||||
.insert({
|
||||
|
@ -31,7 +31,7 @@ async function createOrganization (req, res) {
|
||||
try {
|
||||
const organization = organizationModel.createOrganization(req.body.name, req.body.location, req.body.description, req.body.is_hiring);
|
||||
await organizationModel.insertOrganization(organization, req.jwt.person_id);
|
||||
return res.status(200).json({ Organization: organization });
|
||||
return res.status(200).json(organization);
|
||||
} catch (error) {
|
||||
console.error(`Error in function ${createOrganization.name}: ${error}`);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
|
@ -56,12 +56,13 @@ async function registerPerson (req, res) {
|
||||
req.body.display_name,
|
||||
req.body.date_of_birth,
|
||||
req.body.available,
|
||||
true,
|
||||
req.body.place_of_living);
|
||||
false,
|
||||
req.body.place_of_living,
|
||||
req.body.about_me);
|
||||
await personModel.registerPerson(personToInsert, activationLink);
|
||||
return res.status(200).json({ activationLink });
|
||||
} catch (error) {
|
||||
console.error(`Error in function ${console.trace()}: ${error}`);
|
||||
console.error(`Error in function ${registerPerson.name}: ${error}`);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
}
|
||||
@ -175,6 +176,10 @@ async function updatePerson (req, res) {
|
||||
updatePerson.place_of_living = req.body.place_of_living;
|
||||
}
|
||||
|
||||
if(req.body.about_me) {
|
||||
updatePerson.about_me = req.body.about_me;
|
||||
}
|
||||
|
||||
// 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){
|
||||
|
@ -11,7 +11,8 @@ CREATE TABLE IF NOT EXISTS public."Person"
|
||||
date_of_birth date,
|
||||
available boolean,
|
||||
enabled boolean NOT NULL DEFAULT false,
|
||||
place_of_living character varying(128)
|
||||
place_of_living character varying(128),
|
||||
about_me character varying(4096)
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
@ -12,11 +12,11 @@
|
||||
<header>
|
||||
<img src="../content/profile-picture-example.jpg" alt="Profile Picture" class="profile-picture">
|
||||
<h1 id="displayName">Name Surname</h1>
|
||||
<p id="profession">Web Developer</p>
|
||||
<p id="profession">Title</p>
|
||||
</header>
|
||||
<section>
|
||||
<h2>About Me</h2>
|
||||
<p id="aboutMe">I am a passionate web developer with experience in HTML, CSS, and JavaScript. I enjoy creating responsive and user-friendly websites.</p>
|
||||
<p id="aboutMe">About me</p>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Experience</h2>
|
||||
@ -80,11 +80,10 @@
|
||||
|
||||
const data = await response.json();
|
||||
if (response.ok){
|
||||
populateFields(data.display_name, data.email);
|
||||
populateFields(data.display_name, data.email, data.about_me);
|
||||
document.body.style.display = 'block'; // Show page
|
||||
}
|
||||
else if (response.status == 401){
|
||||
console.error(data.error);
|
||||
window.location.href = 'login.html';
|
||||
}
|
||||
else{
|
||||
@ -92,10 +91,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
function populateFields (displayName, email) {
|
||||
function populateFields (displayName, email, aboutMe) {
|
||||
document.getElementById('displayName').textContent = displayName;
|
||||
document.title = `${displayName} - Blink`
|
||||
document.getElementById('email').textContent = email;
|
||||
document.getElementById('aboutMe').textContent = aboutMe;
|
||||
}
|
||||
|
||||
function editProfile () {
|
||||
|
Reference in New Issue
Block a user