This commit is contained in:
parent
39dacbb58f
commit
d0cfe112e1
|
@ -311,6 +311,9 @@ desktop:
|
||||||
url: "https://www.google.com/landing/2step/"
|
url: "https://www.google.com/landing/2step/"
|
||||||
caution: "As a caveat, security improves, but you can not sign in to Misskey if you lose a registered device, etc."
|
caution: "As a caveat, security improves, but you can not sign in to Misskey if you lose a registered device, etc."
|
||||||
register: "Register a device"
|
register: "Register a device"
|
||||||
|
already-registered: "The setting has already been completed."
|
||||||
|
unregister: "Disable"
|
||||||
|
unregistered: "Two-step authentication has been disabled."
|
||||||
enter-password: "Enter the password"
|
enter-password: "Enter the password"
|
||||||
authenticator: "First, you need install Google Authenticator to your device:"
|
authenticator: "First, you need install Google Authenticator to your device:"
|
||||||
howtoinstall: "How to install"
|
howtoinstall: "How to install"
|
||||||
|
|
|
@ -311,6 +311,9 @@ desktop:
|
||||||
url: "https://www.google.co.jp/intl/ja/landing/2step/"
|
url: "https://www.google.co.jp/intl/ja/landing/2step/"
|
||||||
caution: "登録したデバイスを紛失するなどした場合、Misskeyにサインインできなくなりますのでご注意ください。"
|
caution: "登録したデバイスを紛失するなどした場合、Misskeyにサインインできなくなりますのでご注意ください。"
|
||||||
register: "デバイスを登録する"
|
register: "デバイスを登録する"
|
||||||
|
already-registered: "既に設定は完了しています。"
|
||||||
|
unregister: "設定を解除"
|
||||||
|
unregistered: "二段階認証が無効になりました。"
|
||||||
enter-password: "パスワードを入力してください"
|
enter-password: "パスワードを入力してください"
|
||||||
authenticator: "まず、Google Authenticatorをお使いのデバイスにインストールします:"
|
authenticator: "まず、Google Authenticatorをお使いのデバイスにインストールします:"
|
||||||
howtoinstall: "インストール方法はこちら"
|
howtoinstall: "インストール方法はこちら"
|
||||||
|
|
|
@ -157,11 +157,18 @@ const endpoints: Endpoint[] = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'i/2fa/register',
|
name: 'i/2fa/register',
|
||||||
withCredential: true
|
withCredential: true,
|
||||||
|
secure: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'i/2fa/unregister',
|
||||||
|
withCredential: true,
|
||||||
|
secure: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'i/2fa/done',
|
name: 'i/2fa/done',
|
||||||
withCredential: true
|
withCredential: true,
|
||||||
|
secure: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'i/update',
|
name: 'i/update',
|
||||||
|
@ -179,11 +186,13 @@ const endpoints: Endpoint[] = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'i/change_password',
|
name: 'i/change_password',
|
||||||
withCredential: true
|
withCredential: true,
|
||||||
|
secure: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'i/regenerate_token',
|
name: 'i/regenerate_token',
|
||||||
withCredential: true
|
withCredential: true,
|
||||||
|
secure: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'i/pin',
|
name: 'i/pin',
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
* Module dependencies
|
||||||
|
*/
|
||||||
|
import $ from 'cafy';
|
||||||
|
import * as bcrypt from 'bcryptjs';
|
||||||
|
import User from '../../../models/user';
|
||||||
|
|
||||||
|
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||||
|
// Get 'password' parameter
|
||||||
|
const [password, passwordErr] = $(params.password).string().$;
|
||||||
|
if (passwordErr) return rej('invalid password param');
|
||||||
|
|
||||||
|
// Compare password
|
||||||
|
const same = await bcrypt.compare(password, user.password);
|
||||||
|
|
||||||
|
if (!same) {
|
||||||
|
return rej('incorrect password');
|
||||||
|
}
|
||||||
|
|
||||||
|
await User.update(user._id, {
|
||||||
|
$set: {
|
||||||
|
two_factor_secret: null,
|
||||||
|
two_factor_enabled: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
res();
|
||||||
|
});
|
|
@ -266,7 +266,11 @@
|
||||||
<mk-2fa-setting>
|
<mk-2fa-setting>
|
||||||
<p>%i18n:desktop.tags.mk-2fa-setting.intro%<a href="%i18n:desktop.tags.mk-2fa-setting.url%" target="_blank">%i18n:desktop.tags.mk-2fa-setting.detail%</a></p>
|
<p>%i18n:desktop.tags.mk-2fa-setting.intro%<a href="%i18n:desktop.tags.mk-2fa-setting.url%" target="_blank">%i18n:desktop.tags.mk-2fa-setting.detail%</a></p>
|
||||||
<div class="ui info warn"><p>%fa:exclamation-triangle%%i18n:desktop.tags.mk-2fa-setting.caution%</p></div>
|
<div class="ui info warn"><p>%fa:exclamation-triangle%%i18n:desktop.tags.mk-2fa-setting.caution%</p></div>
|
||||||
<p if={ !data }><button onclick={ register } class="ui primary">%i18n:desktop.tags.mk-2fa-setting.register%</button></p>
|
<p if={ !data && !I.two_factor_enabled }><button onclick={ register } class="ui primary">%i18n:desktop.tags.mk-2fa-setting.register%</button></p>
|
||||||
|
<virtual if={ I.two_factor_enabled }>
|
||||||
|
<p>%i18n:desktop.tags.mk-2fa-setting.already-registered%</p>
|
||||||
|
<button onclick={ unregister } class="ui">%i18n:desktop.tags.mk-2fa-setting.unregister%</button>
|
||||||
|
</virtual>
|
||||||
<div if={ data }>
|
<div if={ data }>
|
||||||
<ol>
|
<ol>
|
||||||
<li>%i18n:desktop.tags.mk-2fa-setting.authenticator% <a href="https://support.google.com/accounts/answer/1066447" target="_blank">%i18n:desktop.tags.mk-2fa-setting.howtoinstall%</a></li>
|
<li>%i18n:desktop.tags.mk-2fa-setting.authenticator% <a href="https://support.google.com/accounts/answer/1066447" target="_blank">%i18n:desktop.tags.mk-2fa-setting.howtoinstall%</a></li>
|
||||||
|
@ -288,6 +292,7 @@
|
||||||
import passwordDialog from '../scripts/password-dialog';
|
import passwordDialog from '../scripts/password-dialog';
|
||||||
import notify from '../scripts/notify';
|
import notify from '../scripts/notify';
|
||||||
|
|
||||||
|
this.mixin('i');
|
||||||
this.mixin('api');
|
this.mixin('api');
|
||||||
|
|
||||||
this.register = () => {
|
this.register = () => {
|
||||||
|
@ -302,11 +307,25 @@
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.unregister = () => {
|
||||||
|
passwordDialog('%i18n:desktop.tags.mk-2fa-setting.enter-password%', password => {
|
||||||
|
this.api('i/2fa/unregister', {
|
||||||
|
password: password
|
||||||
|
}).then(data => {
|
||||||
|
notify('%i18n:desktop.tags.mk-2fa-setting.unregistered%');
|
||||||
|
this.I.two_factor_enabled = false;
|
||||||
|
this.I.update();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
this.submit = () => {
|
this.submit = () => {
|
||||||
this.api('i/2fa/done', {
|
this.api('i/2fa/done', {
|
||||||
token: this.refs.token.value
|
token: this.refs.token.value
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
notify('%i18n:desktop.tags.mk-2fa-setting.success%');
|
notify('%i18n:desktop.tags.mk-2fa-setting.success%');
|
||||||
|
this.I.two_factor_enabled = true;
|
||||||
|
this.I.update();
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
notify('%i18n:desktop.tags.mk-2fa-setting.failed%');
|
notify('%i18n:desktop.tags.mk-2fa-setting.failed%');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue