This commit is contained in:
@ -6,6 +6,9 @@
|
||||
<label class="password">
|
||||
<input ref="password" type="password" placeholder="%i18n:common.tags.mk-signin.password%" required="required"/>%fa:lock%
|
||||
</label>
|
||||
<label class="token" if={ user && user.two_factor_enabled }>
|
||||
<input ref="token" type="number" placeholder="%i18n:common.tags.mk-signin.token%" required="required"/>%fa:lock%
|
||||
</label>
|
||||
<button type="submit" disabled={ signing }>{ signing ? '%i18n:common.tags.mk-signin.signing-in%' : '%i18n:common.tags.mk-signin.signin%' }</button>
|
||||
</form>
|
||||
<style>
|
||||
@ -39,6 +42,7 @@
|
||||
|
||||
input[type=text]
|
||||
input[type=password]
|
||||
input[type=number]
|
||||
user-select text
|
||||
display inline-block
|
||||
cursor auto
|
||||
@ -123,6 +127,10 @@
|
||||
this.refs.password.focus();
|
||||
return false;
|
||||
}
|
||||
if (this.user && this.user.two_factor_enabled && this.refs.token.value == '') {
|
||||
this.refs.token.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
this.update({
|
||||
signing: true
|
||||
@ -130,7 +138,8 @@
|
||||
|
||||
this.api('signin', {
|
||||
username: this.refs.username.value,
|
||||
password: this.refs.password.value
|
||||
password: this.refs.password.value,
|
||||
token: this.user && this.user.two_factor_enabled ? this.refs.token.value : undefined
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
}).catch(() => {
|
||||
|
@ -7,7 +7,7 @@
|
||||
<p class={ active: page == 'apps' } onmousedown={ setPage.bind(null, 'apps') }>%fa:puzzle-piece .fw%アプリ</p>
|
||||
<p class={ active: page == 'twitter' } onmousedown={ setPage.bind(null, 'twitter') }>%fa:B twitter .fw%Twitter</p>
|
||||
<p class={ active: page == 'signin' } onmousedown={ setPage.bind(null, 'signin') }>%fa:sign-in-alt .fw%ログイン履歴</p>
|
||||
<p class={ active: page == 'password' } onmousedown={ setPage.bind(null, 'password') }>%fa:unlock-alt .fw%%i18n:desktop.tags.mk-settings.password%</p>
|
||||
<p class={ active: page == 'security' } onmousedown={ setPage.bind(null, 'security') }>%fa:unlock-alt .fw%%i18n:desktop.tags.mk-settings.security%</p>
|
||||
<p class={ active: page == 'api' } onmousedown={ setPage.bind(null, 'api') }>%fa:key .fw%API</p>
|
||||
</div>
|
||||
<div class="pages">
|
||||
@ -59,11 +59,16 @@
|
||||
<mk-signin-history/>
|
||||
</section>
|
||||
|
||||
<section class="password" show={ page == 'password' }>
|
||||
<section class="password" show={ page == 'security' }>
|
||||
<h1>%i18n:desktop.tags.mk-settings.password%</h1>
|
||||
<mk-password-setting/>
|
||||
</section>
|
||||
|
||||
<section class="2fa" show={ page == 'security' }>
|
||||
<h1>%i18n:desktop.tags.mk-settings.2fa%</h1>
|
||||
<mk-2fa-setting/>
|
||||
</section>
|
||||
|
||||
<section class="api" show={ page == 'api' }>
|
||||
<h1>API</h1>
|
||||
<mk-api-info/>
|
||||
@ -285,3 +290,50 @@
|
||||
};
|
||||
</script>
|
||||
</mk-password-setting>
|
||||
|
||||
<mk-2fa-setting>
|
||||
<p><button onclick={ register }>%i18n:desktop.tags.mk-2fa-setting.register%</button></p>
|
||||
<div if={ data }>
|
||||
<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.scan%<br><img src={ data.qr }></li>
|
||||
<li>%i18n:desktop.tags.mk-2fa-setting.done%<br>
|
||||
<input type="number" ref="token"><button onclick={ submit }>%i18n:desktop.tags.mk-2fa-setting.submit%</button>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<style>
|
||||
:scope
|
||||
display block
|
||||
color #4a535a
|
||||
|
||||
</style>
|
||||
<script>
|
||||
import passwordDialog from '../scripts/password-dialog';
|
||||
import notify from '../scripts/notify';
|
||||
|
||||
this.mixin('api');
|
||||
|
||||
this.register = () => {
|
||||
passwordDialog('%i18n:desktop.tags.mk-2fa-setting.enter-password%', password => {
|
||||
this.api('i/2fa/register', {
|
||||
password: password
|
||||
}).then(data => {
|
||||
this.update({
|
||||
data: data
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
this.submit = () => {
|
||||
this.api('i/2fa/done', {
|
||||
token: this.refs.token.value
|
||||
}).then(() => {
|
||||
notify('%i18n:desktop.tags.mk-2fa-setting.success%');
|
||||
}).catch(() => {
|
||||
notify('%i18n:desktop.tags.mk-2fa-setting.failed%');
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</mk-2fa-setting>
|
||||
|
Reference in New Issue
Block a user