card-jong-be/controller/session.go

26 lines
486 B
Go
Raw Normal View History

2024-05-16 22:15:52 +00:00
package controller
import (
"github.com/nrednav/cuid2"
"net/http"
)
var Users map[string]string = make(map[string]string)
func Register(username string) string {
uid := cuid2.Generate()
// Store in the users map
Users[uid] = username
return uid
}
func ValidateId(writer http.ResponseWriter, request *http.Request) {
if AuthHeaderIsValid(request.Header.Get("Authorization")) {
writer.WriteHeader(http.StatusOK)
} else {
writer.WriteHeader(http.StatusUnauthorized)
}
}