Skip to content

Latest commit

 

History

History
77 lines (72 loc) · 2.75 KB

README.md

File metadata and controls

77 lines (72 loc) · 2.75 KB

Fauna Superprofile Saas Setup

To access the Admin section which includes the Event Create Menu, there would be a need to setup the Superprofile, currently we use FaunaDB for handling this. Follow this link instructions to get the Fauna key, then paste it in the .env as:

NEXT_PUBLIC_FAUNA_SECRET="your private key"

To get more familiar with Fauna here is a quick short workshop link

Or here is a quick guide to get started with Fauna:

  1. Head to dashboard.fauna.com, if you are logged in, click CREATE DATABASE, choose the US server.

image

2. In the left section click the __GraphQL__ and then __IMPORT SCHEMA__; schema to be uploaded is located in `../assets/rc4community-schema.graphql`. 3. Go to the __Functions__ tab, there will be two functions, in the UpserUser, replace it with the following function code.
UpsertUser function
Query(
  Lambda(
    ["uid", "email", "displayName", "phoneNumber", "photoURL"],
    Let(
      {
        user: Match(Index("getByEmail"), Var("email")),
        upsert: If(
          Exists(Var("user")),
          Update(Select(["ref"], Get(Var("user"))), {
            data: {
              displayName: Var("displayName"),
              phoneNumber: Var("phoneNumber"),
              photoURL: Var("photoURL")
            }
          }),
          Create(Collection("User"), {
            data: {
              uid: Var("uid"),
              email: Var("email"),
              displayName: Var("displayName"),
              phoneNumber: Var("phoneNumber"),
              photoURL: Var("photoURL")
            }
          })
        )
      },
      Var("upsert")
    )
  )
)
  1. Under the Security tab click on NEW KEY no need to modify anything, go with defaults, then hit the SAVE, copy the KEY'S SECRET and paste it in the .env as:
NEXT_PUBLIC_FAUNA_SECRET="your key's secret"
NEXT_PUBLIC_FAUNA_DOMAIN="https://graphql.us.fauna.com/graphql"

  1. Create the first basic user using the GraphQL tab, following is the mutation schema of a GraphQL query to create a user
mutation {
  createUser(data: {
    displayName: "YOUR_NAME"
    email: "NEXT_PUBLIC_EVENT_ADMIN_MAIL"
    uid: "ANY_UNIQUE_NUMBER"
    rc4conf: {
      create: {
        role: "Admin"
        email: "NEXT_PUBLIC_EVENT_ADMIN_MAIL"
      }
    }
  }) {
    _id
    displayName
  }
}
  1. Congrats! and thank you! for reading this. With this you are all set, to access Admin menus.