Skip to content

Commit 515590d

Browse files
committed
Fix auth
1 parent b12be80 commit 515590d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/api/offstylesApi.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,32 @@ class OffstylesApi extends Api {
205205

206206
return await response.json();
207207
}
208+
209+
// Authentication methods
210+
static async getCurrentUser(): Promise<User | null> {
211+
try {
212+
const response = await fetch(`${this.offstylesApiUrl}/profile`, {
213+
credentials: 'include' // Include cookies for session authentication
214+
});
215+
216+
if (response.ok) {
217+
return await response.json();
218+
} else {
219+
return null; // Not authenticated or user not found
220+
}
221+
} catch (error) {
222+
console.error('Error fetching current user:', error);
223+
return null;
224+
}
225+
}
226+
227+
static getLoginUrl(): string {
228+
return `${this.offstylesApiUrl}/steam`;
229+
}
230+
231+
static getLogoutUrl(): string {
232+
return `${this.offstylesApiUrl}/logout`;
233+
}
208234
}
209235

210236
export default OffstylesApi;

0 commit comments

Comments
 (0)