If configs apiUrl not defined fallback to origin.

Also removed dependency of login and register to redirect response from
server. Now we send json data with status = 200 when successfully
login/registered.
Username input element also is set to not capitalize input.
This commit is contained in:
2020-03-10 19:00:08 +01:00
parent 410dfcca44
commit fc3b9d3eb5
3 changed files with 24 additions and 37 deletions

View File

@@ -4,14 +4,18 @@
<form aria-label="User signin" @submit.prevent>
<div class="label-div">
<label>Brukernavn</label>
<input type="text" v-model="username" placeholder="Brukernavn" @keyup.enter="login" />
<input type="text"
v-model="username"
placeholder="Brukernavn"
autocapitalize="none"
@keyup.enter="submit" />
</div>
<div class="label-div row">
<label>Passord</label>
<input type="password" v-model="password" placeholder="Passord" @keyup.enter="login" />
<input type="password" v-model="password" placeholder="Passord" @keyup.enter="submit" />
</div>
<button class="vin-button" @click="login">Logg inn</button>
<button class="vin-button" @click="submit">Logg inn</button>
<div v-if="error" class="error">{{ error }}</div>
</form>
@@ -29,16 +33,10 @@ export default {
}
},
methods: {
login() {
submit() {
login(this.username, this.password)
.then(resp => {
if (resp.redirected) { this.$router.push("update") }
})
.catch(this.loginErrorResponse)
},
loginErrorResponse(error) {
this.error = error.message || error
.then(resp => this.$router.push("update"))
.catch(error => this.error = error.message || error)
}
}
};