refactor: updated swagger;
feat: helper function in errors for checking postgres error types; feat: sql query method for finding users by their email; feat: registration begin/complete with checking existing username/email; refactor: error handling in controller
This commit is contained in:
@@ -11,7 +11,7 @@ const docTemplate = `{
|
||||
"title": "{{.Title}}",
|
||||
"contact": {},
|
||||
"license": {
|
||||
"name": "GPL 3.0"
|
||||
"name": "GPL-3.0"
|
||||
},
|
||||
"version": "{{.Version}}"
|
||||
},
|
||||
@@ -139,7 +139,11 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "desc"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/auth/registrationComplete": {
|
||||
@@ -154,7 +158,25 @@ const docTemplate = `{
|
||||
"Auth"
|
||||
],
|
||||
"summary": "Confirm with code, finish creating the account",
|
||||
"responses": {}
|
||||
"parameters": [
|
||||
{
|
||||
"description": "desc",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.RegistrationCompleteRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "desc",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.RegistrationCompleteResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile": {
|
||||
@@ -305,13 +327,16 @@ const docTemplate = `{
|
||||
],
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 100
|
||||
},
|
||||
"totp": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 20,
|
||||
"minLength": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -346,6 +371,46 @@ const docTemplate = `{
|
||||
"minLength": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.RegistrationCompleteRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"username",
|
||||
"verification_code"
|
||||
],
|
||||
"properties": {
|
||||
"avatar_url": {
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
},
|
||||
"birthday": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 75
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"maxLength": 20,
|
||||
"minLength": 3
|
||||
},
|
||||
"verification_code": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.RegistrationCompleteResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access_token": {
|
||||
"type": "string"
|
||||
},
|
||||
"refresh_token": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"title": "Easywish client API",
|
||||
"contact": {},
|
||||
"license": {
|
||||
"name": "GPL 3.0"
|
||||
"name": "GPL-3.0"
|
||||
},
|
||||
"version": "1.0"
|
||||
},
|
||||
@@ -135,7 +135,11 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {}
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "desc"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/auth/registrationComplete": {
|
||||
@@ -150,7 +154,25 @@
|
||||
"Auth"
|
||||
],
|
||||
"summary": "Confirm with code, finish creating the account",
|
||||
"responses": {}
|
||||
"parameters": [
|
||||
{
|
||||
"description": "desc",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.RegistrationCompleteRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "desc",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.RegistrationCompleteResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/profile": {
|
||||
@@ -301,13 +323,16 @@
|
||||
],
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 100
|
||||
},
|
||||
"totp": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"maxLength": 20,
|
||||
"minLength": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -342,6 +367,46 @@
|
||||
"minLength": 3
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.RegistrationCompleteRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"username",
|
||||
"verification_code"
|
||||
],
|
||||
"properties": {
|
||||
"avatar_url": {
|
||||
"type": "string",
|
||||
"maxLength": 255
|
||||
},
|
||||
"birthday": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"maxLength": 75
|
||||
},
|
||||
"username": {
|
||||
"type": "string",
|
||||
"maxLength": 20,
|
||||
"minLength": 3
|
||||
},
|
||||
"verification_code": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.RegistrationCompleteResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"access_token": {
|
||||
"type": "string"
|
||||
},
|
||||
"refresh_token": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
|
||||
@@ -8,10 +8,13 @@ definitions:
|
||||
models.LoginRequest:
|
||||
properties:
|
||||
password:
|
||||
maxLength: 100
|
||||
type: string
|
||||
totp:
|
||||
type: string
|
||||
username:
|
||||
maxLength: 20
|
||||
minLength: 3
|
||||
type: string
|
||||
required:
|
||||
- password
|
||||
@@ -39,11 +42,39 @@ definitions:
|
||||
- password
|
||||
- username
|
||||
type: object
|
||||
models.RegistrationCompleteRequest:
|
||||
properties:
|
||||
avatar_url:
|
||||
maxLength: 255
|
||||
type: string
|
||||
birthday:
|
||||
type: string
|
||||
name:
|
||||
maxLength: 75
|
||||
type: string
|
||||
username:
|
||||
maxLength: 20
|
||||
minLength: 3
|
||||
type: string
|
||||
verification_code:
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- username
|
||||
- verification_code
|
||||
type: object
|
||||
models.RegistrationCompleteResponse:
|
||||
properties:
|
||||
access_token:
|
||||
type: string
|
||||
refresh_token:
|
||||
type: string
|
||||
type: object
|
||||
info:
|
||||
contact: {}
|
||||
description: Easy and feature-rich wishlist.
|
||||
license:
|
||||
name: GPL 3.0
|
||||
name: GPL-3.0
|
||||
title: Easywish client API
|
||||
version: "1.0"
|
||||
paths:
|
||||
@@ -124,7 +155,9 @@ paths:
|
||||
$ref: '#/definitions/models.RegistrationBeginRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses: {}
|
||||
responses:
|
||||
"200":
|
||||
description: desc
|
||||
summary: Register an account
|
||||
tags:
|
||||
- Auth
|
||||
@@ -132,9 +165,20 @@ paths:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: desc
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/models.RegistrationCompleteRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses: {}
|
||||
responses:
|
||||
"200":
|
||||
description: desc
|
||||
schema:
|
||||
$ref: '#/definitions/models.RegistrationCompleteResponse'
|
||||
summary: Confirm with code, finish creating the account
|
||||
tags:
|
||||
- Auth
|
||||
|
||||
Reference in New Issue
Block a user