Skip to content

Commit

Permalink
fix option bug
Browse files Browse the repository at this point in the history
  • Loading branch information
KenWilliamson committed Mar 23, 2023
1 parent 4e48ef9 commit 1aac8ca
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions configOptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package gosecuresessions

// ConfigOptions ConfigOptions
type ConfigOptions struct {
path string
domain string
maxAge int
sessionType int
Path string
Domain string
MaxAge int
SessionType int
}
2 changes: 1 addition & 1 deletion cookieSession_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestCookieSession_Get(t *testing.T) {

func TestCookieSession_Save(t *testing.T) {
var cf ConfigOptions
cf.maxAge = 3600
cf.MaxAge = 3600
m, err := NewSessionManager("dsdfs6dfs61dssdfsdfdsdsfsdsdllsd", cf)
if err != nil {
fmt.Println(err)
Expand Down
8 changes: 4 additions & 4 deletions sessionManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ func NewSessionManager(secretKey string, config ConfigOptions) (SessionManager,
// Creates a new session if one doesn't exist in request
func (m *Manager) NewSession(r *http.Request, name string) Session {
var rtn Session
if m.config.sessionType == cookieSession {
if m.config.SessionType == cookieSession {
eses, err := m.getSession(r, name)
if eses != nil && err == nil {
rtn = eses
} else {
var ses CookieSession
ses.manager = m
ses.name = name
if m.config.path == "" {
if m.config.Path == "" {
ses.path = "/"
} else {
ses.path = m.config.path
ses.path = m.config.Path
}
ses.maxAge = m.config.maxAge
ses.maxAge = m.config.MaxAge
ses.values = make(map[any]any)
rtn = &ses
}
Expand Down
20 changes: 10 additions & 10 deletions sessionManager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ func TestNewSessionManager(t *testing.T) {
args: args{
secretKey: "dsdfs6dfs61dssdfsdfdsdsfsdsdllsd",
config: ConfigOptions{
path: "/",
maxAge: 3600,
Path: "/",
MaxAge: 3600,
},
},
wantErr: false,
Expand All @@ -242,8 +242,8 @@ func TestNewSessionManager(t *testing.T) {
args: args{
secretKey: "dsdfs6",
config: ConfigOptions{
path: "/",
maxAge: 3600,
Path: "/",
MaxAge: 3600,
},
},
wantErr: true,
Expand Down Expand Up @@ -327,8 +327,8 @@ func TestManager_NewSession(t *testing.T) {
fields: fields{
cookies: cookies,
config: ConfigOptions{
path: "/",
maxAge: 3600,
Path: "/",
MaxAge: 3600,
},
},
args: args{
Expand All @@ -341,8 +341,8 @@ func TestManager_NewSession(t *testing.T) {
fields: fields{
cookies: cookies,
config: ConfigOptions{
path: "",
maxAge: 3600,
Path: "",
MaxAge: 3600,
},
},
args: args{
Expand All @@ -355,8 +355,8 @@ func TestManager_NewSession(t *testing.T) {
fields: fields{
cookies: cookies,
config: ConfigOptions{
path: "/",
maxAge: 3600,
Path: "/",
MaxAge: 3600,
},
},
args: args{
Expand Down

0 comments on commit 1aac8ca

Please sign in to comment.