diff options
| author | Sam Wilkins <abdullah_ahmed@brown.edu> | 2019-02-26 18:58:07 -0500 |
|---|---|---|
| committer | Sam Wilkins <abdullah_ahmed@brown.edu> | 2019-02-26 18:58:07 -0500 |
| commit | 042eb977ad7733919daf468001b17dbee4e1fa9f (patch) | |
| tree | f4ed1faca8e6fb794290146e79827500d4cab4e8 /src/server/authentication/models | |
| parent | ab110ba8cc8bbf5a633fc5488458be038b06ec24 (diff) | |
beginning multiple workspaces backend and ui
Diffstat (limited to 'src/server/authentication/models')
| -rw-r--r-- | src/server/authentication/models/user_model.ts (renamed from src/server/authentication/models/User.ts) | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/server/authentication/models/User.ts b/src/server/authentication/models/user_model.ts index 433e2f6c3..dfd104ef8 100644 --- a/src/server/authentication/models/User.ts +++ b/src/server/authentication/models/user_model.ts @@ -15,12 +15,15 @@ mongoose.connection.on('error', function (error) { mongoose.connection.on('disconnected', function () { console.log('connection closed'); }); -export type UserModel = mongoose.Document & { +export type DashUserModel = mongoose.Document & { email: string, password: string, passwordResetToken: string | undefined, passwordResetExpires: Date | undefined, - tokens: AuthToken[], + + allWorkspaceIds: Array<String>, + activeWorkspaceId: String, + didSelectSessionWorkspace: Boolean, profile: { name: string, @@ -46,12 +49,19 @@ const userSchema = new mongoose.Schema({ passwordResetToken: String, passwordResetExpires: Date, - userDocumentId: String, + allWorkspaceIds: { + type: Array, + default: [] + }, + activeWorkspaceId: String, + didSelectSessionWorkspace: { + type: Boolean, + default: false + }, facebook: String, twitter: String, google: String, - tokens: Array, profile: { name: String, @@ -66,7 +76,7 @@ const userSchema = new mongoose.Schema({ * Password hash middleware. */ userSchema.pre("save", function save(next) { - const user = this as UserModel; + const user = this as DashUserModel; if (!user.isModified("password")) { return next(); } bcrypt.genSalt(10, (err, salt) => { if (err) { return next(err); } @@ -78,7 +88,7 @@ userSchema.pre("save", function save(next) { }); }); -const comparePassword: comparePasswordFunction = function (this: UserModel, candidatePassword, cb) { +const comparePassword: comparePasswordFunction = function (this: DashUserModel, candidatePassword, cb) { bcrypt.compare(candidatePassword, this.password, (err: mongoose.Error, isMatch: boolean) => { cb(err, isMatch); }); |
