From ae161051ff02dafe02202a367a45d69f75279c1a Mon Sep 17 00:00:00 2001 From: Tosuke Date: Mon, 13 Aug 2018 12:30:32 +0900 Subject: [PATCH] Create apps without authentication(#2025) --- package.json | 1 + src/models/app.ts | 2 +- src/server/api/endpoints/app/create.ts | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 315f45506..7424a0cec 100644 --- a/package.json +++ b/package.json @@ -145,6 +145,7 @@ "koa-slow": "2.1.0", "koa-views": "6.1.4", "loader-utils": "1.1.0", + "lodash.assign": "4.2.0", "mecab-async": "0.1.2", "minio": "6.0.0", "mkdirp": "0.5.1", diff --git a/src/models/app.ts b/src/models/app.ts index 8dc7fe01d..01cc946c6 100644 --- a/src/models/app.ts +++ b/src/models/app.ts @@ -13,7 +13,7 @@ export default App; export type IApp = { _id: mongo.ObjectID; createdAt: Date; - userId: mongo.ObjectID; + userId: mongo.ObjectID | null; secret: string; name: string; nameId: string; diff --git a/src/server/api/endpoints/app/create.ts b/src/server/api/endpoints/app/create.ts index 5df8bd2f2..b2a5fb73c 100644 --- a/src/server/api/endpoints/app/create.ts +++ b/src/server/api/endpoints/app/create.ts @@ -4,7 +4,7 @@ import App, { isValidNameId, pack } from '../../../../models/app'; import { ILocalUser } from '../../../../models/user'; export const meta = { - requireCredential: true + requireCredential: false }; /** @@ -38,7 +38,7 @@ export default async (params: any, user: ILocalUser) => new Promise(async (res, // Create account const app = await App.insert({ createdAt: new Date(), - userId: user._id, + userId: user && user._id, name: name, nameId: nameId, nameIdLower: nameId.toLowerCase(),