|
1 | 1 | <template> |
2 | | - <div data-test="password-reset-request"> |
| 2 | + <div> |
3 | 3 | <p class="my-4">Please provide the email of the account to reset the password for:</p> |
4 | | - <label> |
5 | | - <b-form-input type="text" name="email" v-model="input.reset_email" placeholder="Email" data-test="reset-email" /> |
6 | | - </label> |
7 | | - <b-button type="submit" v-on:click="resetPass()" variant="primary" data-test="reset-password-submit">Reset Password</b-button> |
8 | | - <alert v-bind:message="alertMessage" v-bind:type="alertType"/> |
| 4 | + <form class="login-container" v-on:submit.prevent="resetPass" data-test="reset-password-submit"> |
| 5 | + <label> |
| 6 | + <b-form-input type="text" name="email" v-model="input.reset_email" placeholder="Email" data-test="reset-email" required/> |
| 7 | + </label> |
| 8 | + <b-button type="submit" variant="primary">Reset Password</b-button> |
| 9 | + </form> |
| 10 | + <alert v-bind:message="alertMessage" v-bind:type="alertType" data-test="reset-password-alert"/> |
9 | 11 | </div> |
10 | 12 | </template> |
11 | 13 |
|
@@ -34,22 +36,18 @@ export default { |
34 | 36 | }, |
35 | 37 |
|
36 | 38 | methods: { |
37 | | - resetPass() { |
| 39 | + async resetPass() { |
38 | 40 | if (this.input.reset_email !== "") { |
39 | | - const response = postReset(this.input.reset_email) |
40 | | - this.changeAlert("Sending", "warning") |
41 | | - response |
42 | | - .then(data => { |
43 | | - if (data.status == 200) { |
44 | | - this.changeAlert("Password reset email sent!", "success") |
45 | | -
|
46 | | - } else { |
47 | | - this.changeAlert("Failed sending email", "warning") |
48 | | - } |
49 | | - }) |
50 | | - .catch(() => { |
51 | | - this.changeAlert("Failed sending email", "warning") |
52 | | - }) |
| 41 | + try { |
| 42 | + this.changeAlert("Sending", "warning") |
| 43 | + const response = await postReset(this.input.reset_email) |
| 44 | + if (response.status != 200) { |
| 45 | + throw Error() |
| 46 | + } |
| 47 | + this.changeAlert("Password reset email sent!", "success") |
| 48 | + } catch { |
| 49 | + this.changeAlert("Failed sending email", "warning") |
| 50 | + } |
53 | 51 | } |
54 | 52 | }, |
55 | 53 | changeAlert(message, type) { |
|
0 commit comments