chore: Syncs changes that were erroneously made in enterprise repo (#1949)
This commit is contained in:
@@ -48,6 +48,12 @@ export default function validation() {
|
||||
}
|
||||
};
|
||||
|
||||
ctx.assertValueInArray = (value, values, message) => {
|
||||
if (!values.includes(value)) {
|
||||
throw new ValidationError(message);
|
||||
}
|
||||
};
|
||||
|
||||
return next();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -95,6 +95,8 @@ const Document = sequelize.define(
|
||||
},
|
||||
getterMethods: {
|
||||
url: function () {
|
||||
if (!this.title) return `/doc/untitled-${this.urlId}`;
|
||||
|
||||
const slugifiedTitle = slugify(this.title);
|
||||
return `/doc/${slugifiedTitle}-${this.urlId}`;
|
||||
},
|
||||
|
||||
@@ -60,11 +60,12 @@ const User = sequelize.define(
|
||||
return original;
|
||||
}
|
||||
|
||||
const initial = this.name ? this.name[0] : "?";
|
||||
const hash = crypto
|
||||
.createHash("md5")
|
||||
.update(this.email || "")
|
||||
.digest("hex");
|
||||
return `${DEFAULT_AVATAR_HOST}/avatar/${hash}/${this.name[0]}.png`;
|
||||
return `${DEFAULT_AVATAR_HOST}/avatar/${hash}/${initial}.png`;
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -69,7 +69,15 @@ export async function getUserForEmailSigninToken(token: string): Promise<User> {
|
||||
}
|
||||
}
|
||||
|
||||
const user = await User.findByPk(payload.id);
|
||||
const user = await User.findByPk(payload.id, {
|
||||
include: [
|
||||
{
|
||||
model: Team,
|
||||
as: "team",
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// if user has signed in at all since the token was created then
|
||||
// it's no longer valid, they'll need a new one.
|
||||
|
||||
Reference in New Issue
Block a user