Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: only return register token against localhost, add descriptions to fields #413

Merged
merged 2 commits into from
Jan 26, 2025

Conversation

golanglemonade
Copy link
Member

@golanglemonade golanglemonade commented Jan 26, 2025

  • We currently return the verify token on the register request to make dev easier, however, we shouldn't directly return the email verification token on the response in prod. This changes it to only return it when the server is running with dev:true and removes the field from the OpenAPI spec.

server.dev=true

(⎈ |default:default)➜  core-more git:(feat-verify) ✗ go run cmd/cli/main.go register --email="[email protected]" --first-name=sarah --last-name=funk -p test\!1234asd -z json
{
  "email": "[email protected]",
  "message": "Welcome to Openlane!",
  "success": true,
  "token": "eYPdf61gNyT6__OqT-_6eUwak7j9hkBKxI9z7gO4ZGM",
  "user_id": "01JJHTJA7DY351YM6DJH5N6VN3"
}

server.dev=false

(⎈ |default:default)➜  core-more git:(feat-verify) ✗ go run cmd/cli/main.go register --email="[email protected]" --first-name=sarah --last-name=funk -p test\!1234asd -z json
{
  "email": "[email protected]",
  "message": "Welcome to Openlane!",
  "success": true,
  "user_id": "01JJHTMJRVVAS50XE0VDS4PZJE"
}
  • Adds description + examples to openAPI spec

Example updated api spec section:

  "RegisterReply": {
        "properties": {
          "email": {
            "description": "The email address of the user",
            "type": "string"
          },
          "error": {
            "description": "The error message if the request was unsuccessful",
            "type": "string"
          },
          "error_code": {
            "description": "The error code if the request was unsuccessful",
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "success": {
            "description": "Whether or not the request was successful or not",
            "type": "boolean"
          },
          "unverified": {
            "type": "boolean"
          },
          "user_id": {
            "description": "The ID of the user that was created",
            "example": "01J4EXD5MM60CX4YNYN0DEE3Y1",
            "type": "string"
          }
        },
        "type": "object"
      },
      "RegisterRequest": {
        "properties": {
          "email": {
            "description": "The email address of the user",
            "example": "[email protected]",
            "type": "string"
          },
          "first_name": {
            "description": "The first name of the user",
            "example": "Jon",
            "type": "string"
          },
          "last_name": {
            "description": "The last name of the user",
            "example": "Snow",
            "type": "string"
          },
          "password": {
            "description": "The password to be used for authentication after registration",
            "example": "Wint3rIsC0ming123!",
            "type": "string"
          }
        },
        "type": "object"
      },

@golanglemonade golanglemonade marked this pull request as ready for review January 26, 2025 05:13
@golanglemonade golanglemonade requested a review from a team as a code owner January 26, 2025 05:13
@golanglemonade golanglemonade enabled auto-merge (squash) January 26, 2025 05:19
Signed-off-by: Sarah Funkhouser <[email protected]>
@golanglemonade golanglemonade merged commit 7f94413 into main Jan 26, 2025
16 checks passed
@golanglemonade golanglemonade deleted the feat-verify branch January 26, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request httpserve
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants