mirror of
https://github.com/usememos/memos.git
synced 2025-02-22 06:07:51 +01:00
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)
|
||
|
})
|
||
|
}
|