snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
20
user/current.go
Normal file
20
user/current.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/traggo/server/auth"
|
||||
"github.com/traggo/server/generated/gqlmodel"
|
||||
)
|
||||
|
||||
// CurrentUser returns the current user.
|
||||
func (r *ResolverForUser) CurrentUser(ctx context.Context) (*gqlmodel.User, error) {
|
||||
user := auth.GetUser(ctx)
|
||||
if user == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var result gqlmodel.User
|
||||
copier.Copy(&result, user)
|
||||
return &result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user