Finished: tag

This commit is contained in:
2021-12-12 15:41:33 +08:00
parent 5a68cea2f3
commit dfc0b43bdd
7 changed files with 66 additions and 9 deletions

View File

@@ -163,3 +163,13 @@ func (api *API) CheckAdmin(w http.ResponseWriter, r *http.Request) error {
w.WriteHeader(http.StatusOK)
return nil
}
func (api *API) GetUserID(w http.ResponseWriter, r *http.Request) (int64, error) {
session, _ := api.store.Get(r, api.defaultSessionName)
userId, ok := session.Values["userId"]
if !ok {
return 0, ErrNotLoggedIn
}
return userId.(int64), nil
}