mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-23 23:55:02 +01:00
replace username by login
This commit is contained in:
@@ -58,10 +58,10 @@ func (controller *AuthController) Auth(c echo.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
username := params.Get("username")
|
login := params.Get("login")
|
||||||
password := params.Get("password")
|
password := params.Get("password")
|
||||||
if username != "" && password != "" {
|
if login != "" && password != "" {
|
||||||
body.Login = username
|
body.Login = login
|
||||||
body.Password = password
|
body.Password = password
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ func NewCreateUserController(svc *service.LndhubService) *CreateUserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CreateUserResponseBody struct {
|
type CreateUserResponseBody struct {
|
||||||
Username string `json:"username"`
|
Login string `json:"login"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
type CreateUserRequestBody struct {
|
type CreateUserRequestBody struct {
|
||||||
Username string `json:"username"`
|
Login string `json:"login"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateUser godoc
|
// CreateUser godoc
|
||||||
// @Summary Create an account
|
// @Summary Create an account
|
||||||
// @Description Create a new account with a username and password
|
// @Description Create a new account with a login and password
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Tags Account
|
// @Tags Account
|
||||||
@@ -45,14 +45,14 @@ func (controller *CreateUserController) CreateUser(c echo.Context) error {
|
|||||||
c.Logger().Errorf("Failed to load create user request body: %v", err)
|
c.Logger().Errorf("Failed to load create user request body: %v", err)
|
||||||
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)
|
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)
|
||||||
}
|
}
|
||||||
user, err := controller.svc.CreateUser(c.Request().Context(), body.Username, body.Password)
|
user, err := controller.svc.CreateUser(c.Request().Context(), body.Login, body.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Logger().Errorf("Failed to create user: %v", err)
|
c.Logger().Errorf("Failed to create user: %v", err)
|
||||||
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)
|
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)
|
||||||
}
|
}
|
||||||
|
|
||||||
var ResponseBody CreateUserResponseBody
|
var ResponseBody CreateUserResponseBody
|
||||||
ResponseBody.Username = user.Login
|
ResponseBody.Login = user.Login
|
||||||
ResponseBody.Password = user.Password
|
ResponseBody.Password = user.Password
|
||||||
|
|
||||||
return c.JSON(http.StatusOK, &ResponseBody)
|
return c.JSON(http.StatusOK, &ResponseBody)
|
||||||
|
|||||||
10
docs/docs.go
10
docs/docs.go
@@ -399,7 +399,7 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"/v2/users": {
|
"/v2/users": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Create a new account with a username and password",
|
"description": "Create a new account with a login and password",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -532,10 +532,10 @@ const docTemplate = `{
|
|||||||
"v2controllers.CreateUserRequestBody": {
|
"v2controllers.CreateUserRequestBody": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"password": {
|
"login": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"username": {
|
"password": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -543,10 +543,10 @@ const docTemplate = `{
|
|||||||
"v2controllers.CreateUserResponseBody": {
|
"v2controllers.CreateUserResponseBody": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"password": {
|
"login": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"username": {
|
"password": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,7 +395,7 @@
|
|||||||
},
|
},
|
||||||
"/v2/users": {
|
"/v2/users": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Create a new account with a username and password",
|
"description": "Create a new account with a login and password",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
@@ -528,10 +528,10 @@
|
|||||||
"v2controllers.CreateUserRequestBody": {
|
"v2controllers.CreateUserRequestBody": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"password": {
|
"login": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"username": {
|
"password": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -539,10 +539,10 @@
|
|||||||
"v2controllers.CreateUserResponseBody": {
|
"v2controllers.CreateUserResponseBody": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"password": {
|
"login": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"username": {
|
"password": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,16 +57,16 @@ definitions:
|
|||||||
type: object
|
type: object
|
||||||
v2controllers.CreateUserRequestBody:
|
v2controllers.CreateUserRequestBody:
|
||||||
properties:
|
properties:
|
||||||
password:
|
login:
|
||||||
type: string
|
type: string
|
||||||
username:
|
password:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
v2controllers.CreateUserResponseBody:
|
v2controllers.CreateUserResponseBody:
|
||||||
properties:
|
properties:
|
||||||
password:
|
login:
|
||||||
type: string
|
type: string
|
||||||
username:
|
password:
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
v2controllers.Invoice:
|
v2controllers.Invoice:
|
||||||
@@ -422,7 +422,7 @@ paths:
|
|||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
description: Create a new account with a username and password
|
description: Create a new account with a login and password
|
||||||
parameters:
|
parameters:
|
||||||
- description: Create User
|
- description: Create User
|
||||||
in: body
|
in: body
|
||||||
|
|||||||
Reference in New Issue
Block a user