Shun Miyazawa 1 yıl önce
ebeveyn
işleme
f13496b0e9
1 değiştirilmiş dosya ile 3 ekleme ve 8 silme
  1. 3 8
      apps/app/src/server/models/access-token.ts

+ 3 - 8
apps/app/src/server/models/access-token.ts

@@ -17,11 +17,6 @@ import { extractScopes } from '../util/scope-utils';
 const logger = loggerFactory('growi:models:access-token');
 const logger = loggerFactory('growi:models:access-token');
 
 
 const generateTokenHash = (token: string) => crypto.createHash('sha256').update(token).digest('hex');
 const generateTokenHash = (token: string) => crypto.createHash('sha256').update(token).digest('hex');
-const getNowDate = () => {
-  const now = new Date();
-  now.setHours(0, 0, 0, 0);
-  return now;
-};
 
 
 type GenerateTokenResult = {
 type GenerateTokenResult = {
   token: string,
   token: string,
@@ -103,13 +98,13 @@ accessTokenSchema.statics.deleteAllTokensByUserId = async function(userId: Types
 };
 };
 
 
 accessTokenSchema.statics.deleteExpiredToken = async function() {
 accessTokenSchema.statics.deleteExpiredToken = async function() {
-  const now = getNowDate();
+  const now = new Date();
   await this.deleteMany({ expiredAt: { $lt: now } });
   await this.deleteMany({ expiredAt: { $lt: now } });
 };
 };
 
 
 accessTokenSchema.statics.findUserIdByToken = async function(token: string, requiredScopes: Scope[]) {
 accessTokenSchema.statics.findUserIdByToken = async function(token: string, requiredScopes: Scope[]) {
   const tokenHash = generateTokenHash(token);
   const tokenHash = generateTokenHash(token);
-  const now = getNowDate();
+  const now = new Date();
   if (requiredScopes.length === 0) {
   if (requiredScopes.length === 0) {
     return;
     return;
   }
   }
@@ -118,7 +113,7 @@ accessTokenSchema.statics.findUserIdByToken = async function(token: string, requ
 };
 };
 
 
 accessTokenSchema.statics.findTokenByUserId = async function(userId: Types.ObjectId | string) {
 accessTokenSchema.statics.findTokenByUserId = async function(userId: Types.ObjectId | string) {
-  const now = getNowDate();
+  const now = new Date();
   return this.find({ user: userId, expiredAt: { $gte: now } }).select('_id expiredAt scopes description');
   return this.find({ user: userId, expiredAt: { $gte: now } }).select('_id expiredAt scopes description');
 };
 };