Skip to content

Commit

Permalink
Fixed session issue
Browse files Browse the repository at this point in the history
  • Loading branch information
frikky committed Mar 27, 2021
1 parent 9bf0f07 commit 33d71c8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,10 @@ func HandleApiAuthentication(resp http.ResponseWriter, request *http.Request) (U
parsedName = session.Id
}

//log.Printf("Session: %s", session.Username)
// Get session first
// Should basically never happen
Userdata, err := GetUser(ctx, parsedName)
user, err := GetUser(ctx, parsedName)
if err != nil {
log.Printf("[INFO] User with Identifier %s doesn't exist: %s", parsedName, err)
return User{}, err
Expand All @@ -869,12 +870,12 @@ func HandleApiAuthentication(resp http.ResponseWriter, request *http.Request) (U
return User{}, errors.New(fmt.Sprintf("Couldn't find user"))
}

if Userdata.Session != sessionToken {
if user.Session != sessionToken {
return User{}, errors.New("[WARNING] Wrong session token")
}

// Means session exists, but
return *Userdata, nil
return *user, nil
}

// Key = apikey
Expand Down

0 comments on commit 33d71c8

Please sign in to comment.