20 lines
361 B
Go
20 lines
361 B
Go
package directives
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/99designs/gqlgen/graphql"
|
|
"github.com/farahty/go-mongo/app"
|
|
)
|
|
|
|
func Auth(ctx context.Context, obj interface{}, next graphql.Resolver) (res interface{}, err error) {
|
|
|
|
if _, err := app.CurrentUser(ctx); err != nil {
|
|
return nil, fmt.Errorf("access denied, %s", err.Error())
|
|
}
|
|
|
|
return next(ctx)
|
|
|
|
}
|