7199e6f4e0
* Update reaction.vue
* fix bug
* wip
* wip
* wjio
* wip
* Revert "wip"
This reverts commit e427f2160a
.
* wip
* wip
* wip
* Update init.ts
* Update drive-window.vue
* wip
* wip
* Use PascalCase for components
* Use PascalCase for components
* update dep
* wip
* wip
* wip
* Update init.ts
* wip
* Update paging.ts
* Update test.vue
* watch deep
* wip
* lint
* wip
* wip
* wip
* wip
* wiop
* wip
* Update webpack.config.ts
* alllow null poll
* wip
* wip
* wip
* wiop
* UI redesign & refactor (#6714)
* wip
* wip
* wip
* wip
* wip
* Update drive.vue
* Update word-mute.vue
* wip
* wip
* wip
* clean up
* wip
* Update default.vue
* wip
* Update notes.vue
* Update mfm.ts
* Update index.home.vue
* Update post-form.vue
* Update post-form-attaches.vue
* wip
* Update post-form.vue
* Update sidebar.vue
* wip
* wip
* Update index.vue
* wip
* Update default.vue
* Update index.vue
* Update index.vue
* wip
* Update post-form-attaches.vue
* Update note.vue
* wip
* clean up
* Update notes.vue
* wip
* wip
* Update ja-JP.yml
* wip
* wip
* Update index.vue
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* wip
* Update default.vue
* wip
* Update _dark.json5
* wip
* wip
* wip
* clean up
* wip
* wip
* Update index.vue
* Update test.vue
* wip
* wip
* fix
* wip
* wip
* wip
* wip
* clena yop
* wip
* wip
* Update store.ts
* Update messaging-room.vue
* Update default.widgets.vue
* fix
* wip
* wip
* Update modal.vue
* wip
* Update os.ts
* Update os.ts
* Update deck.vue
* Update init.ts
* wip
* Update ja-JP.yml
* v-sizeは単にwindowのresizeを監視するだけで良いかもしれない
* Update modal.vue
* wip
* Update tooltip.ts
* wip
* wip
* wip
* wip
* wip
* Update image-viewer.vue
* wip
* wip
* Update style.scss
* Update style.scss
* Update visitor.vue
* wip
* Update init.ts
* Update init.ts
* wip
* wip
* Update visitor.vue
* Update visitor.vue
* Update visitor.vue
* Update visitor.vue
* wip
* wip
* Update modal.vue
* Update header.vue
* Update menu.vue
* Update about.vue
* Update about-misskey.vue
* wip
* wip
* Update visitor.vue
* Update tooltip.ts
* wip
* Update drive.vue
* wip
* Update style.scss
* Update header.vue
* wip
* wip
* Update users.user.vue
* Update announcements.vue
* wip
* wip
* wip
* Update emojis.vue
* wip
* Update emojis.vue
* Update style.scss
* Update users.vue
* wip
* Update style.scss
* wip
* Update welcome.entrance.vue
* Update radio.vue
* Update size.ts
* Update emoji-edit-dialog.vue
* wip
* Update emojis.vue
* wip
* Update emojis.vue
* Update emojis.vue
* Update emojis.vue
* wip
* wip
* wip
* wip
* Update file-dialog.vue
* wip
* wip
* Update token-generate-window.vue
* Update notification-setting-window.vue
* wip
* wip
* Update _error_.vue
* Update ja-JP.yml
* wip
* wip
* Update store.ts
* Update emojis.vue
* Update emojis.vue
* Update emojis.vue
* Update announcements.vue
* Update store.ts
* wip
* Update page-editor.vue
* wip
* wip
* Update modal.vue
* wip
* Update select-file.ts
* Update timeline.vue
* Update emojis.vue
* Update os.ts
* wip
* Update user-select.vue
* Update mfm.ts
* Update get-file-info.ts
* Update drive.vue
* Update init.ts
* Update mfm.ts
* wip
* wip
* Update window.vue
* Update note.vue
* wip
* wip
* Update user-info.vue
* wip
* wip
* wip
* wip
* wip
* Update header.vue
* Update header.vue
* wip
* Update explore.vue
* wip
* wip
* wip
* Update webpack.config.ts
* wip
* wip
* wip
* wip
* wip
* wip
* Update autocomplete.ts
* wip
* wip
* wip
* Update toast.vue
* wip
* Update post-form-dialog.vue
* wip
* wip
* wip
* wip
* wip
* Update users.vue
* wip
* Update explore.vue
* wip
* wip
* wip
* Update package.json
* wip
* Update icon-dialog.vue
* wip
* wip
* Update user-preview.ts
* wip
* wip
* wip
* wip
* wip
* Update instance.vue
* Update user-name.vue
* Update federation.vue
* Update instance.vue
* wip
* wip
* Update tag.vue
* wip
* wip
* wip
* wip
* wip
* Update instance.vue
* wip
* Update os.ts
* Update os.ts
* wip
* wip
* wip
* Update router.ts
* wip
* Update init.ts
* Update note.vue
* Update messages.vue
* wip
* wip
* wip
* wip
* wip
* google
* wip
* wip
* wip
* wip
* Update theme-editor.vue
* wip
* wip
* Update room.vue
* Update channel-editor.vue
* wip
* Update window.vue
* Update window.vue
* wip
* Update window.vue
* Update window.vue
* wip
* Update menu.vue
* wip
* wip
* wip
* wip
* Update messaging-room.vue
* wip
* Update post-form.vue
* Update default.widgets.vue
* Update window.vue
* wip
212 lines
7.1 KiB
Vue
212 lines
7.1 KiB
Vue
<template>
|
|
<form class="mk-signup" @submit.prevent="onSubmit" :autocomplete="Math.random()">
|
|
<template v-if="meta">
|
|
<MkInput v-if="meta.disableRegistration" v-model:value="invitationCode" type="text" :autocomplete="Math.random()" spellcheck="false" required>
|
|
<span>{{ $t('invitationCode') }}</span>
|
|
<template #prefix><Fa :icon="faKey"/></template>
|
|
</MkInput>
|
|
<MkInput v-model:value="username" type="text" pattern="^[a-zA-Z0-9_]{1,20}$" :autocomplete="Math.random()" spellcheck="false" required @update:value="onChangeUsername">
|
|
<span>{{ $t('username') }}</span>
|
|
<template #prefix>@</template>
|
|
<template #suffix>@{{ host }}</template>
|
|
<template #desc>
|
|
<span v-if="usernameState == 'wait'" style="color:#999"><Fa :icon="faSpinner" pulse fixed-width/> {{ $t('checking') }}</span>
|
|
<span v-if="usernameState == 'ok'" style="color:#3CB7B5"><Fa :icon="faCheck" fixed-width/> {{ $t('available') }}</span>
|
|
<span v-if="usernameState == 'unavailable'" style="color:#FF1161"><Fa :icon="faExclamationTriangle" fixed-width/> {{ $t('unavailable') }}</span>
|
|
<span v-if="usernameState == 'error'" style="color:#FF1161"><Fa :icon="faExclamationTriangle" fixed-width/> {{ $t('error') }}</span>
|
|
<span v-if="usernameState == 'invalid-format'" style="color:#FF1161"><Fa :icon="faExclamationTriangle" fixed-width/> {{ $t('usernameInvalidFormat') }}</span>
|
|
<span v-if="usernameState == 'min-range'" style="color:#FF1161"><Fa :icon="faExclamationTriangle" fixed-width/> {{ $t('tooShort') }}</span>
|
|
<span v-if="usernameState == 'max-range'" style="color:#FF1161"><Fa :icon="faExclamationTriangle" fixed-width/> {{ $t('tooLong') }}</span>
|
|
</template>
|
|
</MkInput>
|
|
<MkInput v-model:value="password" type="password" :autocomplete="Math.random()" required @update:value="onChangePassword">
|
|
<span>{{ $t('password') }}</span>
|
|
<template #prefix><Fa :icon="faLock"/></template>
|
|
<template #desc>
|
|
<p v-if="passwordStrength == 'low'" style="color:#FF1161"><Fa :icon="faExclamationTriangle" fixed-width/> {{ $t('weakPassword') }}</p>
|
|
<p v-if="passwordStrength == 'medium'" style="color:#3CB7B5"><Fa :icon="faCheck" fixed-width/> {{ $t('normalPassword') }}</p>
|
|
<p v-if="passwordStrength == 'high'" style="color:#3CB7B5"><Fa :icon="faCheck" fixed-width/> {{ $t('strongPassword') }}</p>
|
|
</template>
|
|
</MkInput>
|
|
<MkInput v-model:value="retypedPassword" type="password" :autocomplete="Math.random()" required @update:value="onChangePasswordRetype">
|
|
<span>{{ $t('password') }} ({{ $t('retype') }})</span>
|
|
<template #prefix><Fa :icon="faLock"/></template>
|
|
<template #desc>
|
|
<p v-if="passwordRetypeState == 'match'" style="color:#3CB7B5"><Fa :icon="faCheck" fixed-width/> {{ $t('passwordMatched') }}</p>
|
|
<p v-if="passwordRetypeState == 'not-match'" style="color:#FF1161"><Fa :icon="faExclamationTriangle" fixed-width/> {{ $t('passwordNotMatched') }}</p>
|
|
</template>
|
|
</MkInput>
|
|
<MkSwitch v-model:value="ToSAgreement" v-if="meta.tosUrl">
|
|
<i18n-t keypath="agreeTo">
|
|
<a :href="meta.tosUrl" class="_link" target="_blank">{{ $t('tos') }}</a>
|
|
</i18n-t>
|
|
</MkSwitch>
|
|
<captcha v-if="meta.enableHcaptcha" class="captcha" provider="hcaptcha" ref="hcaptcha" v-model:value="hCaptchaResponse" :sitekey="meta.hcaptchaSiteKey"/>
|
|
<captcha v-if="meta.enableRecaptcha" class="captcha" provider="grecaptcha" ref="recaptcha" v-model:value="reCaptchaResponse" :sitekey="meta.recaptchaSiteKey"/>
|
|
<MkButton type="submit" :disabled="shouldDisableSubmitting" primary>{{ $t('start') }}</MkButton>
|
|
</template>
|
|
</form>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent, defineAsyncComponent } from 'vue';
|
|
import { faLock, faExclamationTriangle, faSpinner, faCheck, faKey } from '@fortawesome/free-solid-svg-icons';
|
|
const getPasswordStrength = require('syuilo-password-strength');
|
|
import { toUnicode } from 'punycode';
|
|
import { host, url } from '@/config';
|
|
import MkButton from './ui/button.vue';
|
|
import MkInput from './ui/input.vue';
|
|
import MkSwitch from './ui/switch.vue';
|
|
import * as os from '@/os';
|
|
|
|
export default defineComponent({
|
|
components: {
|
|
MkButton,
|
|
MkInput,
|
|
MkSwitch,
|
|
captcha: defineAsyncComponent(() => import('./captcha.vue')),
|
|
},
|
|
|
|
props: {
|
|
autoSet: {
|
|
type: Boolean,
|
|
required: false,
|
|
default: false,
|
|
}
|
|
},
|
|
|
|
emits: ['signup'],
|
|
|
|
data() {
|
|
return {
|
|
host: toUnicode(host),
|
|
username: '',
|
|
password: '',
|
|
retypedPassword: '',
|
|
invitationCode: '',
|
|
url,
|
|
usernameState: null,
|
|
passwordStrength: '',
|
|
passwordRetypeState: null,
|
|
submitting: false,
|
|
ToSAgreement: false,
|
|
hCaptchaResponse: null,
|
|
reCaptchaResponse: null,
|
|
faLock, faExclamationTriangle, faSpinner, faCheck, faKey
|
|
}
|
|
},
|
|
|
|
computed: {
|
|
meta() {
|
|
return this.$store.state.instance.meta;
|
|
},
|
|
|
|
shouldDisableSubmitting(): boolean {
|
|
return this.submitting ||
|
|
this.meta.tosUrl && !this.ToSAgreement ||
|
|
this.meta.enableHcaptcha && !this.hCaptchaResponse ||
|
|
this.meta.enableRecaptcha && !this.reCaptchaResponse ||
|
|
this.passwordRetypeState == 'not-match';
|
|
},
|
|
|
|
shouldShowProfileUrl(): boolean {
|
|
return (this.username != '' &&
|
|
this.usernameState != 'invalid-format' &&
|
|
this.usernameState != 'min-range' &&
|
|
this.usernameState != 'max-range');
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
onChangeUsername() {
|
|
if (this.username == '') {
|
|
this.usernameState = null;
|
|
return;
|
|
}
|
|
|
|
const err =
|
|
!this.username.match(/^[a-zA-Z0-9_]+$/) ? 'invalid-format' :
|
|
this.username.length < 1 ? 'min-range' :
|
|
this.username.length > 20 ? 'max-range' :
|
|
null;
|
|
|
|
if (err) {
|
|
this.usernameState = err;
|
|
return;
|
|
}
|
|
|
|
this.usernameState = 'wait';
|
|
|
|
os.api('username/available', {
|
|
username: this.username
|
|
}).then(result => {
|
|
this.usernameState = result.available ? 'ok' : 'unavailable';
|
|
}).catch(err => {
|
|
this.usernameState = 'error';
|
|
});
|
|
},
|
|
|
|
onChangePassword() {
|
|
if (this.password == '') {
|
|
this.passwordStrength = '';
|
|
return;
|
|
}
|
|
|
|
const strength = getPasswordStrength(this.password);
|
|
this.passwordStrength = strength > 0.7 ? 'high' : strength > 0.3 ? 'medium' : 'low';
|
|
},
|
|
|
|
onChangePasswordRetype() {
|
|
if (this.retypedPassword == '') {
|
|
this.passwordRetypeState = null;
|
|
return;
|
|
}
|
|
|
|
this.passwordRetypeState = this.password == this.retypedPassword ? 'match' : 'not-match';
|
|
},
|
|
|
|
onSubmit() {
|
|
if (this.submitting) return;
|
|
this.submitting = true;
|
|
|
|
os.api('signup', {
|
|
username: this.username,
|
|
password: this.password,
|
|
invitationCode: this.invitationCode,
|
|
'hcaptcha-response': this.hCaptchaResponse,
|
|
'g-recaptcha-response': this.reCaptchaResponse,
|
|
}).then(() => {
|
|
os.api('signin', {
|
|
username: this.username,
|
|
password: this.password
|
|
}).then(res => {
|
|
this.$emit('signup', res);
|
|
|
|
if (this.autoSet) {
|
|
localStorage.setItem('i', res.i);
|
|
location.reload();
|
|
}
|
|
});
|
|
}).catch(() => {
|
|
this.submitting = false;
|
|
this.$refs.hcaptcha?.reset?.();
|
|
this.$refs.recaptcha?.reset?.();
|
|
|
|
os.dialog({
|
|
type: 'error',
|
|
text: this.$t('somethingHappened')
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.mk-signup {
|
|
.captcha {
|
|
margin: 16px 0;
|
|
}
|
|
}
|
|
</style>
|