feat: sign in with microsoft

This commit is contained in:
liyasthomas
2022-03-03 09:06:35 +05:30
parent 484fcd7365
commit b7988b54c5
38 changed files with 139 additions and 23 deletions

View File

@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg"
aria-label="Email" role="img"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%"
fill="teal"/><rect width="356" height="256" x="78" y="128" fill="#fff" rx="8%"/><path fill="none" stroke="teal" stroke-width="20" d="M434 128L269 292c-7 8-19 8-26 0L78 128m0 256l129-128m227 128L305 256"/></svg>

After

Width:  |  Height:  |  Size: 344 B

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="256px" height="250px" viewBox="0 0 256 250" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
<g>
<path d="M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z" fill="currentColor"></path>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg"
aria-label="GitHub" role="img"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%"
fill="#181717"/><path fill="#fff" d="M335 499c14 0 12 17 12 17H165s-2-17 12-17c13 0 16-6 16-12l-1-44c-71 16-86-34-86-34-12-30-28-37-28-37-24-16 1-16 1-16 26 2 40 26 40 26 22 39 59 28 74 22 2-17 9-28 16-35-57-6-116-28-116-126 0-28 10-51 26-69-3-6-11-32 3-67 0 0 21-7 70 26 42-12 86-12 128 0 49-33 70-26 70-26 14 35 6 61 3 67 16 18 26 41 26 69 0 98-60 120-117 126 10 8 18 24 18 48l-1 70c0 6 3 12 16 12z"/></svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 544 B

View File

@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="256px" height="262px" viewBox="0 0 256 262" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
<g>
<path d="M255.878,133.451 C255.878,122.717 255.007,114.884 253.122,106.761 L130.55,106.761 L130.55,155.209 L202.497,155.209 C201.047,167.249 193.214,185.381 175.807,197.565 L175.563,199.187 L214.318,229.21 L217.003,229.478 C241.662,206.704 255.878,173.196 255.878,133.451" fill="currentColor"></path>
<path d="M130.55,261.1 C165.798,261.1 195.389,249.495 217.003,229.478 L175.807,197.565 C164.783,205.253 149.987,210.62 130.55,210.62 C96.027,210.62 66.726,187.847 56.281,156.37 L54.75,156.5 L14.452,187.687 L13.925,189.152 C35.393,231.798 79.49,261.1 130.55,261.1" fill="currentColor"></path>
<path d="M56.281,156.37 C53.525,148.247 51.93,139.543 51.93,130.55 C51.93,121.556 53.525,112.853 56.136,104.73 L56.063,103 L15.26,71.312 L13.925,71.947 C5.077,89.644 0,109.517 0,130.55 C0,151.583 5.077,171.455 13.925,189.152 L56.281,156.37" fill="currentColor"></path>
<path d="M130.55,50.479 C155.064,50.479 171.6,61.068 181.029,69.917 L217.873,33.943 C195.245,12.91 165.798,0 130.55,0 C79.49,0 35.393,29.301 13.925,71.947 L56.136,104.73 C66.726,73.253 96.027,50.479 130.55,50.479" fill="currentColor"></path>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg"
aria-label="Google" role="img"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%"
fill="#fff"/><path fill="#4285f4" d="M386 400c45-42 65-112 53-179H260v74h102c-4 24-18 44-38 57z"/><path fill="#34a853" d="M90 341a192 192 0 0 0 296 59l-62-48c-53 35-141 22-171-60z"/><path fill="#fbbc02" d="M153 292c-8-25-8-48 0-73l-63-49c-23 46-30 111 0 171z"/><path fill="#ea4335" d="M153 219c22-69 116-109 179-50l55-54c-78-75-230-72-297 55z"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 486 B

View File

@@ -0,0 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg"
aria-label="Microsoft" role="img"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%"
fill="#fff"/><path
d="M75 75v171h171v-171z" fill="#f25022"/><path
d="M266 75v171h171v-171z" fill="#7fba00"/><path
d="M75 266v171h171v-171z" fill="#00a4ef"/><path
d="M266 266v171h171v-171z" fill="#ffb900"/></svg>

After

Width:  |  Height:  |  Size: 349 B

View File

@@ -21,7 +21,13 @@
@click.native="signInWithGoogle"
/>
<SmartItem
icon="mail"
:loading="signingInWithMicrosoft"
svg="auth/microsoft"
:label="`${$t('auth.continue_with_microsoft')}`"
@click.native="signInWithMicrosoft"
/>
<SmartItem
svg="auth/email"
:label="`${$t('auth.continue_with_email')}`"
@click.native="mode = 'email'"
/>
@@ -117,6 +123,7 @@ import { defineComponent } from "@nuxtjs/composition-api"
import {
signInUserWithGoogle,
signInUserWithGithub,
signInUserWithMicrosoft,
setProviderInfo,
currentUser$,
signInWithEmail,
@@ -144,6 +151,7 @@ export default defineComponent({
},
signingInWithGoogle: false,
signingInWithGitHub: false,
signingInWithMicrosoft: false,
signingInWithEmail: false,
mode: "sign-in",
}
@@ -234,6 +242,42 @@ export default defineComponent({
this.signingInWithGitHub = false
},
async signInWithMicrosoft() {
this.signingInWithMicrosoft = true
try {
await signInUserWithMicrosoft()
this.showLoginSuccess()
} catch (e) {
console.error(e)
// An error happened.
if (e.code === "auth/account-exists-with-different-credential") {
// Step 2.
// User's email already exists.
// The pending Microsoft credential.
const pendingCred = e.credential
this.$toast.info(`${this.$t("auth.account_exists")}`, {
duration: 0,
closeOnSwipe: false,
action: {
text: `${this.$t("action.yes")}`,
onClick: async (_, toastObject) => {
const { user } = await signInUserWithGithub()
await linkWithFBCredential(user, pendingCred)
this.showLoginSuccess()
toastObject.goAway(0)
},
},
})
} else {
this.$toast.error(`${this.$t("error.something_went_wrong")}`)
}
}
this.signingInWithMicrosoft = false
},
async signInWithEmail() {
this.signingInWithEmail = true

View File

@@ -28,16 +28,26 @@
{{ team.name || t("state.nothing_found") }}
</label>
<div class="flex mt-2 overflow-hidden -space-x-1">
<img
<div
v-for="(member, index) in team.teamMembers"
:key="`member-${index}`"
v-tippy="{ theme: 'tooltip' }"
:title="member.user.displayName"
:src="member.user.photoURL || undefined"
:alt="member.user.displayName"
class="inline-block w-5 h-5 rounded-full ring-primary ring-2"
loading="lazy"
/>
class="inline-flex"
>
<img
v-if="member.user.photoURL"
:src="member.user.photoURL"
:alt="member.user.displayName"
class="inline-block w-5 h-5 rounded-full ring-primary ring-2"
loading="lazy"
/>
<SmartIcon
v-else
name="user"
class="rounded-lg svg-icons bg-primaryLight ring-primary ring-2"
/>
</div>
</div>
</div>
</div>

View File

@@ -6,6 +6,7 @@ import {
signInWithPopup,
GoogleAuthProvider,
GithubAuthProvider,
OAuthProvider,
signInWithEmailAndPassword as signInWithEmailAndPass,
isSignInWithEmailLink as isSignInWithEmailLinkFB,
fetchSignInMethodsForEmail,
@@ -203,6 +204,13 @@ export async function signInUserWithGithub() {
)
}
/**
* Sign user in with a popup using Microsoft
*/
export async function signInUserWithMicrosoft() {
return await signInWithPopup(getAuth(), new OAuthProvider("microsoft.com"))
}
/**
* Sign user in with email and password
*/
@@ -363,6 +371,9 @@ async function reauthenticateUser() {
} else if (currentAuthMethod === "github.com") {
const result = await signInUserWithGoogle()
credential = GoogleAuthProvider.credentialFromResult(result)
} else if (currentAuthMethod === "microsoft.com") {
const result = await signInUserWithMicrosoft()
credential = OAuthProvider.credentialFromResult(result)
} else if (currentAuthMethod === "password") {
const email = prompt(
"Reauthenticate your account using your current email:"

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Gaan voort met e -pos",
"continue_with_github": "Gaan voort met GitHub",
"continue_with_google": "Gaan voort met Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E -pos",
"logged_out": "Uitgeteken",
"login": "Teken aan",

View File

@@ -76,6 +76,7 @@
"continue_with_email": "تواصل مع البريد الإلكتروني",
"continue_with_github": "تواصل مع جيثب",
"continue_with_google": "تواصل مع جوجل",
"continue_with_microsoft": "Continue with Microsoft",
"email": "بريد إلكتروني",
"logged_out": "تسجيل الخروج",
"login": "تسجيل الدخول",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Continueu amb el correu electrònic",
"continue_with_github": "Continueu amb GitHub",
"continue_with_google": "Continueu amb Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Correu electrònic",
"logged_out": "Desconnectat",
"login": "iniciar Sessió",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "使用电子邮箱登录",
"continue_with_github": "使用 GitHub 登录",
"continue_with_google": "使用 Google 登录",
"continue_with_microsoft": "Continue with Microsoft",
"email": "电子邮箱地址",
"logged_out": "登出",
"login": "登录",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Pokračujte e -mailem",
"continue_with_github": "Pokračujte na GitHubu",
"continue_with_google": "Pokračovat s Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mailem",
"logged_out": "Odhlásit",
"login": "Přihlásit se",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Fortsæt med e -mail",
"continue_with_github": "Fortsæt med GitHub",
"continue_with_google": "Fortsæt med Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E -mail",
"logged_out": "Logget ud",
"login": "Log på",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Weiter mit E-Mail",
"continue_with_github": "Weiter mit GitHub",
"continue_with_google": "Weiter mit Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Email",
"logged_out": "Abgemeldet",
"login": "Anmeldung",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Συνεχίστε με το Email",
"continue_with_github": "Συνεχίστε με το GitHub",
"continue_with_google": "Συνεχίστε με την Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "ΗΛΕΚΤΡΟΝΙΚΗ ΔΙΕΥΘΥΝΣΗ",
"logged_out": "Αποσυνδέθηκα",
"login": "Σύνδεση",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Continue with Email",
"continue_with_github": "Continue with GitHub",
"continue_with_google": "Continue with Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Email",
"logged_out": "Logged out",
"login": "Login",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Continuar con correo electrónico",
"continue_with_github": "Continuar con GitHub",
"continue_with_google": "Continuar con Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Correo electrónico",
"logged_out": "Desconectado",
"login": "Acceder",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Jatka sähköpostilla",
"continue_with_github": "Jatka GitHubilla",
"continue_with_google": "Jatka Googlella",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Sähköposti",
"logged_out": "Kirjautunut ulos",
"login": "Kirjaudu sisään",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Continuer avec l'e-mail",
"continue_with_github": "Continuer avec GitHub",
"continue_with_google": "Continuer avec Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mail",
"logged_out": "Déconnecté",
"login": "Connexion",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "המשך עם מייל",
"continue_with_github": "המשך עם GitHub",
"continue_with_google": "המשך עם גוגל",
"continue_with_microsoft": "Continue with Microsoft",
"email": "אימייל",
"logged_out": "התנתק",
"login": "התחברות",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Folytatás e-mail-címmel",
"continue_with_github": "Folytatás GitHub használatával",
"continue_with_google": "Folytatás Google használatával",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mail",
"logged_out": "Kijelentkezett",
"login": "Bejelentkezés",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Continua con e-mail",
"continue_with_github": "Continua con GitHub",
"continue_with_google": "Continua con Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mail",
"logged_out": "Disconnesso",
"login": "Accedi",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "メールを続ける",
"continue_with_github": "GitHubを続行します",
"continue_with_google": "Googleを続ける",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Eメール",
"logged_out": "ログアウトしました",
"login": "ログイン",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "이메일로 계속",
"continue_with_github": "GitHub 계속하기",
"continue_with_google": "Google로 계속하기",
"continue_with_microsoft": "Continue with Microsoft",
"email": "이메일",
"logged_out": "로그아웃",
"login": "로그인",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Ga verder met e-mail",
"continue_with_github": "Ga verder met GitHub",
"continue_with_google": "Ga verder met Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mail",
"logged_out": "Uitgelogd",
"login": "Log in",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Fortsett med e-post",
"continue_with_github": "Fortsett med GitHub",
"continue_with_google": "Fortsett med Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-post",
"logged_out": "Logget ut",
"login": "Logg inn",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Kontynuuj z e-mailem",
"continue_with_github": "Kontynuuj z GitHub",
"continue_with_google": "Kontynuuj z Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mail",
"logged_out": "Wylogowano",
"login": "Zaloguj sie",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Continue com Email",
"continue_with_github": "Continue com GitHub",
"continue_with_google": "Continue com o Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mail",
"logged_out": "Desconectado",
"login": "Conecte-se",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Continue com Email",
"continue_with_github": "Continue com GitHub",
"continue_with_google": "Continue com o Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mail",
"logged_out": "Desconectado",
"login": "Conecte-se",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Continuați cu e-mailul",
"continue_with_github": "Continuați cu GitHub",
"continue_with_google": "Continuați cu Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mail",
"logged_out": "Delogat",
"login": "Autentificare",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Продолжить с электронной почтой",
"continue_with_github": "Продолжить с GitHub",
"continue_with_google": "Продолжить с Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Электронное письмо",
"logged_out": "Вышли из",
"login": "Авторизоваться",

View File

@@ -76,6 +76,7 @@
"continue_with_email": "Наставите са е -поштом",
"continue_with_github": "Наставите са ГитХуб -ом",
"continue_with_google": "Наставите са Гоогле -ом",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Емаил",
"logged_out": "Одјављени",
"login": "Пријавите се",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Fortsätt med e -post",
"continue_with_github": "Fortsätt med GitHub",
"continue_with_google": "Fortsätt med Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-post",
"logged_out": "Utloggad",
"login": "Logga in",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "E-posta ile devam et",
"continue_with_github": "GitHub ile devam et",
"continue_with_google": "Google ile devam",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-posta",
"logged_out": ıkış yapıldı",
"login": "Giriş yapmak",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "使用電子信箱登入",
"continue_with_github": "使用 GitHub 登入",
"continue_with_google": "使用 Google 登入",
"continue_with_microsoft": "Continue with Microsoft",
"email": "電子信箱地址",
"logged_out": "登出",
"login": "登入",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Продовжити з електронною поштою",
"continue_with_github": "Продовжити з GitHub",
"continue_with_google": "Продовжуйте працювати з Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "Електронна пошта",
"logged_out": "Вийшли з системи",
"login": "Увійти",

View File

@@ -75,6 +75,7 @@
"continue_with_email": "Tiếp tục với Email",
"continue_with_github": "Tiếp tục với GitHub",
"continue_with_google": "Tiếp tục với Google",
"continue_with_microsoft": "Continue with Microsoft",
"email": "E-mail",
"logged_out": "Đã đăng xuất",
"login": "Đăng nhập",

View File

@@ -34,7 +34,11 @@
class="w-16 h-16 rounded-lg ring-primary ring-4"
:alt="`${currentUser.displayName}`"
/>
<SmartIcon v-else name="user" class="svg-icons" />
<SmartIcon
v-else
name="user"
class="svg-icons !w-16 !h-16 bg-primaryLight rounded-lg ring-primary ring-4"
/>
<div class="ml-4">
<label class="heading">
{{ currentUser.displayName || t("state.nothing_found") }}