File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
210236export default OffstylesApi ;
You can’t perform that action at this time.
0 commit comments