-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Azure login support (#3071)
This commit adds support for Azure login by implementing the AzureLoginButton component and the useAzureLogin hook. It also updates the login.json file to include the "Continue with Azure" text. This feature enhances the authentication options for users and improves the overall user experience.
- Loading branch information
1 parent
78355ed
commit 0b33c3f
Showing
10 changed files
with
165 additions
and
11 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
frontend/app/(auth)/login/components/AzureLogin/hooks/useAzureLogin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useState } from "react"; | ||
|
||
import { useSupabase } from "@/lib/context/SupabaseProvider"; | ||
import { useToast } from "@/lib/hooks/useToast"; | ||
|
||
export const useAzureLogin = (): { | ||
signInWithAzure: () => Promise<void>; | ||
isPending: boolean; | ||
} => { | ||
const { supabase } = useSupabase(); | ||
const { publish } = useToast(); | ||
const [isPending, setIsPending] = useState(false); | ||
|
||
const signInWithAzure = async () => { | ||
setIsPending(true); | ||
const { error } = await supabase.auth.signInWithOAuth({ | ||
provider: 'azure', | ||
options: { | ||
scopes: 'email', | ||
}, | ||
}); | ||
setIsPending(false); | ||
if (error) { | ||
publish({ | ||
variant: "danger", | ||
text: "An error occurred during Azure login", | ||
}); | ||
} | ||
}; | ||
|
||
return { | ||
signInWithAzure, | ||
isPending, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { SiMicrosoftazure } from "react-icons/si"; | ||
|
||
import Button from "@/lib/components/ui/Button"; | ||
|
||
import { useAzureLogin } from "./hooks/useAzureLogin"; | ||
|
||
export const AzureLoginButton = (): JSX.Element => { | ||
const { isPending, signInWithAzure } = useAzureLogin(); | ||
const { t } = useTranslation(["login"]); | ||
|
||
return ( | ||
<Button | ||
onClick={() => void signInWithAzure()} | ||
isLoading={isPending} | ||
type="button" | ||
data-testid="azure-login-button" | ||
className="font-normal bg-white text-black py-2 hover:text-white" | ||
> | ||
<SiMicrosoftazure /> | ||
{t("azureLogin", { ns: "login" })} | ||
</Button> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
{"password":"Contraseña","googleLogin":"Continuar con Google","errorPasswordMissed":"Por favor ingrese su contraseña","magicLink":"Continuar con correo electrónico","errorMailMissed":"Por favor ingrese su dirección de correo electrónico","talk_to":"Hablar con","restriction_message":"Los usuarios no pagos tienen acceso a una demostración gratuita y limitada de Quivr","email":"Dirección de correo electrónico","cant_find":"¿No puedes encontrarlo?","try_again":"Inténtalo de nuevo","check_your_email":{"part1":"Acabamos de enviarte un ","magic_link":"enlace mágico","part2":". Revisa tus correos electrónicos y sigue los pasos."},"login":"Iniciar sesión"} | ||
{ | ||
"password": "Contraseña", | ||
"googleLogin": "Continuar con Google", | ||
"azureLogin": "Continuar con Azure", | ||
"errorPasswordMissed": "Por favor ingrese su contraseña", | ||
"magicLink": "Continuar con correo electrónico", | ||
"errorMailMissed": "Por favor ingrese su dirección de correo electrónico", | ||
"talk_to": "Hablar con", | ||
"restriction_message": "Los usuarios no pagos tienen acceso a una demostración gratuita y limitada de Quivr", | ||
"email": "Dirección de correo electrónico", | ||
"cant_find": "¿No puedes encontrarlo?", | ||
"try_again": "Inténtalo de nuevo", | ||
"check_your_email": { | ||
"part1": "Acabamos de enviarte un ", | ||
"magic_link": "enlace mágico", | ||
"part2": ". Revisa tus correos electrónicos y sigue los pasos." | ||
}, | ||
"login": "Iniciar sesión" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
{"password":"Mot de passe","googleLogin":"Continuer avec Google","errorPasswordMissed":"Veuillez entrer votre mot de passe","magicLink":"Continuer avec e-mail","errorMailMissed":"Veuillez saisir votre adresse e-mail","talk_to":"Parler à","restriction_message":"Les utilisateurs non payants ont accès à une démonstration gratuite et limitée de Quivr","email":"Adresse e-mail","cant_find":"Vous ne le trouvez pas ?","try_again":"Réessayez","check_your_email":{"part1":"Nous venons de vous envoyer un ","magic_link":"lien magique","part2":". Vérifiez vos e-mails et suivez les étapes."},"login":"Se connecter"} | ||
{ | ||
"password": "Mot de passe", | ||
"googleLogin": "Continuer avec Google", | ||
"azureLogin": "Continuer avec Azure", | ||
"errorPasswordMissed": "Veuillez entrer votre mot de passe", | ||
"magicLink": "Continuer avec e-mail", | ||
"errorMailMissed": "Veuillez saisir votre adresse e-mail", | ||
"talk_to": "Parler à", | ||
"restriction_message": "Les utilisateurs non payants ont accès à une démonstration gratuite et limitée de Quivr", | ||
"email": "Adresse e-mail", | ||
"cant_find": "Vous ne le trouvez pas ?", | ||
"try_again": "Réessayez", | ||
"check_your_email": { | ||
"part1": "Nous venons de vous envoyer un ", | ||
"magic_link": "lien magique", | ||
"part2": ". Vérifiez vos e-mails et suivez les étapes." | ||
}, | ||
"login": "Se connecter" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
{"password":"Senha","googleLogin":"Continuar com o Google","errorPasswordMissed":"Por favor, digite sua senha","magicLink":"Continuar com e-mail","errorMailMissed":"Por favor, digite seu endereço de e-mail","talk_to":"Conversar com","restriction_message":"Usuários não pagos têm acesso a uma demonstração gratuita e limitada do Quivr","email":"Endereço de e-mail","cant_find":"Não consegue encontrar?","try_again":"Tente novamente","check_your_email":{"part1":"Acabamos de enviar um ","magic_link":"link mágico","part2":", verifique seus e-mails e siga as etapas."},"login":"Entrar"} | ||
{ | ||
"password": "Senha", | ||
"googleLogin": "Continuar com o Google", | ||
"azureLogin": "Continuar com o Azure", | ||
"errorPasswordMissed": "Por favor, digite sua senha", | ||
"magicLink": "Continuar com e-mail", | ||
"errorMailMissed": "Por favor, digite seu endereço de e-mail", | ||
"talk_to": "Conversar com", | ||
"restriction_message": "Usuários não pagos têm acesso a uma demonstração gratuita e limitada do Quivr", | ||
"email": "Endereço de e-mail", | ||
"cant_find": "Não consegue encontrar?", | ||
"try_again": "Tente novamente", | ||
"check_your_email": { | ||
"part1": "Acabamos de enviar um ", | ||
"magic_link": "link mágico", | ||
"part2": ", verifique seus e-mails e siga as etapas." | ||
}, | ||
"login": "Entrar" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
{"password":"Пароль","googleLogin":"Продолжить с Google","errorPasswordMissed":"Пожалуйста, введите свой пароль","magicLink":"Продолжить с электронной почтой","errorMailMissed":"Пожалуйста, введите ваш адрес электронной почты","talk_to":"Общение с","restriction_message":"Неоплаченным пользователям доступен бесплатный и ограниченный демонстрационный доступ к Quivr","email":"Адрес электронной почты","cant_find":"Не можете найти?","try_again":"Попробуйте еще раз","check_your_email":{"part1":"Мы только что отправили вам ","magic_link":"волшебную ссылку","part2":". Проверьте свою электронную почту и следуйте инструкциям."},"login":"Войти"} | ||
{ | ||
"password": "Пароль", | ||
"googleLogin": "Продолжить с Google", | ||
"azureLogin": "Продолжить с Azure", | ||
"errorPasswordMissed": "Пожалуйста, введите свой пароль", | ||
"magicLink": "Продолжить с электронной почтой", | ||
"errorMailMissed": "Пожалуйста, введите ваш адрес электронной почты", | ||
"talk_to": "Общение с", | ||
"restriction_message": "Неоплаченным пользователям доступен бесплатный и ограниченный демонстрационный доступ к Quivr", | ||
"email": "Адрес электронной почты", | ||
"cant_find": "Не можете найти?", | ||
"try_again": "Попробуйте еще раз", | ||
"check_your_email": { | ||
"part1": "Мы только что отправили вам ", | ||
"magic_link": "волшебную ссылку", | ||
"part2": ". Проверьте свою электронную почту и следуйте инструкциям." | ||
}, | ||
"login": "Войти" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,19 @@ | ||
{"password":"密码","googleLogin":"使用Google登录","errorPasswordMissed":"请输入密码","magicLink":"使用电子邮件继续","errorMailMissed":"请输入您的电子邮件地址","talk_to":"与之交谈","restriction_message":"未付费用户可以访问Quivr的免费和有限演示","email":"电子邮件地址","cant_find":"找不到?","try_again":"重试","check_your_email":{"part1":"我们刚刚发送了一个","magic_link":"魔法链接","part2":",请检查您的电子邮件并按照步骤操作。"},"login":"登录"} | ||
{ | ||
"password": "密码", | ||
"googleLogin": "使用Google登录", | ||
"azureLogin": "使用Azure登录", | ||
"errorPasswordMissed": "请输入密码", | ||
"magicLink": "使用电子邮件继续", | ||
"errorMailMissed": "请输入您的电子邮件地址", | ||
"talk_to": "与之交谈", | ||
"restriction_message": "未付费用户可以访问Quivr的免费和有限演示", | ||
"email": "电子邮件地址", | ||
"cant_find": "找不到?", | ||
"try_again": "重试", | ||
"check_your_email": { | ||
"part1": "我们刚刚发送了一个", | ||
"magic_link": "魔法链接", | ||
"part2": ",请检查您的电子邮件并按照步骤操作。" | ||
}, | ||
"login": "登录" | ||
} |