mirror of
https://github.com/PeterMaquiran/tvone.git
synced 2026-04-18 15:27:52 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7854e3dd44 | |||
| 2ab775514e |
+22
-10
@@ -89,6 +89,11 @@ const CreateNewsPage = () => {
|
|||||||
const [isEditorOpen, setIsEditorOpen] = useState(false);
|
const [isEditorOpen, setIsEditorOpen] = useState(false);
|
||||||
const [finalCrops, setFinalCrops] = useState<any>(null); // Guarda os Base64 finais
|
const [finalCrops, setFinalCrops] = useState<any>(null); // Guarda os Base64 finais
|
||||||
const [content, setContent] = useState('');
|
const [content, setContent] = useState('');
|
||||||
|
const [user, setUser] = useState<{
|
||||||
|
email?: string;
|
||||||
|
name?: string;
|
||||||
|
picture?: string;
|
||||||
|
} | null>(null);
|
||||||
|
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
@@ -111,19 +116,23 @@ const CreateNewsPage = () => {
|
|||||||
// Avoid hydration mismatch by waiting for mount
|
// Avoid hydration mismatch by waiting for mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
keycloak.init({
|
keycloak.init({
|
||||||
onLoad: "check-sso", // or "login-required"
|
onLoad: "check-sso",
|
||||||
pkceMethod: "S256",
|
pkceMethod: "S256",
|
||||||
}).then((authenticated) => {
|
}).then(async (authenticated) => {
|
||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
localStorage.setItem("token", keycloak.token!);
|
const token = keycloak.token!;
|
||||||
console.log("Logged in", keycloak.token);
|
localStorage.setItem("token", token);
|
||||||
localStorage.setItem("token", keycloak.token as string);
|
|
||||||
|
const res = await fetch("http://localhost:3001/profile/", {
|
||||||
fetch("http://localhost:3001/profile/", {
|
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${localStorage.getItem("token")}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const profile = await res.json();
|
||||||
|
|
||||||
|
setUser(profile);
|
||||||
|
console.log("Profile:", profile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
@@ -187,11 +196,14 @@ const CreateNewsPage = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<div className="text-right">
|
<div className="text-right">
|
||||||
<p className="text-xs font-bold">James Wilson</p>
|
<p className="text-xs font-bold">{user?.name ?? "Loading..."}</p>
|
||||||
<p className="text-[10px] text-slate-500">Editor</p>
|
<p className="text-[10px] text-slate-500">Editor</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-8 h-8 bg-slate-300 rounded-full border border-white shadow-sm overflow-hidden">
|
<div className="w-8 h-8 bg-slate-300 rounded-full border border-white shadow-sm overflow-hidden">
|
||||||
<img src="https://ui-avatars.com/api/?name=James+Wilson" alt="User" />
|
<img
|
||||||
|
src={user?.picture ?? "https://ui-avatars.com/api/?name=User"}
|
||||||
|
alt="User"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
+8
-4
@@ -196,10 +196,14 @@ export default function AppleStyleAuth() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 4. BOTÃO GOOGLE */}
|
{/* 4. BOTÃO GOOGLE */}
|
||||||
<button
|
<button
|
||||||
onClick={() => keycloak.login({ redirectUri: "http://localhost:3000/create-news" })}
|
onClick={() =>
|
||||||
className="group flex w-full items-center justify-center gap-3 rounded-2xl border border-neutral-200 bg-white px-6 py-3.5 transition-all hover:bg-neutral-50 active:scale-[0.98] dark:border-neutral-800 dark:bg-transparent dark:hover:bg-neutral-900"
|
keycloak.login({
|
||||||
>
|
redirectUri: `${window.location.origin}/create-news`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
className="group flex w-full items-center justify-center gap-3 rounded-2xl border border-neutral-200 bg-white px-6 py-3.5 transition-all hover:bg-neutral-50 active:scale-[0.98] dark:border-neutral-800 dark:bg-transparent dark:hover:bg-neutral-900"
|
||||||
|
>
|
||||||
<svg className="h-5 w-5" viewBox="0 0 24 24">
|
<svg className="h-5 w-5" viewBox="0 0 24 24">
|
||||||
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4" />
|
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4" />
|
||||||
<path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853" />
|
<path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853" />
|
||||||
|
|||||||
Reference in New Issue
Block a user