refactor authenticate to use Token.

This commit is contained in:
Miroslav Šedivý
2021-03-13 20:42:56 +01:00
parent 6b638db825
commit 58b00525cc
4 changed files with 27 additions and 38 deletions

View File

@ -59,7 +59,7 @@ func (api *ApiManagerCtx) Route(r chi.Router) {
func (api *ApiManagerCtx) Authenticate(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
session, err := api.sessions.AuthenticateRequest(r)
session, err := api.sessions.Authenticate(r)
if err != nil {
utils.HttpUnauthorized(w, err)
} else {

View File

@ -30,11 +30,12 @@ func (api *ApiManagerCtx) Login(w http.ResponseWriter, r *http.Request) {
return
}
session, err := api.sessions.Authenticate(data.ID, data.Secret)
if err != nil {
utils.HttpUnauthorized(w, err)
// TODO: Proper login.
//session, err := api.sessions.Authenticate(data.ID, data.Secret)
//if err != nil {
utils.HttpUnauthorized(w, "no authentication implemented")
return
}
//}
sameSite := http.SameSiteNoneMode
if UnsecureCookies {