diff --git a/src/controllers/api/account/updateController.js b/src/controllers/api/account/updateController.js index de1dd3a..befca96 100644 --- a/src/controllers/api/account/updateController.js +++ b/src/controllers/api/account/updateController.js @@ -27,6 +27,7 @@ module.exports.post = async function(req, res){ const data = matchedData(req); var tempResult = []; + //This is gross and quite honestly password changes should be their own endpoint anyways //if we're not chaning the password if(data.passChange == null){ //go through validation errors @@ -48,6 +49,7 @@ module.exports.post = async function(req, res){ const userDB = await userModel.findOne(user); const update = {}; + if(userDB){ if(data.img){ userDB.img = data.img; @@ -64,6 +66,15 @@ module.exports.post = async function(req, res){ update.signature = data.signature; } + if(data.pronouns != null){ + userDB.pronouns = data.pronouns; + if(data.pronouns == ''){ + update.pronouns = "Unset/Hidden"; + }else{ + update.pronouns = data.pronouns; + } + } + if(data.passChange){ //kill active session to prevent connect-mongo from freaking out accountUtils.killSession(req.session); diff --git a/src/routers/api/accountRouter.js b/src/routers/api/accountRouter.js index b21fe48..95aafd5 100644 --- a/src/routers/api/accountRouter.js +++ b/src/routers/api/accountRouter.js @@ -46,6 +46,7 @@ router.post('/register', accountValidator.user(), router.post('/update', accountValidator.img(), accountValidator.bio(), accountValidator.signature(), + accountValidator.pronouns(), accountValidator.pass('passChange.oldPass'), accountValidator.securePass('passChange.newPass'), accountValidator.pass('passChange.confirmPass'), updateController.post); diff --git a/src/schemas/user/userSchema.js b/src/schemas/user/userSchema.js index f88e3f5..fc5cd44 100644 --- a/src/schemas/user/userSchema.js +++ b/src/schemas/user/userSchema.js @@ -435,9 +435,10 @@ userSchema.methods.getProfile = function(){ tokeCount: this.getTokeCount(), img: this.img, signature: this.signature, + pronouns: this.pronouns, bio: this.bio }; - + //return profile hashtable return profile; } diff --git a/src/validators/accountValidator.js b/src/validators/accountValidator.js index eec2d2b..777a9b5 100644 --- a/src/validators/accountValidator.js +++ b/src/validators/accountValidator.js @@ -32,6 +32,8 @@ module.exports = { img: (field = 'img') => body(field).optional().isURL({require_tld: false, require_host: false}).trim(), + pronouns: (field = 'pronouns') => body(field).optional().escape().trim().isLength({min: 0, max: 15}), + signature: (field = 'signature') => body(field).optional().escape().trim().isLength({min: 1, max: 150}), bio: (field = 'bio') => body(field).optional().escape().trim().isLength({min: 1, max: 1000}), diff --git a/src/views/partial/profile/bio.ejs b/src/views/partial/profile/bio.ejs index 306102a..e15910c 100644 --- a/src/views/partial/profile/bio.ejs +++ b/src/views/partial/profile/bio.ejs @@ -13,9 +13,12 @@ GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . %> - -

Bio: <%- profile.bio %>

-<% if(selfProfile){ %> -

(edit)

-<% } %> + +

Bio:

+ <% if(selfProfile){ %> +

<%- profile.bio %>

+ + <% }else{ %> +

<%- profile.bio %>

+ <% } %>
\ No newline at end of file diff --git a/src/views/partial/profile/date.ejs b/src/views/partial/profile/date.ejs index 3979ce4..27b21aa 100644 --- a/src/views/partial/profile/date.ejs +++ b/src/views/partial/profile/date.ejs @@ -13,4 +13,6 @@ GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . %> -

Joined: <%- profile.date.toUTCString(); %>

\ No newline at end of file + +

Joined: <%- profile.date.toLocaleDateString(); %>

+
\ No newline at end of file diff --git a/src/views/partial/profile/image.ejs b/src/views/partial/profile/image.ejs index 5fdefe2..7665509 100644 --- a/src/views/partial/profile/image.ejs +++ b/src/views/partial/profile/image.ejs @@ -13,7 +13,9 @@ GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . %> - -<% if(selfProfile){ %> -

(edit)

-<% } %> \ No newline at end of file +
+ + <% if(selfProfile){ %> + + <% } %> +
\ No newline at end of file diff --git a/src/views/partial/profile/pronouns.ejs b/src/views/partial/profile/pronouns.ejs new file mode 100644 index 0000000..3d427f2 --- /dev/null +++ b/src/views/partial/profile/pronouns.ejs @@ -0,0 +1,33 @@ +<%# Canopy - The next generation of stoner streaming software +Copyright (C) 2024-2025 Rainbownapkin and the TTN Community + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . %> + +<%# If pronons are unset and the user is viewing their own profile %> +<% if((profile.pronouns == null || profile.pronouns == "") && selfProfile){ %> + +

Pronouns: Unset/Hidden

+ +
+<%# If pronons are set regardless of who's profile %> +<% }else if(profile.pronouns != null && profile.pronouns != ""){ %> + + <% if(selfProfile){ %> +

Pronouns: <%- profile.pronouns %>

+ + <% }else{ %> +

Pronouns: <%- profile.pronouns %>

+ <% } %> +
+<% } %> \ No newline at end of file diff --git a/src/views/partial/profile/settings.ejs b/src/views/partial/profile/settings.ejs index 30c18f4..4faea19 100644 --- a/src/views/partial/profile/settings.ejs +++ b/src/views/partial/profile/settings.ejs @@ -13,15 +13,11 @@ GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . %> -