Mots de passe fuités refusés (Have I Been Pwned, k-anonymat) à l'inscription et au changement
deploy / deploy (push) Successful in 35s
deploy / deploy (push) Successful in 35s
Remplace l'option payante « Prevent use of leaked passwords » de Supabase : seuls 5 caractères de l'empreinte SHA-1 sont envoyés ; en cas de panne réseau on laisse passer. CSP connect-src, message en 18 langues, politique de confidentialité mise à jour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
22 files changed
+63
-1
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { t, type TKey } from '../../i18n'
|
||||
import { SUPABASE_ANON_KEY, SUPABASE_URL } from './config'
|
||||
import { isPwnedPassword } from '../pwned'
|
||||
|
||||
/**
|
||||
* Connexion aux comptes (Supabase Auth), sans dépendance.
|
||||
@@ -163,6 +164,7 @@ export async function signIn(email: string, password: string): Promise<void> {
|
||||
/** Inscription. Le pseudo choisi est repris par la base à la création du profil (s'il est libre). */
|
||||
export async function signUp(email: string, password: string, username?: string): Promise<boolean> {
|
||||
if (password.length < PASSWORD_MIN) throw new AuthError(t('auth.err.weak', { n: PASSWORD_MIN }))
|
||||
if (await isPwnedPassword(password)) throw new AuthError(t('auth.err.pwned'))
|
||||
const data = await gotrue(`/signup?redirect_to=${encodeURIComponent(appUrl())}`, {
|
||||
body: { email: cleanEmail(email), password, ...(username ? { data: { username } } : {}) },
|
||||
})
|
||||
@@ -180,6 +182,7 @@ export async function requestPasswordReset(email: string): Promise<void> {
|
||||
|
||||
export async function updatePassword(password: string): Promise<void> {
|
||||
if (password.length < PASSWORD_MIN) throw new AuthError(t('auth.err.weak', { n: PASSWORD_MIN }))
|
||||
if (await isPwnedPassword(password)) throw new AuthError(t('auth.err.pwned'))
|
||||
const token = await getAccessToken()
|
||||
if (!token) throw new AuthError(t('auth.err.session'))
|
||||
await gotrue('/user', { method: 'PUT', body: { password }, token })
|
||||
|
||||
Reference in new issue
Block a user