From 5bb088d1eeea5c7925eecbf2d5480497efc56cea Mon Sep 17 00:00:00 2001 From: cosmonawt Date: Sat, 2 Jun 2018 14:51:20 +0200 Subject: [PATCH] http: server serve static files --- auth/sessionId.go | 2 +- auth/sessionId_test.go | 6 ++-- course.go | 2 +- http/middleware.go | 6 ++-- http/middleware_test.go | 10 +++--- http/routes.go | 10 ------ http/server.go | 1 + http/userHandler.go | 12 +++---- mock/repository.go | 20 +++++------ mock/service.go | 24 ++++++------- mongodb/userRepository.go | 12 +++---- service/courseService_test.go | 6 ++-- service/userService.go | 20 +++++------ service/userService_test.go | 64 +++++++++++++++++------------------ static/index.html | 8 +++++ user.go | 12 +++---- 16 files changed, 107 insertions(+), 108 deletions(-) create mode 100644 static/index.html diff --git a/auth/sessionId.go b/auth/sessionId.go index fcb9671..1596df8 100644 --- a/auth/sessionId.go +++ b/auth/sessionId.go @@ -2,7 +2,7 @@ package auth import "github.com/satori/go.uuid" -func (Authenticator) SessionId() string { +func (Authenticator) SessionID() string { v4 := uuid.NewV4() return v4.String() } diff --git a/auth/sessionId_test.go b/auth/sessionId_test.go index 59c4e6c..ed811da 100644 --- a/auth/sessionId_test.go +++ b/auth/sessionId_test.go @@ -6,12 +6,12 @@ import ( "testing" ) -func TestAuthenticator_CreateAccessToken(t *testing.T) { +func TestAuthenticator_SessionID(t *testing.T) { t.Parallel() authenticator := Authenticator{} - sessionId := authenticator.SessionId() + sessionID := authenticator.SessionID() - id, err := uuid.FromString(sessionId) + id, err := uuid.FromString(sessionID) assert.Nil(t, err, "should not cause error") assert.Equal(t, byte(4), id.Version(), "should create UUID v4") } diff --git a/course.go b/course.go index 52ea987..ee17c78 100644 --- a/course.go +++ b/course.go @@ -3,7 +3,7 @@ package eduboard import "gopkg.in/mgo.v2/bson" type Course struct { - Id bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"` + ID bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"` Name string `json:"name,omitempty" bson:"name,omitempty"` Description string `json:"description,omitempty" bson:"description,omitempty"` Members []string `json:"members,omitempty" bson:"members,omitempty"` diff --git a/http/middleware.go b/http/middleware.go index 16416ae..4565e7a 100644 --- a/http/middleware.go +++ b/http/middleware.go @@ -13,8 +13,8 @@ func NewAuthMiddleware(provider eduboard.UserAuthenticationProvider, nextHandler return } - accessToken := cookie.Value - err, ok := provider.CheckAuthentication(accessToken) + sessionID := cookie.Value + err, ok := provider.CheckAuthentication(sessionID) if err != nil || !ok { w.WriteHeader(http.StatusForbidden) return @@ -22,4 +22,4 @@ func NewAuthMiddleware(provider eduboard.UserAuthenticationProvider, nextHandler nextHandler.ServeHTTP(w, r) } -} +} \ No newline at end of file diff --git a/http/middleware_test.go b/http/middleware_test.go index 57721f2..a9405de 100644 --- a/http/middleware_test.go +++ b/http/middleware_test.go @@ -11,11 +11,11 @@ import ( func TestAppServer_NewAuthMiddleware(t *testing.T) { var as = &mock.UserAuthenticationProvider{ - CheckAuthenticationFn: func(sessionId string) (err error, ok bool) { - if sessionId == "" { - return errors.New("empty sessionId"), false + CheckAuthenticationFn: func(sessionID string) (err error, ok bool) { + if sessionID == "" { + return errors.New("empty sessionID"), false } - if sessionId == "invalid" { + if sessionID == "invalid" { return errors.New("not found"), false } return nil, true @@ -61,4 +61,4 @@ func TestAppServer_NewAuthMiddleware(t *testing.T) { assert.True(t, as.CheckAuthenticationFnInvoked, "authentication was not actually checked") }) } -} +} \ No newline at end of file diff --git a/http/routes.go b/http/routes.go index 42778a4..4fbbada 100644 --- a/http/routes.go +++ b/http/routes.go @@ -1,15 +1,11 @@ package http import ( - "fmt" "github.com/julienschmidt/httprouter" - "net/http" ) func (a *AppServer) authenticatedRoutes() *httprouter.Router { router := httprouter.New() - //router.GET("/index.html", a.serveFilesHandler()) - //router.GET("/static/*", a.serveFilesHandler()) // User router.GET("/api/v1/user/:id", a.getUserHandler()) @@ -29,9 +25,3 @@ func (a *AppServer) publicRoutes() *httprouter.Router { router.POST("/api/logout", a.logoutUserHandler()) return router } - -func (a *AppServer) serveFilesHandler() httprouter.Handle { - return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { - fmt.Fprint(w, "hello world") - } -} diff --git a/http/server.go b/http/server.go index 04a3e92..96bf8b0 100644 --- a/http/server.go +++ b/http/server.go @@ -20,6 +20,7 @@ func (a *AppServer) initialize() { mux := http.NewServeMux() mux.Handle("/api/v1/", NewAuthMiddleware(a.UserService, protected)) mux.Handle("/api/", public) + mux.Handle("/", http.FileServer(http.Dir("./static"))) a.httpServer = &http.Server{ Addr: ":8080", diff --git a/http/userHandler.go b/http/userHandler.go index f4504e4..d890ab1 100644 --- a/http/userHandler.go +++ b/http/userHandler.go @@ -15,7 +15,7 @@ func (a *AppServer) registerUserHandler() httprouter.Handle { Password string `json:"password"` } type response struct { - Id string `json:"id"` + ID string `json:"id"` Email string `json:"email"` } @@ -37,9 +37,9 @@ func (a *AppServer) registerUserHandler() httprouter.Handle { w.WriteHeader(http.StatusInternalServerError) return } - response := response{Id: user.Id.Hex(), Email: user.Email} + response := response{ID: user.ID.Hex(), Email: user.Email} - cookie := createCookie(user.SessionId) + cookie := createCookie(user.SessionID) http.SetCookie(w, &cookie) if err = json.NewEncoder(w).Encode(response); err != nil { w.WriteHeader(http.StatusInternalServerError) @@ -72,7 +72,7 @@ func (a *AppServer) loginUserHandler() httprouter.Handle { return } - cookie := createCookie(user.SessionId) + cookie := createCookie(user.SessionID) response := response{user.Name, user.Surname, user.Email} http.SetCookie(w, &cookie) if err = json.NewEncoder(w).Encode(response); err != nil { @@ -83,12 +83,12 @@ func (a *AppServer) loginUserHandler() httprouter.Handle { func (a *AppServer) logoutUserHandler() httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { - sessionId, err := r.Cookie("sessionId") + sessionID, err := r.Cookie("sessionID") if err != nil { w.WriteHeader(http.StatusOK) return } - err = a.UserService.Logout(sessionId.Value) + err = a.UserService.Logout(sessionID.Value) if err != nil { w.WriteHeader(http.StatusInternalServerError) return diff --git a/mock/repository.go b/mock/repository.go index 6c4ffdf..e736b38 100644 --- a/mock/repository.go +++ b/mock/repository.go @@ -47,11 +47,11 @@ type UserRepository struct { FindByEmailFn func(email string) (error, *eduboard.User) FindByEmailFnInvoked bool - FindBySessionIdFn func(sessionId string) (error, *eduboard.User) - FindBySessionIdFnInvoked bool + FindBySessionIDFn func(sessionID string) (error, *eduboard.User) + FindBySessionIDFnInvoked bool - UpdateSessionIdFn func(user *eduboard.User) (error, *eduboard.User) - UpdateSessionIdFnInvoked bool + UpdateSessionIDFn func(user *eduboard.User) (error, *eduboard.User) + UpdateSessionIDFnInvoked bool } var _ eduboard.UserRepository = (*UserRepository)(nil) @@ -71,12 +71,12 @@ func (uRM *UserRepository)FindByEmail(email string) (error, *eduboard.User) { return uRM.FindByEmailFn(email) } -func (uRM *UserRepository)FindBySessionId(sessionId string) (error, *eduboard.User) { - uRM.FindBySessionIdFnInvoked = true - return uRM.FindBySessionIdFn(sessionId) +func (uRM *UserRepository)FindBySessionID(sessionID string) (error, *eduboard.User) { + uRM.FindBySessionIDFnInvoked = true + return uRM.FindBySessionIDFn(sessionID) } -func (uRM *UserRepository)UpdateSessionId(user *eduboard.User) (error, *eduboard.User) { - uRM.UpdateSessionIdFnInvoked = true - return uRM.UpdateSessionIdFn(user) +func (uRM *UserRepository)UpdateSessionID(user *eduboard.User) (error, *eduboard.User) { + uRM.UpdateSessionIDFnInvoked = true + return uRM.UpdateSessionIDFn(user) } diff --git a/mock/service.go b/mock/service.go index af7d11d..244afde 100644 --- a/mock/service.go +++ b/mock/service.go @@ -54,10 +54,10 @@ type UserAuthenticationProvider struct { LoginFn func(email string, password string) (error, *eduboard.User) LoginFnInvoked bool - LogoutFn func(accessToken string) error + LogoutFn func(sessionID string) error LogoutFnInvoked bool - CheckAuthenticationFn func(sessionId string) (err error, ok bool) + CheckAuthenticationFn func(sessionID string) (err error, ok bool) CheckAuthenticationFnInvoked bool } @@ -69,19 +69,19 @@ func (uAM *UserAuthenticationProvider) Login(email string, password string) (err return uAM.LoginFn(email, password) } -func (uAM *UserAuthenticationProvider) Logout(sessionId string) error { +func (uAM *UserAuthenticationProvider) Logout(sessionID string) error { uAM.LogoutFnInvoked = true - return uAM.LogoutFn(sessionId) + return uAM.LogoutFn(sessionID) } -func (uAM *UserAuthenticationProvider) CheckAuthentication(sessionId string) (err error, ok bool) { +func (uAM *UserAuthenticationProvider) CheckAuthentication(sessionID string) (err error, ok bool) { uAM.CheckAuthenticationFnInvoked = true - return uAM.CheckAuthenticationFn(sessionId) + return uAM.CheckAuthenticationFn(sessionID) } type Authenticator interface { Hash(password string) (string, error) CompareHash(hashedPassword string, plainPassword string) (bool, error) - SessionId() string + SessionID() string } type AuthenticatorMock struct { @@ -91,8 +91,8 @@ type AuthenticatorMock struct { CompareHashFn func(hashedPassword string, plainPassword string) (bool, error) CompareHashFnInvoked bool - SessionIdFn func() string - SessionIdFnInvoked bool + SessionIDFn func() string + SessionIDFnInvoked bool } var _ Authenticator = (*AuthenticatorMock)(nil) @@ -106,7 +106,7 @@ func (uAM *AuthenticatorMock) CompareHash(hashedPassword string, plainPassword s uAM.CompareHashFnInvoked = true return uAM.CompareHashFn(hashedPassword, plainPassword) } -func (uAM *AuthenticatorMock) SessionId() string { - uAM.SessionIdFnInvoked = true - return uAM.SessionIdFn() +func (uAM *AuthenticatorMock) SessionID() string { + uAM.SessionIDFnInvoked = true + return uAM.SessionIDFn() } diff --git a/mongodb/userRepository.go b/mongodb/userRepository.go index 35ab87d..a7f6004 100644 --- a/mongodb/userRepository.go +++ b/mongodb/userRepository.go @@ -19,8 +19,8 @@ func newUserRepository(database *mgo.Database) *UserRepository { } func (u *UserRepository) Store(user *eduboard.User) error { - if user.Id == "" { - user.Id = bson.NewObjectId() + if user.ID == "" { + user.ID = bson.NewObjectId() } return u.c.Insert(user) } @@ -38,8 +38,8 @@ func (u *UserRepository) Find(id string) (error, *eduboard.User) { return nil, &result } -func (u *UserRepository) FindBySessionId(accessToken string) (error, *eduboard.User) { - return u.findBy("sessionId", accessToken) +func (u *UserRepository) FindBySessionID(accessToken string) (error, *eduboard.User) { + return u.findBy("sessionID", accessToken) } func (u *UserRepository) FindByEmail(email string) (error, *eduboard.User) { @@ -56,8 +56,8 @@ func (u *UserRepository) findBy(key string, value string) (error, *eduboard.User return nil, &result } -func (u *UserRepository) UpdateSessionId(user *eduboard.User) (error, *eduboard.User) { - return u.updateValue(user.Id, "sessionId", user.SessionId) +func (u *UserRepository) UpdateSessionID(user *eduboard.User) (error, *eduboard.User) { + return u.updateValue(user.ID, "sessionID", user.SessionID) } func (u *UserRepository) updateValue(id bson.ObjectId, key string, value string) (error, *eduboard.User) { diff --git a/service/courseService_test.go b/service/courseService_test.go index b83947d..601fa16 100644 --- a/service/courseService_test.go +++ b/service/courseService_test.go @@ -24,8 +24,8 @@ func TestCourseService_GetAllCourses(t *testing.T) { service.r = &mockRepo - course1 := &eduboard.Course{Id: "1", Name: "Course 1"} - course2 := &eduboard.Course{Id: "2", Name: "Course 2"} + course1 := &eduboard.Course{ID: "1", Name: "Course 1"} + course2 := &eduboard.Course{ID: "2", Name: "Course 2"} var testCases = []struct { name string @@ -68,7 +68,7 @@ func TestCourseService_GetCourse(t *testing.T) { service.r = &mockRepo - course1 := &eduboard.Course{Id: "1", Name: "Course 1"} + course1 := &eduboard.Course{ID: "1", Name: "Course 1"} var testCases = []struct { name string diff --git a/service/userService.go b/service/userService.go index 029785e..bffa844 100644 --- a/service/userService.go +++ b/service/userService.go @@ -14,7 +14,7 @@ type UserService struct { type Authenticator interface { Hash(password string) (string, error) CompareHash(hashedPassword string, plainPassword string) (bool, error) - SessionId() string + SessionID() string } func NewUserService(repository eduboard.UserRepository) *UserService { @@ -39,7 +39,7 @@ func (uS *UserService) CreateUser(user *eduboard.User, password string) (error, return err, &eduboard.User{} } user.PasswordHash = hashedPassword - user.SessionId = uS.a.SessionId() + user.SessionID = uS.a.SessionID() err = uS.r.Store(user) if err != nil { @@ -66,8 +66,8 @@ func (uS *UserService) Login(email string, password string) (error, *eduboard.Us return errors.New("invalid password"), &eduboard.User{} } - user.SessionId = uS.a.SessionId() - err, user = uS.r.UpdateSessionId(user) + user.SessionID = uS.a.SessionID() + err, user = uS.r.UpdateSessionID(user) if err != nil { return err, &eduboard.User{} } @@ -75,20 +75,20 @@ func (uS *UserService) Login(email string, password string) (error, *eduboard.Us return nil, user } -func (uS *UserService) Logout(sessionId string) error { - err, user := uS.r.FindBySessionId(sessionId) +func (uS *UserService) Logout(sessionID string) error { + err, user := uS.r.FindBySessionID(sessionID) if err != nil { return err } - user.SessionId = "" - uS.r.UpdateSessionId(user) + user.SessionID = "" + uS.r.UpdateSessionID(user) return nil } -func (uS *UserService) CheckAuthentication(sessionId string) (err error, ok bool) { - err, _ = uS.r.FindBySessionId(sessionId) +func (uS *UserService) CheckAuthentication(sessionID string) (err error, ok bool) { + err, _ = uS.r.FindBySessionID(sessionID) if err != nil { return err, false } diff --git a/service/userService_test.go b/service/userService_test.go index 9f6f8c2..2758a29 100644 --- a/service/userService_test.go +++ b/service/userService_test.go @@ -12,21 +12,21 @@ var r = mock.UserRepository{ FindFnInvoked: false, FindFn: func(id string) (error, *eduboard.User) { if id == "0" { - return nil, &eduboard.User{Id: "0"} + return nil, &eduboard.User{ID: "0"} } return errors.New("not found"), &eduboard.User{} }, FindByEmailFnInvoked: false, FindByEmailFn: func(email string) (error, *eduboard.User) { if email == "existing@mail.com" { - return nil, &eduboard.User{Id: "0", PasswordHash: "password"} + return nil, &eduboard.User{ID: "0", PasswordHash: "password"} } return errors.New("not found"), &eduboard.User{} }, - FindBySessionIdFnInvoked: false, - FindBySessionIdFn: func(sessionId string) (error, *eduboard.User) { - if sessionId == "sessionID-0-0-0" { - return nil, &eduboard.User{Id: "1"} + FindBySessionIDFnInvoked: false, + FindBySessionIDFn: func(sessionID string) (error, *eduboard.User) { + if sessionID == "sessionID-0-0-0" { + return nil, &eduboard.User{ID: "1"} } return errors.New("not found"), &eduboard.User{} }, @@ -34,8 +34,8 @@ var r = mock.UserRepository{ StoreFn: func(user *eduboard.User) error { return nil }, - UpdateSessionIdFnInvoked: false, - UpdateSessionIdFn: func(user *eduboard.User) (error, *eduboard.User) { + UpdateSessionIDFnInvoked: false, + UpdateSessionIDFn: func(user *eduboard.User) (error, *eduboard.User) { return nil, user }, } @@ -51,8 +51,8 @@ var a = mock.AuthenticatorMock{ } return true, nil }, - SessionIdFnInvoked: false, - SessionIdFn: func() string { + SessionIDFnInvoked: false, + SessionIDFn: func() string { return "sessionID-0-0-0" }, } @@ -81,7 +81,7 @@ func TestUserService_CreateUser(t *testing.T) { for _, v := range testCases { t.Run(v.name, func(t *testing.T) { defer func() { r.FindByEmailFnInvoked = false }() - defer func() { a.SessionIdFnInvoked = false }() + defer func() { a.SessionIDFnInvoked = false }() defer func() { r.StoreFnInvoked = false }() defer func() { a.HashFnInvoked = false }() @@ -97,8 +97,8 @@ func TestUserService_CreateUser(t *testing.T) { assert.True(t, r.FindByEmailFnInvoked, "FindByEmail was not invoked") assert.True(t, a.HashFnInvoked, "Hash was not invoked") assert.Equal(t, v.password, user.PasswordHash, "did not hash password") - assert.True(t, a.SessionIdFnInvoked, "SessionId was not invoked") - assert.Equal(t, "sessionID-0-0-0", user.SessionId, "sessionId was not set") + assert.True(t, a.SessionIDFnInvoked, "SessionID was not invoked") + assert.Equal(t, "sessionID-0-0-0", user.SessionID, "sessionID was not set") assert.True(t, r.StoreFnInvoked, "Store was not invoked") }) } @@ -148,22 +148,22 @@ func TestUserService_Login(t *testing.T) { t.Run(v.name, func(t *testing.T) { defer func() { r.FindByEmailFnInvoked = false }() defer func() { a.CompareHashFnInvoked = false }() - defer func() { a.SessionIdFnInvoked = false }() - defer func() { r.UpdateSessionIdFnInvoked = false }() + defer func() { a.SessionIDFnInvoked = false }() + defer func() { r.UpdateSessionIDFnInvoked = false }() err, user := us.Login(v.email, v.password) if v.error { assert.NotNil(t, err, "did not fail to log in user") assert.Equal(t, &eduboard.User{}, user, "did not return empty user") - assert.False(t, r.UpdateSessionIdFnInvoked, "UpdateSessionId invoked") + assert.False(t, r.UpdateSessionIDFnInvoked, "UpdateSessionID invoked") return } assert.Nil(t, err, "should not fail to login user") assert.True(t, r.FindByEmailFnInvoked, "FindByEmail not invoked") assert.True(t, a.CompareHashFnInvoked, "CompareHash not invoked") - assert.True(t, a.SessionIdFnInvoked, "SessionId not invoked") - assert.True(t, r.UpdateSessionIdFnInvoked, "UpdateSessionId not invoked") - assert.Equal(t, "sessionID-0-0-0", user.SessionId, "did not update sessionId") + assert.True(t, a.SessionIDFnInvoked, "SessionID not invoked") + assert.True(t, r.UpdateSessionIDFnInvoked, "UpdateSessionID not invoked") + assert.Equal(t, "sessionID-0-0-0", user.SessionID, "did not update sessionID") }) } } @@ -171,7 +171,7 @@ func TestUserService_Login(t *testing.T) { func TestUserService_Logout(t *testing.T) { var testCases = []struct { name string - sessionId string + sessionID string error bool }{ {"unknown session", "someOtherSession", true}, @@ -180,19 +180,19 @@ func TestUserService_Logout(t *testing.T) { for _, v := range testCases { t.Run(v.name, func(t *testing.T) { - defer func() { r.FindBySessionIdFnInvoked = false }() - defer func() { r.UpdateSessionIdFnInvoked = false }() + defer func() { r.FindBySessionIDFnInvoked = false }() + defer func() { r.UpdateSessionIDFnInvoked = false }() - err := us.Logout(v.sessionId) + err := us.Logout(v.sessionID) if v.error { assert.NotNil(t, err, "did not fail") - assert.True(t, r.FindBySessionIdFnInvoked, "FindBySessionId was not invoked") - assert.False(t, r.UpdateSessionIdFnInvoked, "UpdateSessionIdFn was invoked") + assert.True(t, r.FindBySessionIDFnInvoked, "FindBySessionID was not invoked") + assert.False(t, r.UpdateSessionIDFnInvoked, "UpdateSessionIDFn was invoked") return } assert.Nil(t, err, "caused error logging out user") - assert.True(t, r.FindBySessionIdFnInvoked, "FindBySessionId was not invoked") - assert.True(t, r.UpdateSessionIdFnInvoked, "UpdateSessionId was not invoked") + assert.True(t, r.FindBySessionIDFnInvoked, "FindBySessionID was not invoked") + assert.True(t, r.UpdateSessionIDFnInvoked, "UpdateSessionID was not invoked") }) } } @@ -200,7 +200,7 @@ func TestUserService_Logout(t *testing.T) { func TestUserService_CheckAuthentication(t *testing.T) { var testCases = []struct { name string - sessionId string + sessionID string error bool }{ {"unknown session", "someOtherSession", true}, @@ -209,18 +209,18 @@ func TestUserService_CheckAuthentication(t *testing.T) { for _, v := range testCases { t.Run(v.name, func(t *testing.T) { - defer func() { r.FindBySessionIdFnInvoked = false }() + defer func() { r.FindBySessionIDFnInvoked = false }() - err, ok := us.CheckAuthentication(v.sessionId) + err, ok := us.CheckAuthentication(v.sessionID) if v.error { assert.NotNil(t, err, "did not fail") assert.False(t, ok, "should not be ok") - assert.True(t, r.FindBySessionIdFnInvoked, "UpdateSessionIdFn was invoked") + assert.True(t, r.FindBySessionIDFnInvoked, "UpdateSessionIDFn was invoked") return } assert.Nil(t, err, "caused error logging out user") assert.True(t, ok, "should be ok") - assert.True(t, r.FindBySessionIdFnInvoked, "FindBySessionId was not invoked") + assert.True(t, r.FindBySessionIDFnInvoked, "FindBySessionID was not invoked") }) } } diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..a0511e4 --- /dev/null +++ b/static/index.html @@ -0,0 +1,8 @@ + + + Eduboard + + + Hello World! + + diff --git a/user.go b/user.go index 81a082b..69f9411 100644 --- a/user.go +++ b/user.go @@ -3,12 +3,12 @@ package eduboard import "gopkg.in/mgo.v2/bson" type User struct { - Id bson.ObjectId `json:"id" bson:"_id,omitempty"` + ID bson.ObjectId `json:"id" bson:"_id,omitempty"` Name string `json:"name" bson:"name"` Surname string `json:"surname" bson:"surname"` Email string `json:"email" bson:"email"` PasswordHash string `json:"password" bson:"password"` - SessionId string `json:"sessionId" bson:"sessionId"` + SessionID string `json:"sessionId" bson:"sessionId"` Courses []string `json:"courses" bson:"courses"` } @@ -16,8 +16,8 @@ type UserRepository interface { Store(user *User) error Find(id string) (error, *User) FindByEmail(email string) (error, *User) - FindBySessionId(sessionId string) (error, *User) - UpdateSessionId(user *User) (error, *User) + FindBySessionID(sessionID string) (error, *User) + UpdateSessionID(user *User) (error, *User) } type UserService interface { @@ -28,6 +28,6 @@ type UserService interface { type UserAuthenticationProvider interface { Login(email string, password string) (error, *User) - Logout(sessionId string) error - CheckAuthentication(sessionId string) (err error, ok bool) + Logout(sessionID string) error + CheckAuthentication(sessionID string) (err error, ok bool) }