Add functionality for session termination
This commit is contained in:
23
handler/user/session/terminate/terminate.go
Normal file
23
handler/user/session/terminate/terminate.go
Normal 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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user