vigiloauth/vigilo

Add endpoint to allow users to set security questions during registration

開放

#370 建立於 2025年6月3日

 (2 則留言) (0 個反應) (1 位負責人)Go (9 個分叉)auto 404
admin-uifeaturegood first issuepriority: medium

倉庫指標

星標
 (100 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Description: We need an endpoint that allows setting security questions and answers for a specific user (by user ID). This will help support account recovery and additional authentication flows in the future.

Endpoint:

  • Method: POST
  • Path: /users/{user_id}/security-questions

Example Request Body:

{
  "questions": [
    {
      "question": "What was the name of your first pet?",
      "answer": "Fluffy"
    },
    {
      "question": "What is your mother’s maiden name?",
      "answer": "Smith"
    }
  ]
}

Requirements

  • Validate that the user_id corresponds to an existing user.
  • Accept a slice of 2–3 questions and answers.
  • Hash the answers before saving (do not store plain text answers).
  • Store them in the DB.
  • Return 200 OK on success.
  • Return 400 Bad Request for validation errors.
  • Return 404 Not Found when the user doesn't exist with the given ID.
  • Return 500 Internal Server Error when appropriate.
  • Include basic validation: ensure both question and answer are non-empty strings.

貢獻者指南