chore: Migrate authentication to new tables (#1929)
This work provides a foundation for a more pluggable authentication system such as the one outlined in #1317. closes #1317
This commit is contained in:
@ -79,7 +79,12 @@ User.associate = (models) => {
|
||||
});
|
||||
User.hasMany(models.Document, { as: "documents" });
|
||||
User.hasMany(models.View, { as: "views" });
|
||||
User.hasMany(models.UserAuthentication, { as: "authentications" });
|
||||
User.belongsTo(models.Team);
|
||||
|
||||
User.addScope("withAuthentications", {
|
||||
include: [{ model: models.UserAuthentication, as: "authentications" }],
|
||||
});
|
||||
};
|
||||
|
||||
// Instance methods
|
||||
@ -151,10 +156,6 @@ User.prototype.getTransferToken = function () {
|
||||
// Returns a temporary token that is only used for logging in from an email
|
||||
// It can only be used to sign in once and has a medium length expiry
|
||||
User.prototype.getEmailSigninToken = function () {
|
||||
if (this.service && this.service !== "email") {
|
||||
throw new Error("Cannot generate email signin token for OAuth user");
|
||||
}
|
||||
|
||||
return JWT.sign(
|
||||
{ id: this.id, createdAt: new Date().toISOString(), type: "email-signin" },
|
||||
this.jwtSecret
|
||||
|
Reference in New Issue
Block a user