Skip to content
Snippets Groups Projects
Commit 6d216cf1 authored by Titus Netland's avatar Titus Netland
Browse files

Upgraded the authentication mechanism is apiutil and login

parent ce24d172
No related branches found
No related tags found
1 merge request!12API login mock tests
Pipeline #175725 failed
......@@ -90,7 +90,7 @@
>
</div>
</div>
<div class="flex flex-row min-h-screen justify-center items-center">
<div class="flex justify-center">
<label>{{ message }}</label>
</div>
</div>
......@@ -153,11 +153,17 @@ export default {
const loginResponse = await doLogin(loginRequest);
if (loginResponse.data === "Login failed") {
if (loginResponse.isLoggedIn === false) {
this.message = "Feil e-post/passord";
this.$store.commit("logout");
} else {
}
else if(loginResponse.isLoggedIn === true){
this.$store.commit("saveToken", loginResponse);
this.message = loginResponse.token;
console.log("Logged in")
}
else {
console.log("Something went wrong")
}
},
......
import axios from "axios";
export function doLogin(loginRequest) {
const auth = {isLoggedIn: false, token: ""};
return axios
.post(process.env.VUE_APP_BASEURL + "login/authentication", loginRequest)
.then((response) => {
return response.data;
auth.isLoggedIn = true;
auth.token = response.data;
return auth;
})
.catch((error) => {
console.log(error.response);
return error.response;
return auth;
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment