add support for configuring server url. fixes #11
This commit is contained in:
+4
-2
@@ -5,7 +5,7 @@
|
||||
<div style="font-size: 4rem; color: #fff;" class="text-center">
|
||||
<Icon icon="person-circle" />
|
||||
</div>
|
||||
<b-form-group label="Server">
|
||||
<b-form-group v-if="!config.serverUrl" label="Server">
|
||||
<b-form-input v-model="server" name="server" type="text" :state="valid" />
|
||||
</b-form-group>
|
||||
<b-form-group label="Username">
|
||||
@@ -28,6 +28,7 @@
|
||||
</template>>
|
||||
<script lang="ts">
|
||||
import Vue from 'vue'
|
||||
import { config } from '@/shared/config'
|
||||
|
||||
export default Vue.extend({
|
||||
props: {
|
||||
@@ -47,7 +48,8 @@
|
||||
computed: {
|
||||
valid(): false | null {
|
||||
return this.error == null ? null : false
|
||||
}
|
||||
},
|
||||
config: () => config
|
||||
},
|
||||
async created() {
|
||||
this.server = await this.$auth.server
|
||||
|
||||
+6
-3
@@ -1,5 +1,6 @@
|
||||
import axios from 'axios'
|
||||
import { randomString, md5 } from '@/shared/utils'
|
||||
import { config } from '@/shared/config'
|
||||
|
||||
export class AuthService {
|
||||
public server = '';
|
||||
@@ -9,14 +10,16 @@ export class AuthService {
|
||||
private authenticated = false;
|
||||
|
||||
constructor() {
|
||||
this.server = localStorage.getItem('server') || '/api'
|
||||
this.username = localStorage.getItem('username') || 'guest1'
|
||||
this.server = config.serverUrl || localStorage.getItem('server') || ''
|
||||
this.username = localStorage.getItem('username') || ''
|
||||
this.salt = localStorage.getItem('salt') || ''
|
||||
this.hash = localStorage.getItem('hash') || ''
|
||||
}
|
||||
|
||||
private saveSession() {
|
||||
localStorage.setItem('server', this.server)
|
||||
if (!config.serverUrl) {
|
||||
localStorage.setItem('server', this.server)
|
||||
}
|
||||
localStorage.setItem('username', this.username)
|
||||
localStorage.setItem('salt', this.salt)
|
||||
localStorage.setItem('hash', this.hash)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export interface Config {
|
||||
serverUrl: string
|
||||
}
|
||||
|
||||
const env = (window as any).env
|
||||
|
||||
export const config: Config = {
|
||||
serverUrl: env?.SERVER_URL || '',
|
||||
}
|
||||
Reference in New Issue
Block a user