-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathuser.go
34 lines (32 loc) · 1.09 KB
/
user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package couchdb
// User is special CouchDB document format.
// http://docs.couchdb.org/en/latest/intro/security.html#users-documents
type User struct {
Document
DerivedKey string `json:"derived_key,omitempty"`
Name string `json:"name,omitempty"`
Roles []string `json:"roles"`
Password string `json:"password,omitempty"` // plain text password when creating the user
PasswordSha string `json:"password_sha,omitempty"` // hashed password when requesting user information
PasswordScheme string `json:"password_scheme,omitempty"`
Salt string `json:"salt,omitempty"`
Type string `json:"type,omitempty"`
Iterations int `json:"iterations,omitempty"`
}
// NewUser returns new user instance.
func NewUser(name, password string, roles []string) User {
user := User{
Document: Document{
ID: "org.couchdb.user:" + name,
},
DerivedKey: "",
Name: name,
Roles: roles,
Password: password,
PasswordSha: "",
PasswordScheme: "",
Salt: "",
Type: "user",
}
return user
}