From 4535ab4c434ba5961e5d8b5ec3957d4e05cd99eb Mon Sep 17 00:00:00 2001 From: sei0o Date: Fri, 17 Aug 2018 16:35:04 +0900 Subject: fix #2266 --- src/client/app/common/views/components/visibility-chooser.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/client/app/common') diff --git a/src/client/app/common/views/components/visibility-chooser.vue b/src/client/app/common/views/components/visibility-chooser.vue index cc9c75095e..8be3ddb8f6 100644 --- a/src/client/app/common/views/components/visibility-chooser.vue +++ b/src/client/app/common/views/components/visibility-chooser.vue @@ -44,7 +44,12 @@ import Vue from 'vue'; import * as anime from 'animejs'; export default Vue.extend({ - props: ['source', 'compact', 'v'], + data() { + return { + v: this.$store.state.device.visibility + } + }, + props: ['source', 'compact'], mounted() { this.$nextTick(() => { const popover = this.$refs.popover as any; @@ -92,6 +97,7 @@ export default Vue.extend({ }, methods: { choose(visibility) { + this.$store.commit('device/setVisibility', visibility); this.$emit('chosen', visibility); this.$destroy(); }, -- cgit v1.2.3-freya From 2c8f962889f9231238dbdaa5990f00646e8060f3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Aug 2018 19:17:23 +0900 Subject: #2214 #2155 --- locales/ja.yml | 2 + src/client/app/common/views/components/signup.vue | 15 ++++- .../desktop/views/pages/admin/admin.dashboard.vue | 14 ++++- src/models/meta.ts | 1 + src/models/registration-tickets.ts | 12 ++++ src/server/api/endpoints/admin/invite.ts | 26 ++++++++ src/server/api/endpoints/admin/suspend-user.ts | 72 +++++++++++----------- src/server/api/endpoints/meta.ts | 3 +- src/server/api/private/signup.ts | 24 ++++++++ 9 files changed, 130 insertions(+), 39 deletions(-) create mode 100644 src/models/registration-tickets.ts create mode 100644 src/server/api/endpoints/admin/invite.ts (limited to 'src/client/app/common') diff --git a/locales/ja.yml b/locales/ja.yml index 310a73a64e..acc4efe89f 100644 --- a/locales/ja.yml +++ b/locales/ja.yml @@ -317,6 +317,8 @@ common/views/components/signin.vue: login-failed: "ログインできませんでした。ユーザー名とパスワードを確認してください。" common/views/components/signup.vue: + invitation-code: "招待コード" + invitation-info: "招待コードをお持ちでない方は、管理者までご連絡ください。" username: "ユーザー名" checking: "確認しています..." available: "利用できます" diff --git a/src/client/app/common/views/components/signup.vue b/src/client/app/common/views/components/signup.vue index 45a183e144..1d33702159 100644 --- a/src/client/app/common/views/components/signup.vue +++ b/src/client/app/common/views/components/signup.vue @@ -1,5 +1,10 @@ @@ -16,13 +20,21 @@ import Vue from "vue"; export default Vue.extend({ data() { return { - stats: null + stats: null, + inviteCode: null }; }, created() { (this as any).api('stats').then(stats => { this.stats = stats; }); + }, + methods: { + invite() { + (this as any).api('admin/invite').then(x => { + this.inviteCode = x.code; + }); + } } }); diff --git a/src/models/meta.ts b/src/models/meta.ts index 11b9b186ce..aef0163dfe 100644 --- a/src/models/meta.ts +++ b/src/models/meta.ts @@ -11,4 +11,5 @@ export type IMeta = { usersCount: number; originalUsersCount: number; }; + disableRegistration: boolean; }; diff --git a/src/models/registration-tickets.ts b/src/models/registration-tickets.ts new file mode 100644 index 0000000000..846acefedf --- /dev/null +++ b/src/models/registration-tickets.ts @@ -0,0 +1,12 @@ +import * as mongo from 'mongodb'; +import db from '../db/mongodb'; + +const RegistrationTicket = db.get('registrationTickets'); +RegistrationTicket.createIndex('code', { unique: true }); +export default RegistrationTicket; + +export interface IRegistrationTicket { + _id: mongo.ObjectID; + createdAt: Date; + code: string; +} diff --git a/src/server/api/endpoints/admin/invite.ts b/src/server/api/endpoints/admin/invite.ts new file mode 100644 index 0000000000..77608e715c --- /dev/null +++ b/src/server/api/endpoints/admin/invite.ts @@ -0,0 +1,26 @@ +import rndstr from 'rndstr'; +import RegistrationTicket from '../../../../models/registration-tickets'; + +export const meta = { + desc: { + ja: '招待コードを発行します。' + }, + + requireCredential: true, + requireAdmin: true, + + params: {} +}; + +export default (params: any) => new Promise(async (res, rej) => { + const code = rndstr({ length: 5, chars: '0-9' }); + + await RegistrationTicket.insert({ + createdAt: new Date(), + code: code + }); + + res({ + code: code + }); +}); diff --git a/src/server/api/endpoints/admin/suspend-user.ts b/src/server/api/endpoints/admin/suspend-user.ts index 8698120cdb..9c32ba987d 100644 --- a/src/server/api/endpoints/admin/suspend-user.ts +++ b/src/server/api/endpoints/admin/suspend-user.ts @@ -4,43 +4,43 @@ import getParams from '../../get-params'; import User from '../../../../models/user'; export const meta = { - desc: { - ja: '指定したユーザーを凍結します。', - en: 'Suspend a user.' - }, - - requireCredential: true, - requireAdmin: true, - - params: { - userId: $.type(ID).note({ - desc: { - ja: '対象のユーザーID', - en: 'The user ID which you want to suspend' - } - }), - } + desc: { + ja: '指定したユーザーを凍結します。', + en: 'Suspend a user.' + }, + + requireCredential: true, + requireAdmin: true, + + params: { + userId: $.type(ID).note({ + desc: { + ja: '対象のユーザーID', + en: 'The user ID which you want to suspend' + } + }), + } }; export default (params: any) => new Promise(async (res, rej) => { - const [ps, psErr] = getParams(meta, params); - if (psErr) return rej(psErr); - - const user = await User.findOne({ - _id: ps.userId - }); - - if (user == null) { - return rej('user not found'); - } - - await User.findOneAndUpdate({ - _id: user._id - }, { - $set: { - isSuspended: true - } - }); - - res(); + const [ps, psErr] = getParams(meta, params); + if (psErr) return rej(psErr); + + const user = await User.findOne({ + _id: ps.userId + }); + + if (user == null) { + return rej('user not found'); + } + + await User.findOneAndUpdate({ + _id: user._id + }, { + $set: { + isSuspended: true + } + }); + + res(); }); diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index c2d93997a7..000a56024d 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -28,6 +28,7 @@ export default () => new Promise(async (res, rej) => { model: os.cpus()[0].model, cores: os.cpus().length }, - broadcasts: meta.broadcasts + broadcasts: meta.broadcasts, + disableRegistration: meta.disableRegistration }); }); diff --git a/src/server/api/private/signup.ts b/src/server/api/private/signup.ts index 16ec33bcbf..2bf56a9791 100644 --- a/src/server/api/private/signup.ts +++ b/src/server/api/private/signup.ts @@ -6,6 +6,7 @@ import User, { IUser, validateUsername, validatePassword, pack } from '../../../ import generateUserToken from '../common/generate-native-user-token'; import config from '../../../config'; import Meta from '../../../models/meta'; +import RegistrationTicket from '../../../models/registration-tickets'; if (config.recaptcha) { recaptcha.init({ @@ -29,6 +30,29 @@ export default async (ctx: Koa.Context) => { const username = body['username']; const password = body['password']; + const invitationCode = body['invitationCode']; + + const meta = await Meta.findOne({}); + + if (meta.disableRegistration) { + if (invitationCode == null || typeof invitationCode != 'string') { + ctx.status = 400; + return; + } + + const ticket = await RegistrationTicket.findOne({ + code: invitationCode + }); + + if (ticket == null) { + ctx.status = 400; + return; + } + + RegistrationTicket.remove({ + _id: ticket._id + }); + } // Validate username if (!validateUsername(username)) { -- cgit v1.2.3-freya From 8d3f71d490dca290b19e2e35c44cb29280907b36 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Aug 2018 19:35:05 +0900 Subject: Fix bug --- src/client/app/common/views/components/visibility-chooser.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/client/app/common') diff --git a/src/client/app/common/views/components/visibility-chooser.vue b/src/client/app/common/views/components/visibility-chooser.vue index 8be3ddb8f6..4691604e57 100644 --- a/src/client/app/common/views/components/visibility-chooser.vue +++ b/src/client/app/common/views/components/visibility-chooser.vue @@ -44,12 +44,12 @@ import Vue from 'vue'; import * as anime from 'animejs'; export default Vue.extend({ + props: ['source', 'compact'], data() { return { - v: this.$store.state.device.visibility + v: this.$store.state.device.visibility || 'public' } }, - props: ['source', 'compact'], mounted() { this.$nextTick(() => { const popover = this.$refs.popover as any; -- cgit v1.2.3-freya From f8a977f1c0c571ebed886666e838939b945c6956 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Sat, 18 Aug 2018 03:55:45 +0900 Subject: Add new kao --- src/client/app/common/scripts/get-kao.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/client/app/common') diff --git a/src/client/app/common/scripts/get-kao.ts b/src/client/app/common/scripts/get-kao.ts index ca83153b96..2c9280c9b6 100644 --- a/src/client/app/common/scripts/get-kao.ts +++ b/src/client/app/common/scripts/get-kao.ts @@ -3,7 +3,8 @@ const kaos = [ 'v(\'ω\')v', '🐡( \'-\' 🐡 )フグパンチ!!!!', '🖕(´・_・`)🖕', - '(。>﹏<。)' + '(。>﹏<。)', + '(Δ・x・Δ)' ]; export default () => kaos[Math.floor(Math.random() * kaos.length)]; -- cgit v1.2.3-freya From 41cf856e263f48570555513f7d3ec78370b1f6a2 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Sat, 18 Aug 2018 04:13:25 +0900 Subject: Fix #2301 --- src/client/app/common/scripts/get-face.ts | 10 ++++++++++ src/client/app/common/scripts/get-kao.ts | 10 ---------- src/client/app/desktop/views/components/post-form.vue | 4 ++-- src/client/app/mobile/views/components/post-form.vue | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 src/client/app/common/scripts/get-face.ts delete mode 100644 src/client/app/common/scripts/get-kao.ts (limited to 'src/client/app/common') diff --git a/src/client/app/common/scripts/get-face.ts b/src/client/app/common/scripts/get-face.ts new file mode 100644 index 0000000000..79cf7a1be4 --- /dev/null +++ b/src/client/app/common/scripts/get-face.ts @@ -0,0 +1,10 @@ +const faces = [ + '(=^・・^=)', + 'v(\'ω\')v', + '🐡( \'-\' 🐡 )フグパンチ!!!!', + '🖕(´・_・`)🖕', + '(。>﹏<。)', + '(Δ・x・Δ)' +]; + +export default () => faces[Math.floor(Math.random() * faces.length)]; diff --git a/src/client/app/common/scripts/get-kao.ts b/src/client/app/common/scripts/get-kao.ts deleted file mode 100644 index 2c9280c9b6..0000000000 --- a/src/client/app/common/scripts/get-kao.ts +++ /dev/null @@ -1,10 +0,0 @@ -const kaos = [ - '(=^・・^=)', - 'v(\'ω\')v', - '🐡( \'-\' 🐡 )フグパンチ!!!!', - '🖕(´・_・`)🖕', - '(。>﹏<。)', - '(Δ・x・Δ)' -]; - -export default () => kaos[Math.floor(Math.random() * kaos.length)]; diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index d5d160bd8f..bacaea65ee 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -58,7 +58,7 @@ import Vue from 'vue'; import insertTextAtCursor from 'insert-text-at-cursor'; import * as XDraggable from 'vuedraggable'; -import getKao from '../../../common/scripts/get-kao'; +import getFace from '../../../common/scripts/get-face'; import MkVisibilityChooser from '../../../common/views/components/visibility-chooser.vue'; import parse from '../../../../../mfm/parse'; import { host } from '../../../config'; @@ -421,7 +421,7 @@ export default Vue.extend({ }, kao() { - this.text += getKao(); + this.text += getFace(); } } }); diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue index 466ca393d5..a74df67c0a 100644 --- a/src/client/app/mobile/views/components/post-form.vue +++ b/src/client/app/mobile/views/components/post-form.vue @@ -56,7 +56,7 @@ import Vue from 'vue'; import insertTextAtCursor from 'insert-text-at-cursor'; import * as XDraggable from 'vuedraggable'; import MkVisibilityChooser from '../../../common/views/components/visibility-chooser.vue'; -import getKao from '../../../common/scripts/get-kao'; +import getFace from '../../../common/scripts/get-face'; import parse from '../../../../../mfm/parse'; import { host } from '../../../config'; @@ -313,7 +313,7 @@ export default Vue.extend({ }, kao() { - this.text += getKao(); + this.text += getFace(); } } }); -- cgit v1.2.3-freya From 53ea7096979fb417f3718dd55b4be2736cee32d5 Mon Sep 17 00:00:00 2001 From: sei0o Date: Sat, 18 Aug 2018 07:53:06 +0900 Subject: fix #1776 --- src/client/app/common/views/components/games/reversi/reversi.index.vue | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/client/app/common') diff --git a/src/client/app/common/views/components/games/reversi/reversi.index.vue b/src/client/app/common/views/components/games/reversi/reversi.index.vue index d4d35f6a86..fa88aeaaf4 100644 --- a/src/client/app/common/views/components/games/reversi/reversi.index.vue +++ b/src/client/app/common/views/components/games/reversi/reversi.index.vue @@ -32,6 +32,7 @@ {{ g.user1 | userName }} vs {{ g.user2 | userName }} {{ g.isEnded ? '%i18n:@game-state.ended%' : '%i18n:@game-state.playing%' }} +
@@ -41,6 +42,7 @@ {{ g.user1 | userName }} vs {{ g.user2 | userName }} {{ g.isEnded ? '%i18n:@game-state.ended%' : '%i18n:@game-state.playing%' }} +
-- cgit v1.2.3-freya