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

Merge branch 'display-email-error' into 'main'

Display email error

See merge request !149
parents f52672f5 b3069116
No related branches found
No related tags found
1 merge request!149Display email error
Pipeline #182092 failed
...@@ -25,14 +25,13 @@ ...@@ -25,14 +25,13 @@
v-for="(error, index) of v$.email.$errors" v-for="(error, index) of v$.email.$errors"
:key="index" :key="index"
> >
<div <div class="text-error-medium text-sm" v-show="showError">
class="text-error-medium text-sm"
v-show="showError"
id="emailErrorId"
>
{{ error.$message }} {{ error.$message }}
</div> </div>
</div> </div>
<div class="text-error-medium text-sm" v-show="errorMessage">
{{ errorMessage }}
</div>
</div> </div>
<div> <div>
...@@ -166,7 +165,7 @@ ...@@ -166,7 +165,7 @@
<script> <script>
import useVuelidate from "@vuelidate/core"; import useVuelidate from "@vuelidate/core";
import { doLogin, registerUser } from "@/utils/apiutil"; import { doLogin } from "@/utils/apiutil";
import { import {
required, required,
email, email,
...@@ -246,10 +245,7 @@ export default { ...@@ -246,10 +245,7 @@ export default {
//If a user is created succsessfully, try to login //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 we get this far, we will be pushed anyway so there is no point updating "loading"
if (!userCreated) { if (!userCreated) return;
this.errorMessage = "Could not create user.";
return;
}
const loginRequest = { const loginRequest = {
email: this.email, email: this.email,
...@@ -270,17 +266,16 @@ export default { ...@@ -270,17 +266,16 @@ export default {
await this.$router.push("/"); await this.$router.push("/");
}, },
async sendRegisterRequest() { async sendRegisterRequest() {
const registerInfo = { const userInfo = {
email: this.email, email: this.email,
firstName: this.firstName, firstName: this.firstName,
lastname: this.lastName, lastName: this.lastName,
password: this.password, password: this.password,
address: this.address, address: this.address,
}; };
const res = await UserService.registerUser(userInfo);
const response = await registerUser(registerInfo); this.errorMessage = res;
return res.status === 200;
return response.status === 200;
}, },
}, },
}; };
......
...@@ -124,5 +124,19 @@ class UserService { ...@@ -124,5 +124,19 @@ class UserService {
}) })
.catch((err) => console.log(err)); .catch((err) => console.log(err));
} }
async registerUser(userInfo) {
return await axios
.post(API_URL + "register", userInfo)
.then((res) => {
return res;
})
.catch((err) => {
if (err.response) {
return err.response.data;
}
console.error(err);
});
}
} }
export default new UserService(); export default new UserService();
...@@ -18,21 +18,6 @@ export function doLogin(loginRequest) { ...@@ -18,21 +18,6 @@ export function doLogin(loginRequest) {
}); });
} }
export function registerUser(registerInfo) {
return axios
.post(API_URL + "register", {
email: registerInfo.email,
firstName: registerInfo.firstName,
lastName: registerInfo.lastname,
password: registerInfo.password,
address: registerInfo.address,
})
.then((response) => {
return response;
})
.catch((err) => console.error(err));
}
export async function getUser(userid) { export async function getUser(userid) {
return axios return axios
.get(API_URL + "users/" + userid + "/profile", { .get(API_URL + "users/" + userid + "/profile", {
......
...@@ -24,6 +24,10 @@ exports[`RegisterFormComponent renders correctly 1`] = ` ...@@ -24,6 +24,10 @@ exports[`RegisterFormComponent renders correctly 1`] = `
<!-- error message --> <!-- error message -->
<div
class="text-error-medium text-sm"
style="display: none;"
/>
</div> </div>
<div> <div>
<input <input
......
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