user_classic.go 816 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2015 Google Inc. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. // +build appengine
  5. package user
  6. import (
  7. "appengine/user"
  8. "golang.org/x/net/context"
  9. "google.golang.org/appengine/internal"
  10. )
  11. func Current(ctx context.Context) *User {
  12. u := user.Current(internal.ClassicContextFromContext(ctx))
  13. if u == nil {
  14. return nil
  15. }
  16. // Map appengine/user.User to this package's User type.
  17. return &User{
  18. Email: u.Email,
  19. AuthDomain: u.AuthDomain,
  20. Admin: u.Admin,
  21. ID: u.ID,
  22. FederatedIdentity: u.FederatedIdentity,
  23. FederatedProvider: u.FederatedProvider,
  24. }
  25. }
  26. func IsAdmin(ctx context.Context) bool {
  27. return user.IsAdmin(internal.ClassicContextFromContext(ctx))
  28. }