You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
394 B

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package utils
  5. import "code.gitea.io/gitea/modules/context"
  6. // UserID user ID of authenticated user, or 0 if not authenticated
  7. func UserID(ctx *context.APIContext) int64 {
  8. if ctx.User == nil {
  9. return 0
  10. }
  11. return ctx.User.ID
  12. }