mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-05-25 19:17:19 +08:00
#12, API: list user repos, list repo hooks
This commit is contained in:
@ -25,21 +25,7 @@ func SignedInId(req *http.Request, sess session.Store) int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
uid := sess.Get("uid")
|
||||
if uid == nil {
|
||||
return 0
|
||||
}
|
||||
if id, ok := uid.(int64); ok {
|
||||
if _, err := models.GetUserById(id); err != nil {
|
||||
if err != models.ErrUserNotExist {
|
||||
log.Error(4, "GetUserById: %v", err)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// API calls also need to check access token.
|
||||
// API calls need to check access token.
|
||||
if strings.HasPrefix(req.URL.Path, "/api/") {
|
||||
auHead := req.Header.Get("Authorization")
|
||||
if len(auHead) > 0 {
|
||||
@ -56,6 +42,20 @@ func SignedInId(req *http.Request, sess session.Store) int64 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uid := sess.Get("uid")
|
||||
if uid == nil {
|
||||
return 0
|
||||
}
|
||||
if id, ok := uid.(int64); ok {
|
||||
if _, err := models.GetUserById(id); err != nil {
|
||||
if err != models.ErrUserNotExist {
|
||||
log.Error(4, "GetUserById: %v", err)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
return id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user