Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #155 from s0lvang/hotfix/displayname
Browse files Browse the repository at this point in the history
Pop a prompt asking for display name if not set
  • Loading branch information
s0lvang authored Mar 19, 2020
2 parents f9a8963 + c08c289 commit 14ab5f0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/components/LoginArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ export default {
let email = window.localStorage.getItem("emailForSignIn");
if (!email) {
// If the user opens the link on another device
email = window.prompt("Skriv inn epostadressen din");
email = this.$dialog.prompt(
{
title: "Epostadresse",
body: "Skriv inn epostadressen din",
promptHelp: `Skriv din epostadresse i boksen under og trykk "[+:okText]"`
},
{
okText: "Fortsett",
cancelText: "Lukk",
customClass: "phone-prompt"
}
).then(dialog => dialog.data);
}
await fb
.signInWithEmailLink(email, url)
Expand Down
25 changes: 23 additions & 2 deletions src/helpers/auth.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
import firebase from "firebase";
import fb from "@/firebaseConfig.js";

export const handleSignedIn = (context, user) => {
fb.additionalUserInfoCollection
export const handleSignedIn = async(context, user) => {
if (!user.displayName) {
await context.$dialog
.prompt(
{
title: "Navn",
body: "Skriv inn navnet ditt",
promptHelp: `Skriv ditt navn i boksen under og trykk "[+:okText]"`
},
{
okText: "Fortsett",
cancelText: "Lukk",
customClass: "phone-prompt"
}
)
.then(dialog => {
if (!dialog.data) {
throw new Error("Venligst skriv inn et navn");
}
user.updateProfile({ displayName: user.data });
});
}
await fb.additionalUserInfoCollection
.doc(user.uid)
.get()
.then(userInfo => {
Expand Down

0 comments on commit 14ab5f0

Please sign in to comment.