feat: Remove anonymous guest login functionality and associated UI elements.
This commit is contained in:
3
.env
3
.env
@@ -7,5 +7,4 @@ VITE_FIREBASE_APP_ID="1:219982610263:web:0ebe67d9cf0e7d2753c812"
|
|||||||
|
|
||||||
VITE_APP_ID=my-closet-app
|
VITE_APP_ID=my-closet-app
|
||||||
VITE_INITIAL_AUTH_TOKEN=
|
VITE_INITIAL_AUTH_TOKEN=
|
||||||
#fiz um teste
|
|
||||||
#fiz outro teste
|
|
||||||
|
|||||||
27
src/App.jsx
27
src/App.jsx
@@ -11,7 +11,7 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
signInWithEmailAndPassword, createUserWithEmailAndPassword,
|
signInWithEmailAndPassword, createUserWithEmailAndPassword,
|
||||||
onAuthStateChanged, signOut, signInAnonymously, signInWithCustomToken
|
onAuthStateChanged, signOut, signInWithCustomToken
|
||||||
} from 'firebase/auth';
|
} from 'firebase/auth';
|
||||||
import {
|
import {
|
||||||
collection, doc, onSnapshot, addDoc, updateDoc,
|
collection, doc, onSnapshot, addDoc, updateDoc,
|
||||||
@@ -179,23 +179,14 @@ export default function App() {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
if (err.code === 'auth/operation-not-allowed') {
|
if (err.code === 'auth/operation-not-allowed') {
|
||||||
setAuthError('O login por e-mail está desativado. Use o modo Convidado.');
|
setAuthError('O login por e-mail está desativado.');
|
||||||
} else {
|
} else {
|
||||||
setAuthError(err.message);
|
setAuthError(err.message);
|
||||||
}
|
}
|
||||||
} finally { setLoading(false); }
|
} finally { setLoading(false); }
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleGuestLogin = async () => {
|
|
||||||
setLoading(true);
|
|
||||||
try {
|
|
||||||
await signInAnonymously(auth);
|
|
||||||
} catch (e) {
|
|
||||||
setAuthError('Erro no modo convidado: ' + e.message);
|
|
||||||
} finally {
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const emptyTrashPermanently = async () => {
|
const emptyTrashPermanently = async () => {
|
||||||
if (!user || !window.confirm("Esvaziar o lixo permanentemente?")) return;
|
if (!user || !window.confirm("Esvaziar o lixo permanentemente?")) return;
|
||||||
@@ -249,9 +240,7 @@ export default function App() {
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<button onClick={handleGuestLogin} className="w-full mt-4 py-4 text-indigo-600 rounded-2xl font-black text-xs uppercase tracking-widest hover:bg-indigo-50 transition-all flex items-center justify-center gap-2">
|
|
||||||
<UserCircle size={18} /> Modo Convidado
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<div className="mt-10 text-center">
|
<div className="mt-10 text-center">
|
||||||
<button onClick={() => setAuthMode(authMode === 'login' ? 'register' : 'login')} className="text-gray-400 font-black text-[10px] uppercase tracking-[0.3em] hover:text-indigo-600 transition-colors text-inherit">
|
<button onClick={() => setAuthMode(authMode === 'login' ? 'register' : 'login')} className="text-gray-400 font-black text-[10px] uppercase tracking-[0.3em] hover:text-indigo-600 transition-colors text-inherit">
|
||||||
@@ -302,10 +291,10 @@ export default function App() {
|
|||||||
<div className="mt-auto pt-10 border-t border-inherit">
|
<div className="mt-auto pt-10 border-t border-inherit">
|
||||||
<div className="flex items-center gap-4 mb-8 px-2">
|
<div className="flex items-center gap-4 mb-8 px-2">
|
||||||
<div className={`w-12 h-12 rounded-2xl flex items-center justify-center font-black text-white shadow-xl ${darkMode ? 'bg-indigo-500' : 'bg-indigo-600'}`}>
|
<div className={`w-12 h-12 rounded-2xl flex items-center justify-center font-black text-white shadow-xl ${darkMode ? 'bg-indigo-500' : 'bg-indigo-600'}`}>
|
||||||
{user?.isAnonymous ? 'C' : user?.email?.[0]?.toUpperCase()}
|
{user?.email?.[0]?.toUpperCase() || 'U'}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<p className="text-sm font-black truncate">{user?.isAnonymous ? 'Convidado' : (user?.email?.split('@')[0] || 'Utilizador')}</p>
|
<p className="text-sm font-black truncate">{user?.email?.split('@')[0] || 'Utilizador'}</p>
|
||||||
<Badge variant="success">Online</Badge>
|
<Badge variant="success">Online</Badge>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -630,10 +619,10 @@ export default function App() {
|
|||||||
<Card className="p-10 border-indigo-100 relative overflow-hidden" darkMode={darkMode}>
|
<Card className="p-10 border-indigo-100 relative overflow-hidden" darkMode={darkMode}>
|
||||||
<div className="flex items-center gap-8 relative z-10 text-inherit">
|
<div className="flex items-center gap-8 relative z-10 text-inherit">
|
||||||
<div className="w-24 h-24 rounded-[2.5rem] bg-indigo-600 flex items-center justify-center text-white text-4xl font-black shadow-2xl">
|
<div className="w-24 h-24 rounded-[2.5rem] bg-indigo-600 flex items-center justify-center text-white text-4xl font-black shadow-2xl">
|
||||||
{user?.isAnonymous ? 'C' : user?.email?.[0]?.toUpperCase()}
|
{user?.email?.[0]?.toUpperCase() || 'U'}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h3 className="text-3xl font-black tracking-tighter">{user?.isAnonymous ? 'Convidado' : 'A Tua Conta'}</h3>
|
<h3 className="text-3xl font-black tracking-tighter">A Tua Conta</h3>
|
||||||
<p className="opacity-60 font-bold text-sm">{user?.email || 'Modo PAP'}</p>
|
<p className="opacity-60 font-bold text-sm">{user?.email || 'Modo PAP'}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user