blob: 87d17f42fc5de2737ab9973b706d877b8ee720af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package authentication
import (
"glsamaker/pkg/database/connection"
"glsamaker/pkg/logger"
"glsamaker/pkg/models"
"net/http"
)
func Logout(w http.ResponseWriter, r *http.Request) {
sessionID, err := r.Cookie("session")
if err != nil || sessionID == nil {
// TODO Error
}
session := &models.Session{Id: sessionID.Value}
_, err = connection.DB.Model(session).WherePK().Delete()
if err != nil {
logger.Info.Println("Error deleting session")
logger.Error.Println("Error deleting session")
logger.Error.Println(err)
}
http.Redirect(w, r, "/", 301)
}
|