1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-11 02:13:41 +09:00

GO-4848: Add app_name param to display_code endpoint

This commit is contained in:
Jannis Metrikat 2025-01-15 21:34:54 +01:00
parent 50f6b2819e
commit b40b2817e0
No known key found for this signature in database
GPG key ID: B223CAC5AAF85615
4 changed files with 30 additions and 3 deletions

View file

@ -36,6 +36,15 @@ const docTemplate = `{
"auth"
],
"summary": "Open a modal window with a code in Anytype Desktop app",
"parameters": [
{
"type": "string",
"description": "The name of the app that requests the code",
"name": "app_name",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "Challenge ID",

View file

@ -30,6 +30,15 @@
"auth"
],
"summary": "Open a modal window with a code in Anytype Desktop app",
"parameters": [
{
"type": "string",
"description": "The name of the app that requests the code",
"name": "app_name",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "Challenge ID",

View file

@ -338,6 +338,12 @@ paths:
post:
consumes:
- application/json
parameters:
- description: The name of the app that requests the code
in: query
name: app_name
required: true
type: string
produces:
- application/json
responses:

View file

@ -14,12 +14,15 @@ import (
// @Tags auth
// @Accept json
// @Produce json
// @Success 200 {object} DisplayCodeResponse "Challenge ID"
// @Failure 502 {object} util.ServerError "Internal server error"
// @Param app_name query string true "The name of the app that requests the code"
// @Success 200 {object} DisplayCodeResponse "Challenge ID"
// @Failure 502 {object} util.ServerError "Internal server error"
// @Router /auth/display_code [post]
func DisplayCodeHandler(s *AuthService) gin.HandlerFunc {
return func(c *gin.Context) {
challengeId, err := s.GenerateNewChallenge(c.Request.Context(), "api-test")
appName := c.Query("app_name")
challengeId, err := s.GenerateNewChallenge(c.Request.Context(), appName)
code := util.MapErrorCode(err, util.ErrToCode(ErrFailedGenerateChallenge, http.StatusInternalServerError))
if code != http.StatusOK {