diff --git a/handler/download/download.go b/handler/download/download.go index c8da242..c612e5b 100644 --- a/handler/download/download.go +++ b/handler/download/download.go @@ -30,9 +30,9 @@ func GET(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - storeSession, err := session.Store.Get(cookie.Value) + storeSession, err := session.GlobalSessionStore.Get(cookie.Value) if err != nil { - if errors.Is(err, &session.SessionNotFound{}) { + if errors.Is(err, &session.SessionNotFoundError{}) { storeSession.Destroy(w) } http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/handler/forgotPassword/verify/verify.go b/handler/forgotPassword/verify/verify.go index e577ba5..e5b3a9c 100644 --- a/handler/forgotPassword/verify/verify.go +++ b/handler/forgotPassword/verify/verify.go @@ -94,7 +94,7 @@ func POST(w http.ResponseWriter, r *http.Request) { delete(forgotPasswordHandler.ListForgotPassword, data.User.Email) delete(forgotPasswordHandler.UserForgotPassword, data.Code) - session.RemoveAllSession(data.User.Email) + session.RemoveAllSessions(data.User.Email) user.DeleteCache(data.User.Email) diff --git a/handler/logout/logout.go b/handler/logout/logout.go index 6c6fd2f..4eda278 100644 --- a/handler/logout/logout.go +++ b/handler/logout/logout.go @@ -21,17 +21,17 @@ func GET(w http.ResponseWriter, r *http.Request) { return } - storeSession, err := session.Store.Get(cookie.Value) + storeSession, err := session.GlobalSessionStore.Get(cookie.Value) if err != nil { - if errors.Is(err, &session.SessionNotFound{}) { + if errors.Is(err, &session.SessionNotFoundError{}) { storeSession.Destroy(w) } http.Error(w, err.Error(), http.StatusInternalServerError) return } - session.Store.Delete(cookie.Value) - session.RemoveSession(storeSession.Values["user"].(types.User).Email, cookie.Value) + session.GlobalSessionStore.Delete(cookie.Value) + session.RemoveSessionInfo(storeSession.Values["user"].(types.User).Email, cookie.Value) http.SetCookie(w, &http.Cookie{ Name: utils.Getenv("SESSION_NAME"), diff --git a/handler/signin/signin.go b/handler/signin/signin.go index ef8a55a..c6d52e4 100644 --- a/handler/signin/signin.go +++ b/handler/signin/signin.go @@ -57,7 +57,7 @@ func POST(w http.ResponseWriter, r *http.Request) { } if email == userData.Email && utils.CheckPasswordHash(password, userData.Password) { - storeSession := session.Store.Create() + storeSession := session.GlobalSessionStore.Create() storeSession.Values["user"] = types.User{ UserID: userData.UserID, Email: email, @@ -79,7 +79,7 @@ func POST(w http.ResponseWriter, r *http.Request) { } storeSession.Save(w) - session.AppendSession(email, &sessionInfo) + session.AddSessionInfo(email, &sessionInfo) cookie, err := r.Cookie("redirect") if errors.Is(err, http.ErrNoCookie) { diff --git a/handler/upload/initialisation/initialisation.go b/handler/upload/initialisation/initialisation.go index 630f5cd..a5026f1 100644 --- a/handler/upload/initialisation/initialisation.go +++ b/handler/upload/initialisation/initialisation.go @@ -30,9 +30,9 @@ func POST(w http.ResponseWriter, r *http.Request) { return } - storeSession, err := session.Store.Get(cookie.Value) + storeSession, err := session.GlobalSessionStore.Get(cookie.Value) if err != nil { - if errors.Is(err, &session.SessionNotFound{}) { + if errors.Is(err, &session.SessionNotFoundError{}) { storeSession.Destroy(w) } http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/handler/upload/upload.go b/handler/upload/upload.go index c3fa1b7..83f6003 100644 --- a/handler/upload/upload.go +++ b/handler/upload/upload.go @@ -44,9 +44,9 @@ func POST(w http.ResponseWriter, r *http.Request) { return } - storeSession, err := session.Store.Get(cookie.Value) + storeSession, err := session.GlobalSessionStore.Get(cookie.Value) if err != nil { - if errors.Is(err, &session.SessionNotFound{}) { + if errors.Is(err, &session.SessionNotFoundError{}) { storeSession.Destroy(w) } http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/handler/user/user.go b/handler/user/user.go index a11d2e3..07ad7f7 100644 --- a/handler/user/user.go +++ b/handler/user/user.go @@ -20,9 +20,9 @@ func GET(w http.ResponseWriter, r *http.Request) { if err != nil { return } - storeSession, err := session.Store.Get(cookie.Value) + storeSession, err := session.GlobalSessionStore.Get(cookie.Value) if err != nil { - if errors.Is(err, &session.SessionNotFound{}) { + if errors.Is(err, &session.SessionNotFoundError{}) { storeSession.Destroy(w) } http.Error(w, err.Error(), http.StatusInternalServerError) @@ -35,7 +35,7 @@ func GET(w http.ResponseWriter, r *http.Request) { return } - component := userView.Main("User Page", userSession.Email, userSession.Username, session.UserSessions[userSession.Email]) + component := userView.Main("User Page", userSession.Email, userSession.Username, session.UserSessionInfoList[userSession.Email]) err = component.Render(r.Context(), w) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/middleware/middleware.go b/middleware/middleware.go index 4b94b3e..dde1de0 100644 --- a/middleware/middleware.go +++ b/middleware/middleware.go @@ -74,10 +74,10 @@ func Auth(next http.HandlerFunc, w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - storeSession, err := session.Store.Get(cookie.Value) + storeSession, err := session.GlobalSessionStore.Get(cookie.Value) if err != nil { - if errors.Is(err, &session.SessionNotFound{}) { + if errors.Is(err, &session.SessionNotFoundError{}) { storeSession.Destroy(w) http.Redirect(w, r, "/signin", http.StatusSeeOther) return @@ -112,9 +112,9 @@ func Guest(next http.HandlerFunc, w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - storeSession, err := session.Store.Get(cookie.Value) + storeSession, err := session.GlobalSessionStore.Get(cookie.Value) if err != nil { - if errors.Is(err, &session.SessionNotFound{}) { + if errors.Is(err, &session.SessionNotFoundError{}) { http.SetCookie(w, &http.Cookie{ Name: "Session", Value: "", diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 06b673b..0000000 --- a/public/index.html +++ /dev/null @@ -1,222 +0,0 @@ - - - -
- - -Enter your email below to reset your password
-