mirror of https://github.com/usememos/memos
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
346 B
Go
20 lines
346 B
Go
package api
|
|
|
|
import (
|
|
"memos/common/error"
|
|
"net/http"
|
|
)
|
|
|
|
func AuthCheckerMiddleWare(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
userId, err := GetUserIdInCookie(r)
|
|
|
|
if err != nil || userId == "" {
|
|
error.ErrorHandler(w, "NOT_AUTH")
|
|
return
|
|
}
|
|
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|