Merge pull request #6010 from influxdata/dn-fix-create-user
make CREATE USER default to IF NOT EXISTSpull/6001/head
commit
ad8605d258
|
@ -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]
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue