Skip to content
Snippets Groups Projects
Commit dd95e141 authored by Erik Borgeteien Hansen's avatar Erik Borgeteien Hansen
Browse files

add error message display for user

parent d61d8d9c
No related branches found
No related tags found
Loading
Pipeline #175515 passed
......@@ -108,6 +108,7 @@
<strong>{{ error.$message }}</strong>
</p>
</section>
<p v-if="errorMessage">{{ errorMessage }}</p>
</template>
<script>
......@@ -122,6 +123,7 @@ export default {
setup: () => ({ v$: useVuelidate() }),
data() {
return {
errorMessage: "",
loading: false,
email: "",
pword: "",
......@@ -165,24 +167,27 @@ export default {
//If a user is created succsessfully, try to login
//If we get this far, we will be pushed anyway so there is no point updating "loading"
if (userCreated) {
const loginRequest = {
email: this.email,
password: this.pword,
};
const loginResponse = await doLogin(loginRequest);
if (loginResponse === "Failed login") {
this.message = "kunne ikke logge inn";
this.$store.commit("logout");
this.$router.push("/login");
return;
}
this.$store.commit("saveToken", loginResponse);
this.$router.push("/");
if (!userCreated) {
this.errorMessage = "Could not create user.";
return;
}
const loginRequest = {
email: this.email,
password: this.pword,
};
const loginResponse = await doLogin(loginRequest);
if (loginResponse === "Failed login") {
this.errorMessage = "Failed to log in with new user";
this.$store.commit("logout");
this.$router.push("/login");
return;
}
this.$store.commit("saveToken", loginResponse);
this.$router.push("/");
},
async sendRegisterRequest() {
const registerInfo = {
......
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