Taichi Masuyama il y a 4 ans
Parent
commit
1ea3abf49c
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 3 3
      packages/app/src/server/models/user.js

+ 3 - 3
packages/app/src/server/models/user.js

@@ -47,7 +47,7 @@ module.exports = function(crowi) {
     name: { type: String },
     name: { type: String },
     username: { type: String, required: true, unique: true },
     username: { type: String, required: true, unique: true },
     email: { type: String, unique: true, sparse: true },
     email: { type: String, unique: true, sparse: true },
-    slackId: { type: String, unique:true },
+    slackId: { type: String, unique: true },
     // === Crowi settings
     // === Crowi settings
     // username: { type: String, index: true },
     // username: { type: String, index: true },
     // email: { type: String, required: true, index: true },
     // email: { type: String, required: true, index: true },
@@ -692,7 +692,7 @@ module.exports = function(crowi) {
 
 
   userSchema.statics.findUserBySlackId = async function(slackId) {
   userSchema.statics.findUserBySlackId = async function(slackId) {
     const user = this.findOne({ slackId });
     const user = this.findOne({ slackId });
-    if (!user) {
+    if (user == null) {
       throw new Error('User not found');
       throw new Error('User not found');
     }
     }
     return user;
     return user;
@@ -700,7 +700,7 @@ module.exports = function(crowi) {
 
 
   userSchema.statics.findUsersBySlackIds = async function(slackIds) {
   userSchema.statics.findUsersBySlackIds = async function(slackIds) {
     const users = this.find({ slackId: { $in: slackIds } });
     const users = this.find({ slackId: { $in: slackIds } });
-    if (!users) {
+    if (users.length === 0) {
       throw new Error('No user found');
       throw new Error('No user found');
     }
     }
     return users;
     return users;