Skip to content

Commit

Permalink
Handle login/registration errors more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
ldscavo committed Nov 30, 2023
1 parent cbd9c6a commit b70cfef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 4 additions & 0 deletions client/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@ input.edit-field:focus {
color: red;
font-weight: bold;
}
.form-error {
color: red;
font-size: 0.9rem;
}
</style>
8 changes: 6 additions & 2 deletions client/src/components/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<label for="password">Password:</label>
<input id="password" class="form-input text" v-model="password" type="password" />
</div>
<div class="form-error" v-if="error">
<span>{{ error }}</span>
</div>
<div class="form-section">
<button type="submit" class="form-input">Login &raquo;</button>
</div>
Expand All @@ -28,7 +31,8 @@ export default {
data: function() {
return {
email: "",
password: ""
password: "",
error: ""
}
},
methods: {
Expand All @@ -40,7 +44,7 @@ export default {
this.$router.push({ path: '/budgets' });
}
catch (error) {
alert(error.response.data.error)
this.error = error.response.data.error;
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions client/src/components/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<input id="passwordconfirm" class="form-input text" v-model="passwordconfirm" type="password" />
<div class="warning" v-if="password !== passwordconfirm">Passwords do not match!</div>
</div>
<div class="form-error" v-if="error">
<span>{{ error }}</span>
</div>
<div class="form-section">
<button type="submit" class="form-input">Register &raquo;</button>
</div>
Expand All @@ -31,7 +34,8 @@ export default {
return {
email: '',
password: '',
passwordconfirm: ''
passwordconfirm: '',
error: ''
}
},
methods: {
Expand All @@ -43,7 +47,7 @@ export default {
this.$router.push({ path: '/budgets' });
}
catch (error) {
alert(error.response.data.error);
this.error = error.response.data.error;
}
}
}
Expand Down

0 comments on commit b70cfef

Please sign in to comment.