This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import ayconfig from "../utils/config";
|
||||
|
||||
export default {
|
||||
authenticate(login, password) {
|
||||
fetch(ayconfig.apiUrl + "/auth", {
|
||||
login: login,
|
||||
password: password
|
||||
})
|
||||
.then(function(response) {
|
||||
if (response.status != 200) {
|
||||
alert("Error: " + response.statusText);
|
||||
return;
|
||||
}
|
||||
// Handle response you get from the server
|
||||
response.json().then(function(data) {
|
||||
//set token in config here
|
||||
return data;
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
alert("Fetch Error :-S", err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
4
app/ayanova/src/utils/config.js
Normal file
4
app/ayanova/src/utils/config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export default {
|
||||
apiUrl: "http://localhost:7575/api/v8.0/",
|
||||
apiToken: ""
|
||||
};
|
||||
@@ -1,13 +1,14 @@
|
||||
<template>
|
||||
<div id="login">
|
||||
<h1>Login</h1>
|
||||
<input type="text" name="username" v-model="input.username" placeholder="Username">
|
||||
<input type="password" name="password" v-model="input.password" placeholder="Password">
|
||||
<button type="button" v-on:click="login()">Login</button>
|
||||
</div>
|
||||
<div id="login">
|
||||
<h1>Login</h1>
|
||||
<input type="text" name="username" v-model="input.username" placeholder="Username">
|
||||
<input type="password" name="password" v-model="input.password" placeholder="Password">
|
||||
<button type="button" v-on:click="login()">Login</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import auth from "../api/auth";
|
||||
export default {
|
||||
name: "Login",
|
||||
data() {
|
||||
@@ -21,6 +22,12 @@ export default {
|
||||
methods: {
|
||||
login() {
|
||||
if (this.input.username != "" && this.input.password != "") {
|
||||
// eslint-disable-next-line
|
||||
var response = auth.authenticate(
|
||||
this.input.username,
|
||||
this.input.password
|
||||
);
|
||||
|
||||
if (
|
||||
this.input.username == this.$store.state.mockAccount.username &&
|
||||
this.input.password == this.$store.state.mockAccount.password
|
||||
|
||||
Reference in New Issue
Block a user