1
0
Fork 0
forked from forgejo/forgejo

#12, API: list user repos, list repo hooks

This commit is contained in:
Unknwon 2014-11-13 02:32:18 -05:00
parent 8c9338a537
commit 8eb5120fbd
12 changed files with 315 additions and 37 deletions

View file

@ -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
}