Merge pull request #6010 from influxdata/dn-fix-create-user

make CREATE USER default to IF NOT EXISTS
pull/6001/head
David Norton 2016-03-14 18:55:05 -04:00
commit ad8605d258
2 changed files with 9 additions and 0 deletions

View File

@ -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]

View File

@ -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 {