Added profilePicture property to User

- added profilePicture which saves the url to the users profile picture
pull/5/head
Trivernis 5 years ago
parent 9011cb39cf
commit 124fde08d5

@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ability for admins to delete posts
- ability to upload file at `/upload` with the name profilePicture
- publicPath to config file to configure the directory for public files
- profilePicture property to User model which is an url to the users profile picture
### Removed

@ -21,6 +21,7 @@ import * as socketIoRedis from "socket.io-redis";
import {resolver} from "./graphql/resolvers";
import dataaccess from "./lib/dataAccess";
import globals from "./lib/globals";
import {User} from "./lib/models";
import routes from "./routes";
const SequelizeStore = require("connect-session-sequelize")(session.Store);
@ -140,6 +141,9 @@ class App {
.toFile(path.join(dir, req.session.userId + ".png"));
success = true;
fileName = `/data/profilePictures/${req.session.userId}.png`;
const user = await User.findByPk(req.session.userId);
user.profilePicture = fileName;
await user.save();
} else {
res.status(400);
}

@ -65,6 +65,9 @@ export class User extends Model<User> {
@Column({defaultValue: false, allowNull: false})
public isAdmin: boolean;
@Column({type: sqz.STRING(512)})
public profilePicture: string;
@BelongsToMany(() => User, () => Friendship, "userId")
public rFriends: User[];

Loading…
Cancel
Save