Add functionality for session termination

This commit is contained in:
2024-06-20 18:15:49 +07:00
parent b732262dcd
commit 949099124e
3 changed files with 59 additions and 4 deletions

View File

@ -0,0 +1,23 @@
package userSessionTerminateHandler
import (
"github.com/fossyy/filekeeper/session"
userView "github.com/fossyy/filekeeper/view/user"
"net/http"
)
func DELETE(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id")
_, mySession, _ := session.GetSession(r)
otherSession, _ := session.Get(id)
otherSession.Delete()
session.RemoveSessionInfo(mySession.Email, otherSession.ID)
component := userView.SessionTable(session.GetSessions(mySession.Email))
err := component.Render(r.Context(), w)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
}