Skip to content

Commit

Permalink
Merge pull request #207 from getAlby/refactor/username-login
Browse files Browse the repository at this point in the history
replace username by login
  • Loading branch information
kiwiidb authored Jul 8, 2022
2 parents 5e31a28 + 96c6a4f commit 4498312
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions controllers/auth.ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func (controller *AuthController) Auth(c echo.Context) error {
if err != nil {
return err
}
username := params.Get("username")
login := params.Get("login")
password := params.Get("password")
if username != "" && password != "" {
body.Login = username
if login != "" && password != "" {
body.Login = login
body.Password = password
}
}
Expand Down
10 changes: 5 additions & 5 deletions controllers_v2/create.ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ func NewCreateUserController(svc *service.LndhubService) *CreateUserController {
}

type CreateUserResponseBody struct {
Username string `json:"username"`
Login string `json:"login"`
Password string `json:"password"`
}
type CreateUserRequestBody struct {
Username string `json:"username"`
Login string `json:"login"`
Password string `json:"password"`
}

// CreateUser godoc
// @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
// @Produce json
// @Tags Account
Expand All @@ -45,14 +45,14 @@ func (controller *CreateUserController) CreateUser(c echo.Context) error {
c.Logger().Errorf("Failed to load create user request body: %v", err)
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 {
c.Logger().Errorf("Failed to create user: %v", err)
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)
}

var ResponseBody CreateUserResponseBody
ResponseBody.Username = user.Login
ResponseBody.Login = user.Login
ResponseBody.Password = user.Password

return c.JSON(http.StatusOK, &ResponseBody)
Expand Down
10 changes: 5 additions & 5 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ const docTemplate = `{
},
"/v2/users": {
"post": {
"description": "Create a new account with a username and password",
"description": "Create a new account with a login and password",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -532,21 +532,21 @@ const docTemplate = `{
"v2controllers.CreateUserRequestBody": {
"type": "object",
"properties": {
"password": {
"login": {
"type": "string"
},
"username": {
"password": {
"type": "string"
}
}
},
"v2controllers.CreateUserResponseBody": {
"type": "object",
"properties": {
"password": {
"login": {
"type": "string"
},
"username": {
"password": {
"type": "string"
}
}
Expand Down
10 changes: 5 additions & 5 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
},
"/v2/users": {
"post": {
"description": "Create a new account with a username and password",
"description": "Create a new account with a login and password",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -528,21 +528,21 @@
"v2controllers.CreateUserRequestBody": {
"type": "object",
"properties": {
"password": {
"login": {
"type": "string"
},
"username": {
"password": {
"type": "string"
}
}
},
"v2controllers.CreateUserResponseBody": {
"type": "object",
"properties": {
"password": {
"login": {
"type": "string"
},
"username": {
"password": {
"type": "string"
}
}
Expand Down
10 changes: 5 additions & 5 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ definitions:
type: object
v2controllers.CreateUserRequestBody:
properties:
password:
login:
type: string
username:
password:
type: string
type: object
v2controllers.CreateUserResponseBody:
properties:
password:
login:
type: string
username:
password:
type: string
type: object
v2controllers.Invoice:
Expand Down Expand Up @@ -422,7 +422,7 @@ paths:
post:
consumes:
- application/json
description: Create a new account with a username and password
description: Create a new account with a login and password
parameters:
- description: Create User
in: body
Expand Down

0 comments on commit 4498312

Please sign in to comment.