Skip to content

Commit 4ace79c

Browse files
committed
[CODEBREW] Added password reset function
1 parent 9056c72 commit 4ace79c

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

src/components/LoginForm.vue

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
<template>
22
<div class="hello">
33
<h1>{{ msg }}</h1>
4-
<form
5-
>
6-
<input type="email" v-model="email" placeholder="Email Adresse">
7-
<br>
8-
<input type="password" v-model="password" placeholder="Passwort">
9-
<br>
10-
<input type="button" value="LOG IN" @click="login">
11-
</form>
4+
<form>
5+
<input type="email" v-model="email" placeholder="Email Adresse" />
6+
<br />
7+
<input type="password" v-model="password" placeholder="Passwort" />
8+
<br />
9+
<input type="button" value="LOG IN" @click="login" />
10+
<input type="button" value="RESET PASSWORD" @click="resetPassword" />
11+
</form>
1212
</div>
1313
</template>
1414

1515
<script>
1616
export default {
17-
name: 'LoginForm',
17+
name: "LoginForm",
1818
props: {
19-
msg: String
19+
msg: String,
2020
},
2121
2222
data() {
2323
return {
2424
email: "",
25-
password: ""
26-
}
25+
password: "",
26+
};
2727
},
2828
2929
methods: {
3030
login() {
3131
this.$emit("login", {
3232
email: this.email,
33-
password: this.password
34-
})
33+
password: this.password,
34+
});
35+
},
36+
resetPassword() {
37+
this.$emit("resetPassword", this.email);
3538
},
3639
},
37-
}
40+
};
3841
</script>
3942

4043
<!-- Add "scoped" attribute to limit CSS to this component only -->

src/store/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ export default new Vuex.Store({
3939
fb.auth.signOut();
4040
commit("setUser", {});
4141
},
42+
async resetPassword({ commit }, email) {
43+
return fb.auth
44+
.sendPasswordResetEmail(email)
45+
.then((res) => {
46+
commit("setUser", {});
47+
return res;
48+
})
49+
.catch((err) => {
50+
return err;
51+
});
52+
},
4253
async uploadProfilePicture({ commit }, payload) {
4354
var storageRef = fb.storage.ref();
4455
var pictureRef = storageRef.child(

src/views/Index.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<template>
22
<div id="app">
33
<img alt="Vue logo" src="@/assets/logo.png" />
4-
<LoginForm @login="login" v-if="!user.uid" msg="Bitte einloggen" />
4+
<LoginForm
5+
@login="login"
6+
@resetPassword="resetPassword"
7+
v-if="!user.uid"
8+
msg="Bitte einloggen"
9+
/>
510
</div>
611
</template>
712

@@ -28,6 +33,12 @@ export default {
2833
this.$router.push("/dashboard");
2934
});
3035
},
36+
resetPassword(email) {
37+
console.log("Email reset: " + email);
38+
this.$store.dispatch("resetPassword", email).then(() => {
39+
alert("Password Reset sent out to: " + email);
40+
});
41+
},
3142
},
3243
};
3344
</script>

0 commit comments

Comments
 (0)