Skip to content

Commit

Permalink
Merge pull request #6010 from influxdata/dn-fix-create-user
Browse files Browse the repository at this point in the history
make CREATE USER default to IF NOT EXISTS
  • Loading branch information
dgnorton committed Mar 14, 2016
2 parents ba6a95e + 96327f3 commit ad8605d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
- [#4688](https://github.com/influxdata/influxdb/issues/4688): admin UI doesn't display results for some SHOW queries
- [#6006](https://github.com/influxdata/influxdb/pull/6006): Fix deadlock while running backups
- [#5965](https://github.com/influxdata/influxdb/issues/5965): InfluxDB panic crashes while parsing "-" as Float
- [#5835](https://github.com/influxdata/influxdb/issues/5835): Make CREATE USER default to IF NOT EXISTS

## v0.10.2 [2016-03-03]

Expand Down
8 changes: 8 additions & 0 deletions services/meta/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,14 @@ func (c *Client) CreateUser(name, password string, admin bool) (*UserInfo, error

data := c.cacheData.Clone()

// See if the user already exists.
if u := data.User(name); u != nil {
if err := bcrypt.CompareHashAndPassword([]byte(u.Hash), []byte(password)); err != nil || u.Admin != admin {
return nil, ErrUserExists
}
return u, nil
}

// Hash the password before serializing it.
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcryptCost)
if err != nil {
Expand Down

0 comments on commit ad8605d

Please sign in to comment.