invite links.

This commit is contained in:
m1k1o 2021-03-10 21:35:40 +01:00
parent 9e64b47dea
commit d763895665
3 changed files with 26 additions and 7 deletions

View File

@ -6,9 +6,10 @@
<span><b>n</b>.eko</span> <span><b>n</b>.eko</span>
</div> </div>
<form class="message" v-if="!connecting" @submit.stop.prevent="connect"> <form class="message" v-if="!connecting" @submit.stop.prevent="connect">
<span>{{ $t('connect.title') }}</span> <span v-if="!autoPassword">{{ $t('connect.login_title') }}</span>
<span v-else>{{ $t('connect.invitation_title') }}</span>
<input type="text" :placeholder="$t('connect.displayname')" v-model="displayname" /> <input type="text" :placeholder="$t('connect.displayname')" v-model="displayname" />
<input type="password" :placeholder="$t('connect.password')" v-model="password" /> <input type="password" :placeholder="$t('connect.password')" v-model="password" v-if="!autoPassword" />
<button type="submit" @click.stop.prevent="login"> <button type="submit" @click.stop.prevent="login">
{{ $t('connect.connect') }} {{ $t('connect.connect') }}
</button> </button>
@ -158,13 +159,29 @@
this.$accessor.login({ displayname: this.$accessor.displayname, password: this.$accessor.password }) this.$accessor.login({ displayname: this.$accessor.displayname, password: this.$accessor.password })
} }
} }
get autoPassword() {
return new URL(location.href).searchParams.get('pwd')
}
get connecting() { get connecting() {
return this.$accessor.connecting return this.$accessor.connecting
} }
login() { async login() {
this.$accessor.login({ displayname: this.displayname, password: this.password }) let password = this.password
if (this.autoPassword) {
password = this.autoPassword
}
try {
await this.$accessor.login({ displayname: this.displayname, password })
} catch (err) {
this.$swal({
title: this.$t('connect.error') as string,
text: err.message,
icon: 'error',
})
}
} }
} }
</script> </script>

View File

@ -10,10 +10,12 @@ export const side = {
} }
export const connect = { export const connect = {
title: 'Please Login', login_title: 'Please Login',
displayname: 'Display Name', invitation_title: 'You have been invited to this room',
displayname: 'Enter your display name',
password: 'Password', password: 'Password',
connect: 'Connect', connect: 'Connect',
error: 'Login error',
} }
export const context = { export const context = {

View File

@ -52,7 +52,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
} }
if (displayname === '') { if (displayname === '') {
throw new Error('Must add a displayname') // TODO: Better handling throw new Error('Display Name cannot be empty.')
} }
this._displayname = displayname this._displayname = displayname