diff --git a/client/src/components/connect.vue b/client/src/components/connect.vue index 7ae1962..cab5f74 100644 --- a/client/src/components/connect.vue +++ b/client/src/components/connect.vue @@ -6,9 +6,10 @@ n.eko
- {{ $t('connect.title') }} + {{ $t('connect.login_title') }} + {{ $t('connect.invitation_title') }} - + @@ -158,13 +159,29 @@ this.$accessor.login({ displayname: this.$accessor.displayname, password: this.$accessor.password }) } } + get autoPassword() { + return new URL(location.href).searchParams.get('pwd') + } get connecting() { return this.$accessor.connecting } - login() { - this.$accessor.login({ displayname: this.displayname, password: this.password }) + async login() { + 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', + }) + } } } diff --git a/client/src/locale/en-us.ts b/client/src/locale/en-us.ts index b552a37..5c64d53 100644 --- a/client/src/locale/en-us.ts +++ b/client/src/locale/en-us.ts @@ -10,10 +10,12 @@ export const side = { } export const connect = { - title: 'Please Login', - displayname: 'Display Name', + login_title: 'Please Login', + invitation_title: 'You have been invited to this room', + displayname: 'Enter your display name', password: 'Password', connect: 'Connect', + error: 'Login error', } export const context = { diff --git a/client/src/neko/base.ts b/client/src/neko/base.ts index 85ec947..16797af 100644 --- a/client/src/neko/base.ts +++ b/client/src/neko/base.ts @@ -52,7 +52,7 @@ export abstract class BaseClient extends EventEmitter { } if (displayname === '') { - throw new Error('Must add a displayname') // TODO: Better handling + throw new Error('Display Name cannot be empty.') } this._displayname = displayname