Skip to content

Commit

Permalink
refactor: minimize session data
Browse files Browse the repository at this point in the history
  • Loading branch information
andygeiss committed Jan 5, 2025
1 parent 9a9048c commit 02ebf37
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
4 changes: 0 additions & 4 deletions security/oauth_callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ func OAuthCallback(homePath string, sessions *ServerSessions) http.HandlerFunc {
// Update the user's session.
id := sessions.Update(ServerSession{
AvatarURL: userInfo.AvatarURL,
EMail: userInfo.EMail,
Login: userInfo.Login,
Name: userInfo.Name,
})

Expand Down Expand Up @@ -100,8 +98,6 @@ func getAccessToken(code string) (string, error) {
// githubUserInfo represents the user's information returned by the GitHub API.
type githubUserInfo struct {
AvatarURL string `json:"avatar_url"`
EMail string `json:"email"`
Login string `json:"login"`
Name string `json:"name"`
}

Expand Down
2 changes: 0 additions & 2 deletions security/server_sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
type ServerSession struct {
ID string `json:"id"`
AvatarURL string `json:"avatar_url"`
EMail string `json:"email"`
Login string `json:"login"`
Name string `json:"name"`
}

Expand Down
4 changes: 2 additions & 2 deletions security/server_sessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (

func TestServerSessions_Update(t *testing.T) {
sessions := security.NewServerSessions()
id := sessions.Update(security.ServerSession{AvatarURL: "avatar_url", EMail: "email", Login: "login", Name: "name"})
id := sessions.Update(security.ServerSession{AvatarURL: "avatar_url", Name: "name"})
assert.That(t, "id is correct", len(id), 64)
}

func TestServerSessions_Get(t *testing.T) {
sessions := security.NewServerSessions()
session := security.ServerSession{AvatarURL: "avatar_url", EMail: "email", Login: "login", Name: "name"}
session := security.ServerSession{AvatarURL: "avatar_url", Name: "name"}
id := sessions.Update(session)
session.ID = id
current, found := sessions.Get(id)
Expand Down

0 comments on commit 02ebf37

Please sign in to comment.