This commit is contained in:
+18
-10
@@ -1,16 +1,16 @@
|
|||||||
import { View, Text } from "react-native";
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
import { Text, View } from "react-native";
|
||||||
import { useGlobal } from "reactn";
|
import { useGlobal } from "reactn";
|
||||||
import Page from "../layouts/Page";
|
|
||||||
import { background } from "../assets";
|
import { background } from "../assets";
|
||||||
|
import GradientButton from "../components/GradientButton";
|
||||||
|
import { Input } from "../components/Input";
|
||||||
import ItemContainer from "../components/ItemContainer/ItemContainer";
|
import ItemContainer from "../components/ItemContainer/ItemContainer";
|
||||||
|
import firebase, { usersRef } from "../config/firebase";
|
||||||
|
import Page from "../layouts/Page";
|
||||||
|
import { Routes } from "../navigation";
|
||||||
|
import { navigate } from "../navigation/NavigationService";
|
||||||
import { Palette } from "../styles";
|
import { Palette } from "../styles";
|
||||||
import { FONT_FAMILY } from "../styles/Fonts";
|
import { FONT_FAMILY } from "../styles/Fonts";
|
||||||
import { Input } from "../components/Input";
|
|
||||||
import GradientButton from "../components/GradientButton";
|
|
||||||
import { navigate } from "../navigation/NavigationService";
|
|
||||||
import { Routes } from "../navigation";
|
|
||||||
import firebase, { usersRef } from "../config/firebase";
|
|
||||||
|
|
||||||
const CreatePseudo = () => {
|
const CreatePseudo = () => {
|
||||||
const [userName, setUserName] = useState("");
|
const [userName, setUserName] = useState("");
|
||||||
@@ -29,7 +29,10 @@ const CreatePseudo = () => {
|
|||||||
}
|
}
|
||||||
// Check uniqueness (case-insensitive)
|
// Check uniqueness (case-insensitive)
|
||||||
const lower = val.toLowerCase();
|
const lower = val.toLowerCase();
|
||||||
const snap = await usersRef.where("userNameLower", "==", lower).limit(1).get();
|
const snap = await usersRef
|
||||||
|
.where("userNameLower", "==", lower)
|
||||||
|
.limit(1)
|
||||||
|
.get();
|
||||||
if (!snap.empty && snap.docs[0].id !== uid) {
|
if (!snap.empty && snap.docs[0].id !== uid) {
|
||||||
setTooltip({ text: "Ce pseudo est déjà pris", type: "error" });
|
setTooltip({ text: "Ce pseudo est déjà pris", type: "error" });
|
||||||
return;
|
return;
|
||||||
@@ -40,14 +43,19 @@ const CreatePseudo = () => {
|
|||||||
userName: val,
|
userName: val,
|
||||||
userNameLower: lower,
|
userNameLower: lower,
|
||||||
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
updatedAt: firebase.firestore.FieldValue.serverTimestamp(),
|
||||||
|
createdAt: firebase.firestore.FieldValue.serverTimestamp(),
|
||||||
|
email: firebase.auth().currentUser?.email || null,
|
||||||
},
|
},
|
||||||
{ merge: true },
|
{ merge: true }
|
||||||
);
|
);
|
||||||
setTooltip({ text: `Bienvenue ${val}`, type: "success" });
|
setTooltip({ text: `Bienvenue ${val}`, type: "success" });
|
||||||
navigate(Routes.BottomTab);
|
navigate(Routes.BottomTab);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("CreatePseudo error", e?.message);
|
console.log("CreatePseudo error", e?.message);
|
||||||
setTooltip({ text: e?.message || "Enregistrement impossible", type: "error" });
|
setTooltip({
|
||||||
|
text: e?.message || "Enregistrement impossible",
|
||||||
|
type: "error",
|
||||||
|
});
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -3,7 +3,7 @@ import * as AuthSession from "expo-auth-session";
|
|||||||
import * as GoogleAuth from "expo-auth-session/providers/google";
|
import * as GoogleAuth from "expo-auth-session/providers/google";
|
||||||
import * as WebBrowser from "expo-web-browser";
|
import * as WebBrowser from "expo-web-browser";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Platform, Pressable, Text, View } from "react-native";
|
import { Pressable, Text, View } from "react-native";
|
||||||
import { useGlobal } from "reactn";
|
import { useGlobal } from "reactn";
|
||||||
import { background } from "../assets";
|
import { background } from "../assets";
|
||||||
import GradientButton from "../components/GradientButton.js";
|
import GradientButton from "../components/GradientButton.js";
|
||||||
@@ -106,13 +106,15 @@ export default ({ navigation }) => {
|
|||||||
|
|
||||||
if (!idToken) {
|
if (!idToken) {
|
||||||
// Otherwise, exchange the authorization code for tokens using PKCE.
|
// Otherwise, exchange the authorization code for tokens using PKCE.
|
||||||
const code = response?.params?.code || response?.authentication?.code;
|
const code =
|
||||||
|
response?.params?.code || response?.authentication?.code;
|
||||||
if (!code) throw new Error("Code d'autorisation Google manquant");
|
if (!code) throw new Error("Code d'autorisation Google manquant");
|
||||||
|
|
||||||
// Use the exact clientId used during the authorize request.
|
// Use the exact clientId used during the authorize request.
|
||||||
const clientId = request?.clientId;
|
const clientId = request?.clientId;
|
||||||
const discovery = {
|
const discovery = {
|
||||||
authorizationEndpoint: "https://accounts.google.com/o/oauth2/v2/auth",
|
authorizationEndpoint:
|
||||||
|
"https://accounts.google.com/o/oauth2/v2/auth",
|
||||||
tokenEndpoint: "https://oauth2.googleapis.com/token",
|
tokenEndpoint: "https://oauth2.googleapis.com/token",
|
||||||
revocationEndpoint: "https://oauth2.googleapis.com/revoke",
|
revocationEndpoint: "https://oauth2.googleapis.com/revoke",
|
||||||
};
|
};
|
||||||
@@ -136,9 +138,11 @@ export default ({ navigation }) => {
|
|||||||
idToken = tokenResponse?.id_token;
|
idToken = tokenResponse?.id_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!idToken) throw new Error("Jeton Google manquant (échange/retour)");
|
if (!idToken)
|
||||||
|
throw new Error("Jeton Google manquant (échange/retour)");
|
||||||
|
|
||||||
const credential = firebase.auth.GoogleAuthProvider.credential(idToken);
|
const credential =
|
||||||
|
firebase.auth.GoogleAuthProvider.credential(idToken);
|
||||||
await firebase.auth().signInWithCredential(credential);
|
await firebase.auth().signInWithCredential(credential);
|
||||||
await afterLoginNavigate();
|
await afterLoginNavigate();
|
||||||
}
|
}
|
||||||
@@ -167,7 +171,7 @@ export default ({ navigation }) => {
|
|||||||
hideBackButton
|
hideBackButton
|
||||||
>
|
>
|
||||||
<View style={{ flex: 1, paddingTop: 20 }}>
|
<View style={{ flex: 1, paddingTop: 20 }}>
|
||||||
<ItemContainer height={490}>
|
<ItemContainer height={600}>
|
||||||
<View style={{ gap: 30, paddingTop: 5, paddingHorizontal: 5 }}>
|
<View style={{ gap: 30, paddingTop: 5, paddingHorizontal: 5 }}>
|
||||||
<View style={{ gap: 2 }}>
|
<View style={{ gap: 2 }}>
|
||||||
<Text
|
<Text
|
||||||
|
|||||||
Reference in New Issue
Block a user