From 32ede9325c6653bf28f104ff04b2b49d9264207d Mon Sep 17 00:00:00 2001 From: kharann Date: Thu, 19 Mar 2020 19:52:32 +0100 Subject: [PATCH 1/2] Add prompt to set display name --- src/components/LoginArea.vue | 13 ++++++++++++- src/helpers/auth.js | 25 +++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/components/LoginArea.vue b/src/components/LoginArea.vue index 9c89276..3a7bbe4 100644 --- a/src/components/LoginArea.vue +++ b/src/components/LoginArea.vue @@ -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: "Telefonnummer", + body: "Skriv inn telefonnummeret ditt uten landskode", + promptHelp: `Skriv ditt telefonnummer i boksen under og trykk "[+:okText]"` + }, + { + okText: "Fortsett", + cancelText: "Lukk", + customClass: "phone-prompt" + } + ).then(dialog => dialog.data); } await fb .signInWithEmailLink(email, url) diff --git a/src/helpers/auth.js b/src/helpers/auth.js index 4df0c17..1dfd700 100644 --- a/src/helpers/auth.js +++ b/src/helpers/auth.js @@ -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 => { From c08c28920993fcf93099251393dc20e5d2dcf117 Mon Sep 17 00:00:00 2001 From: kharann Date: Thu, 19 Mar 2020 19:53:37 +0100 Subject: [PATCH 2/2] quick prompt when logging in with another device --- src/components/LoginArea.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/LoginArea.vue b/src/components/LoginArea.vue index 3a7bbe4..d099c75 100644 --- a/src/components/LoginArea.vue +++ b/src/components/LoginArea.vue @@ -82,9 +82,9 @@ export default { // If the user opens the link on another device email = this.$dialog.prompt( { - title: "Telefonnummer", - body: "Skriv inn telefonnummeret ditt uten landskode", - promptHelp: `Skriv ditt telefonnummer i boksen under og trykk "[+:okText]"` + title: "Epostadresse", + body: "Skriv inn epostadressen din", + promptHelp: `Skriv din epostadresse i boksen under og trykk "[+:okText]"` }, { okText: "Fortsett",