Skip to content

Commit b15566e

Browse files
committed
Cleanup login
1 parent 82d5818 commit b15566e

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

src/contexts/AuthContext.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
import React, { createContext, useContext, useState, type ReactNode } from 'react';
33

44
type User = {
5-
id?: string;
6-
name?: string;
5+
uid?: string;
76
email?: string;
7+
first_name?: string;
8+
last_name?: string;
9+
role?: string;
810
};
911

1012
type AuthContextType = {
@@ -32,10 +34,8 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
3234
setLoading(true);
3335

3436
const response = await fetch('https://api.capyrpi.org/v1/auth/me', {
35-
headers: {
36-
Accept: 'application/json',
37-
},
38-
credentials: 'include',
37+
headers: { Accept: 'application/json' },
38+
credentials: 'include'
3939
});
4040

4141
if (response.ok) {
@@ -70,9 +70,8 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
7070
const pollInterval = setInterval(async () => {
7171
try {
7272
const response = await fetch('https://api.capyrpi.org/v1/auth/me', {
73-
headers: {
74-
Accept: 'application/json',
75-
},
73+
headers: { Accept: 'application/json' },
74+
credentials: 'include'
7675
});
7776

7877
if (response.ok) {

src/pages/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function Home() {
1616
</a>
1717
<LoginPopup isOpen={showLogin} onClose={() => setShowLogin(false)} />
1818
<p style={{ color: 'black' }}>
19-
UserId: <span style={{ color: user?.id ? 'green' : 'red' }}>{user?.id ?? 'Not logged in'}</span>
19+
UserId: <span style={{ color: user?.uid ? 'green' : 'red' }}>{user?.uid ?? 'Not logged in'}</span>
2020
</p>
2121
</div>
2222
<div className="home-grid-panel"></div>

vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ import react from '@vitejs/plugin-react'
44
// https://vite.dev/config/
55
export default defineConfig({
66
plugins: [react()],
7+
server: {
8+
port: 5173
9+
}
710
})

0 commit comments

Comments
 (0)