blob: c057e284df935861fe3d7c3af290302d13f9a5d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<template>
<div class="row justify-content-center">
<form>
<div class="form-group">
<label for="login">Login</label>
<input
type="text"
name="login"
v-model="name"
v-validate.initial="'required'"
class="form-control"
id="login"
/>
</div>
<div class="form-group">
<label for="password">Password</label>
<input
type="password"
name="password"
v-model="password"
v-validate.initial="'required'"
class="form-control"
id="password"
/>
</div>
<button type="button" class="btn btn-primary btn-xlg col-auto" @click="login()">Login</button>
</form>
</div>
</template>
<script>
import Vue from "vue";
import util from "./../services/Util.service.js";
import config from '../config.js'
var host = config.host;
export default {
name: "auth",
data() {
return {
name: "",
password: ""
};
},
methods: {
login() {
Vue.http.headers.common["Authorization"] =
"Basic " + btoa(this.name + ":" + this.password);
Vue.http.get(host + "/auth").then(
response => {
Vue.http.headers.common["Authorization"] = "Basic ";
Vue.http.headers.common["x-api-key"] = response.data;
localStorage.setItem("auth-key", response.data);
this.$router.push("models");
},
response => {
util.displayError("Unable to log in " + response);
}
);
}
}
};
</script>
|