added endpoints for changing password and username
This commit is contained in:
		@@ -31,6 +31,14 @@ class UserService {
 | 
			
		||||
        if (await (this.isInGroup(userId, groupId))) throw new customError(`joinGroup user already in group`, responseCodes.responses.user.already_in_group);
 | 
			
		||||
        await db.query("UPDATE Users SET groups = array_append(groups, $1::integer) WHERE ID = $2", [groupId, userId]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async changeUsername(userId, username) {
 | 
			
		||||
        await db.query("UPDATE users SET username = $1 WHERE id = $2", [username, userId]).catch(e => errorHandler(e, "user"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async changePassword(userId, password) {
 | 
			
		||||
        await db.query("UPDATE users SET password = $1 WHERE id = $2", [bcrypt.hashSync(password, 12), userId])
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default new UserService();
 | 
			
		||||
		Reference in New Issue
	
	Block a user