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.
24 lines
397 B
Go
24 lines
397 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
type Response struct {
|
|
Succeed bool `json:"succeed"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data"`
|
|
}
|
|
|
|
func GetUserIdInSession(r *http.Request) (string, error) {
|
|
session, _ := SessionStore.Get(r, "session")
|
|
|
|
userId, ok := session.Values["user_id"].(string)
|
|
|
|
if !ok {
|
|
return "", http.ErrNoCookie
|
|
}
|
|
|
|
return userId, nil
|
|
}
|