Skip to content

Commit

Permalink
1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ilzheev committed Aug 19, 2019
1 parent 9d9d52e commit 6c619f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type ViewData struct {
}

const (
Version = "1.1.1"
Version = "1.1.2"
DefaultPaginationStart = 0
DefaultPaginationLimit = 30
DefaultSort = "desc"
Expand Down Expand Up @@ -163,7 +163,7 @@ func NewAPI(conf *config.Config, s service.Service, configFile string) *API {
adminGroup.DELETE("/users", api.adminDeleteUser)
adminGroup.GET("/users/:id", api.adminGetUser)
adminGroup.PUT("/users/:id", api.adminUpdateUser)
adminGroup.POST("/users/rotate", api.adminRotateUserToken)
adminGroup.GET("/users/:id/rotate", api.adminRotateUserToken)
adminGroup.GET("/logout", api.adminLogout)
adminGroup.GET("/settings", api.adminGetSettings)
adminGroup.POST("/settings", api.adminUpdateSettings)
Expand All @@ -176,7 +176,7 @@ func NewAPI(conf *config.Config, s service.Service, configFile string) *API {

// Documentation
url := echoSwagger.URL("swagger.json")
api.HTTP.Static("/docs/swagger.json", "./docs/swagger.json")
api.HTTP.File("/docs/swagger.json", "docs/swagger.json")
api.HTTP.GET("/docs/*", echoSwagger.EchoWrapHandler(url))

// Chains
Expand Down Expand Up @@ -428,20 +428,20 @@ func (api *API) adminUpdateUser(c echo.Context) error {

func (api *API) adminRotateUserToken(c echo.Context) error {

req := &model.User{}

// bind input data
if err := c.Bind(req); err != nil {
return api.ErrorResponse(errors.New(errors.BindDataError, err), c)
userID, err := strconv.Atoi(c.Param("id"))
if err != nil {
return api.ErrorResponse(errors.New(errors.ValidationError, err), c)
}

req.AccessToken = req.GenerateAccessToken(AccessTokenLength)
user := api.service.GetUser(&model.User{ID: userID})

user.AccessToken = user.GenerateAccessToken(AccessTokenLength)

if err := api.service.UpdateUser(req); err != nil {
if err := api.service.UpdateUser(user); err != nil {
return api.ErrorResponse(errors.New(errors.ServiceError, err), c)
}

return api.SuccessResponse(req, c)
return api.SuccessResponse(user, c)

}

Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/admin/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const Users = () => {

const rotateToken = user => {
axios
.post('/admin/users/rotate', { id: user.id })
.get('/admin/users/' + user.id + '/rotate')
.then(function(response) {
const array = [...users];
const index = array.findIndex(v => v.id === user.id);
Expand Down Expand Up @@ -245,7 +245,7 @@ const Users = () => {
cancelText="No"
>
<a href="javascript:;">
<Icon type="switcher" theme="twoTone" />
<Icon type="interaction" theme="twoTone" />
 Rotate token
</a>
</Popconfirm>
Expand Down

0 comments on commit 6c619f2

Please sign in to comment.