This commit is contained in:
syuilo 2020-10-31 09:39:22 +09:00
parent 0baed1a275
commit cb16cb0610
3 changed files with 64 additions and 45 deletions

View File

@ -7,9 +7,7 @@
> >
<template #header>{{ $t('login') }}</template> <template #header>{{ $t('login') }}</template>
<div class="_section"> <MkSignin :auto-set="autoSet" @login="onLogin"/>
<MkSignin :auto-set="autoSet" @login="onLogin"/>
</div>
</XModalWindow> </XModalWindow>
</template> </template>

View File

@ -1,43 +1,47 @@
<template> <template>
<form class="eppvobhk" :class="{ signing, totpLogin }" @submit.prevent="onSubmit"> <form class="eppvobhk" :class="{ signing, totpLogin }" @submit.prevent="onSubmit">
<div class="avatar" :style="{ backgroundImage: user ? `url('${ user.avatarUrl }')` : null }" v-show="withAvatar"></div> <div class="auth _section">
<div class="normal-signin" v-if="!totpLogin"> <div class="avatar" :style="{ backgroundImage: user ? `url('${ user.avatarUrl }')` : null }" v-show="withAvatar"></div>
<MkInput v-model:value="username" type="text" pattern="^[a-zA-Z0-9_]+$" spellcheck="false" autofocus required @update:value="onUsernameChange"> <div class="normal-signin" v-if="!totpLogin">
<span>{{ $t('username') }}</span> <MkInput v-model:value="username" type="text" pattern="^[a-zA-Z0-9_]+$" spellcheck="false" autofocus required @update:value="onUsernameChange">
<template #prefix>@</template> <span>{{ $t('username') }}</span>
<template #suffix>@{{ host }}</template> <template #prefix>@</template>
</MkInput> <template #suffix>@{{ host }}</template>
<MkInput v-model:value="password" type="password" :with-password-toggle="true" v-if="!user || user && !user.usePasswordLessLogin" required> </MkInput>
<span>{{ $t('password') }}</span> <MkInput v-model:value="password" type="password" :with-password-toggle="true" v-if="!user || user && !user.usePasswordLessLogin" required>
<template #prefix><Fa :icon="faLock"/></template>
</MkInput>
<MkButton type="submit" primary :disabled="signing" style="margin: 0 auto;">{{ signing ? $t('loggingIn') : $t('login') }}</MkButton>
<a class="_panelButton" style="margin: 8px auto;" v-if="meta && meta.enableTwitterIntegration" :href="`${apiUrl}/signin/twitter`"><Fa :icon="faTwitter" style="margin-right: 4px;"/>{{ $t('signinWith', { x: 'Twitter' }) }}</a>
<a class="_panelButton" style="margin: 8px auto;" v-if="meta && meta.enableGithubIntegration" :href="`${apiUrl}/signin/github`"><Fa :icon="faGithub" style="margin-right: 4px;"/>{{ $t('signinWith', { x: 'GitHub' }) }}</a>
<a class="_panelButton" style="margin: 8px auto;" v-if="meta && meta.enableDiscordIntegration" :href="`${apiUrl}/signin/discord`"><Fa :icon="faDiscord" style="margin-right: 4px;"/>{{ $t('signinWith', { x: 'Discord' }) }}</a>
</div>
<div class="2fa-signin" v-if="totpLogin" :class="{ securityKeys: user && user.securityKeys }">
<div v-if="user && user.securityKeys" class="twofa-group tap-group">
<p>{{ $t('tapSecurityKey') }}</p>
<MkButton @click="queryKey" v-if="!queryingKey">
{{ $t('retry') }}
</MkButton>
</div>
<div class="or-hr" v-if="user && user.securityKeys">
<p class="or-msg">{{ $t('or') }}</p>
</div>
<div class="twofa-group totp-group">
<p style="margin-bottom:0;">{{ $t('twoStepAuthentication') }}</p>
<MkInput v-model:value="password" type="password" :with-password-toggle="true" v-if="user && user.usePasswordLessLogin" required>
<span>{{ $t('password') }}</span> <span>{{ $t('password') }}</span>
<template #prefix><Fa :icon="faLock"/></template> <template #prefix><Fa :icon="faLock"/></template>
</MkInput> </MkInput>
<MkInput v-model:value="token" type="text" pattern="^[0-9]{6}$" autocomplete="off" spellcheck="false" required> <MkButton type="submit" primary :disabled="signing" style="margin: 0 auto;">{{ signing ? $t('loggingIn') : $t('login') }}</MkButton>
<span>{{ $t('token') }}</span>
<template #prefix><Fa :icon="faGavel"/></template>
</MkInput>
<MkButton type="submit" :disabled="signing" primary style="margin: 0 auto;">{{ signing ? $t('loggingIn') : $t('login') }}</MkButton>
</div> </div>
<div class="2fa-signin" v-if="totpLogin" :class="{ securityKeys: user && user.securityKeys }">
<div v-if="user && user.securityKeys" class="twofa-group tap-group">
<p>{{ $t('tapSecurityKey') }}</p>
<MkButton @click="queryKey" v-if="!queryingKey">
{{ $t('retry') }}
</MkButton>
</div>
<div class="or-hr" v-if="user && user.securityKeys">
<p class="or-msg">{{ $t('or') }}</p>
</div>
<div class="twofa-group totp-group">
<p style="margin-bottom:0;">{{ $t('twoStepAuthentication') }}</p>
<MkInput v-model:value="password" type="password" :with-password-toggle="true" v-if="user && user.usePasswordLessLogin" required>
<span>{{ $t('password') }}</span>
<template #prefix><Fa :icon="faLock"/></template>
</MkInput>
<MkInput v-model:value="token" type="text" pattern="^[0-9]{6}$" autocomplete="off" spellcheck="false" required>
<span>{{ $t('token') }}</span>
<template #prefix><Fa :icon="faGavel"/></template>
</MkInput>
<MkButton type="submit" :disabled="signing" primary style="margin: 0 auto;">{{ signing ? $t('loggingIn') : $t('login') }}</MkButton>
</div>
</div>
</div>
<div class="social _section">
<a class="_borderButton _vMargin" v-if="meta && meta.enableTwitterIntegration" :href="`${apiUrl}/signin/twitter`"><Fa :icon="faTwitter" style="margin-right: 4px;"/>{{ $t('signinWith', { x: 'Twitter' }) }}</a>
<a class="_borderButton _vMargin" v-if="meta && meta.enableGithubIntegration" :href="`${apiUrl}/signin/github`"><Fa :icon="faGithub" style="margin-right: 4px;"/>{{ $t('signinWith', { x: 'GitHub' }) }}</a>
<a class="_borderButton _vMargin" v-if="meta && meta.enableDiscordIntegration" :href="`${apiUrl}/signin/discord`"><Fa :icon="faDiscord" style="margin-right: 4px;"/>{{ $t('signinWith', { x: 'Discord' }) }}</a>
</div> </div>
</form> </form>
</template> </template>
@ -203,14 +207,16 @@ export default defineComponent({
<style lang="scss" scoped> <style lang="scss" scoped>
.eppvobhk { .eppvobhk {
> .avatar { > .auth {
margin: 0 auto 0 auto; > .avatar {
width: 64px; margin: 0 auto 0 auto;
height: 64px; width: 64px;
background: #ddd; height: 64px;
background-position: center; background: #ddd;
background-size: cover; background-position: center;
border-radius: 100%; background-size: cover;
border-radius: 100%;
}
} }
} }
</style> </style>

View File

@ -297,6 +297,21 @@ hr {
padding: 12px 0; padding: 12px 0;
} }
._borderButton {
@extend ._button;
display: block;
width: 100%;
padding: 10px;
box-sizing: border-box;
text-align: center;
border: solid 1px var(--divider);
border-radius: var(--radius);
&:active {
border-color: var(--accent);
}
}
._popup { ._popup {
background: var(--panel); background: var(--panel);
border-radius: var(--radius); border-radius: var(--radius);