Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import React, { createContext, useContext, useState, type ReactNode } from 'react';

type User = {
id?: string;
name?: string;
uid?: string;
email?: string;
first_name?: string;
last_name?: string;
role?: string;
};

type AuthContextType = {
Expand Down Expand Up @@ -32,9 +34,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
setLoading(true);

const response = await fetch('https://api.capyrpi.org/v1/auth/me', {
headers: {
Accept: 'application/json',
},
headers: { Accept: 'application/json' },
credentials: 'include',
});

Expand Down Expand Up @@ -70,9 +70,8 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
const pollInterval = setInterval(async () => {
try {
const response = await fetch('https://api.capyrpi.org/v1/auth/me', {
headers: {
Accept: 'application/json',
},
headers: { Accept: 'application/json' },
credentials: 'include',
});

if (response.ok) {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default function Home() {
</a>
<LoginPopup isOpen={showLogin} onClose={() => setShowLogin(false)} />
<p style={{ color: 'black' }}>
UserId: <span style={{ color: user?.id ? 'green' : 'red' }}>{user?.id ?? 'Not logged in'}</span>
UserId:{' '}
<span style={{ color: user?.uid ? 'green' : 'red' }}>{user?.uid ?? 'Not logged in'}</span>
</p>
</div>
<div className="home-grid-panel"></div>
Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ import react from '@vitejs/plugin-react'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 5173
}
})