Skip to content

Commit

Permalink
Merge pull request #1 from trywilco/289-url-inclusion
Browse files Browse the repository at this point in the history
m1k1o#289 started work on it
  • Loading branch information
darmalovan authored Feb 28, 2024
2 parents 6ed3493 + b714ba1 commit 379764d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
16 changes: 14 additions & 2 deletions client/src/components/connect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@
@Component({ name: 'neko-connect' })
export default class extends Vue {
private autoPassword: string | null = new URL(location.href).searchParams.get('pwd')
private autoUrl: string | null = new URL(location.href).searchParams.get('url')
private displayname: string = ''
private password: string = ''
private url: string = ''
mounted() {
// auto-password fill
Expand All @@ -164,6 +166,11 @@
password = this.autoPassword
}
let url = this.$accessor.browseurl
if (this.autoUrl !== null) {
url = this.autoUrl
}
// auto-user fill
let displayname = this.$accessor.displayname
const usr = new URL(location.href).searchParams.get('usr')
Expand All @@ -173,7 +180,7 @@
}
if (displayname !== '' && password !== '') {
this.$accessor.login({ displayname, password })
this.$accessor.login({ displayname, password, browseurl: url })
this.autoPassword = null
}
}
Expand Down Expand Up @@ -209,6 +216,11 @@
password = this.autoPassword
}
let url = this.url
if (this.autoUrl !== null) {
url = this.autoUrl
}
if (this.displayname == '') {
this.$swal({
title: this.$t('connect.error') as string,
Expand All @@ -218,7 +230,7 @@
return
}
this.$accessor.login({ displayname: this.displayname, password })
this.$accessor.login({ displayname: this.displayname, password, browseurl: url })
this.autoPassword = null
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/neko/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
return this.peerConnected && this.socketOpen
}

public connect(url: string, password: string, displayname: string) {
public connect(url: string, password: string, displayname: string, browseurl: string) {
if (this.socketOpen) {
this.emit('warn', `attempting to create websocket while connection open`)
return
Expand Down
4 changes: 2 additions & 2 deletions client/src/neko/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
this.$accessor.chat.reset()
}

login(password: string, displayname: string) {
this.connect(this.url, password, displayname)
login(password: string, displayname: string, browseurl: string) {
this.connect(this.url, password, displayname, browseurl)
}

logout() {
Expand Down
13 changes: 8 additions & 5 deletions client/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as emoji from './emoji'
export const state = () => ({
displayname: get<string>('displayname', ''),
password: get<string>('password', ''),
browseurl: get<string>('url', ''),
active: false,
connecting: false,
connected: false,
Expand All @@ -28,9 +29,10 @@ export const mutations = mutationTree(state, {
state.active = true
},

setLogin(state, { displayname, password }: { displayname: string; password: string }) {
setLogin(state, { displayname, password, browseurl }: { displayname: string; password: string, browseurl: string }) {
state.displayname = displayname
state.password = password
state.browseurl = browseurl
},

setLocked(state, resource: string) {
Expand Down Expand Up @@ -92,15 +94,16 @@ export const actions = actionTree(
}
},

login(store, { displayname, password }: { displayname: string; password: string }) {
accessor.setLogin({ displayname, password })
$client.login(password, displayname)
login(store, { displayname, password, browseurl }: { displayname: string; password: string, browseurl: string }) {
accessor.setLogin({ displayname, password, browseurl })
$client.login(password, displayname, browseurl)
},

logout() {
accessor.setLogin({ displayname: '', password: '' })
accessor.setLogin({ displayname: '', password: '', browseurl: '' })
set('displayname', '')
set('password', '')
set('browseurl', '')
$client.logout()
},
},
Expand Down

0 comments on commit 379764d

Please sign in to comment.