Skip to content

Commit

Permalink
feat: add forgot password feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jkklapp committed Jun 9, 2022
1 parent 14792bb commit dc716e5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
9 changes: 9 additions & 0 deletions frontend/src/components/Login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,13 @@ describe('Login', () => {
});
});
});
describe('forgot password link', () => {
it('is enabled', () => {
const wrapper = mountComponent();

const link = wrapper.find('a');

expect(link.exists()).toBe(true);
});
});
});
27 changes: 25 additions & 2 deletions frontend/src/components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
/>
</div>
</div>
<div class="grid place-items-center">
<div class="flex place-items-stretch">
<button
type="submit"
:disabled="!form.email || !form.password"
Expand All @@ -67,6 +67,15 @@
Login
</button>
<div class="mb-2 md:mx-14"></div>
<div class="mt-2">
<a
class="text-gray-700 dark:text-gray-300 align-bottom"
href="#"
@click.prevent="forgotPassword"
>
<small>Forgot password?</small>
</a>
</div>
</div>
</form>
</div>
Expand All @@ -77,7 +86,10 @@

<script>
import { getAuth } from '../auth';
import { signInWithEmailAndPassword } from 'firebase/auth';
import {
signInWithEmailAndPassword,
sendPasswordResetEmail,
} from 'firebase/auth';
import Email from './misc/icons/Email.vue';
import Password from './misc/icons/Password.vue';
Expand Down Expand Up @@ -109,6 +121,17 @@ export default {
console.log(err);
});
},
async forgotPassword() {
try {
await sendPasswordResetEmail(getAuth(), this.form.email);
} catch {
// empty
} finally {
this.$root.$toast.success(
'An email has been sent to your email address with instructions to reset your password.',
);
}
},
},
};
</script>

0 comments on commit dc716e5

Please sign in to comment.