Documentation
¶
Index ¶
- func DatasetExists(db sqlutil.Queryable, datasetId string) (exists bool, err error)
- func EmailTaken(db sqlutil.Queryable, email string) (taken bool, err error)
- func PathTaken(db sqlutil.Queryable, path string) (taken bool, err error)
- func UsernameTaken(db sqlutil.Queryable, username string) (taken bool, err error)
- func ValidUrlString(rawurl string) (string, error)
- func ValidUser(db sqlutil.Queryable, u *User) (err error)
- type Key
- type User
- func AuthenticateUser(db sqlutil.Queryable, username, password string) (u *User, err error)
- func CommunityUsers(db sqlutil.Queryable, community *User, order string, limit, offset int) ([]*User, error)
- func CreateUser(db sqlutil.Transactable, username, email, name, password string, t UserType) (u *User, err error)
- func NewAccessTokenUser(token string) *User
- func NewUser(id string) *User
- func NewUserFromString(s string) *User
- func ReadUsers(db sqlutil.Queryable, userType UserType, limit, offset int) (users []*User, err error)
- func UserCommunities(db sqlutil.Queryable, user *User, order string, limit, offset int) ([]*User, error)
- func UserForPublicKey(db sqlutil.Queryable, pubKey ssh.PublicKey) (*User, error)
- func UsersSearch(db sqlutil.Queryable, query string, limit, offset int) ([]*User, error)
- func (u *User) AcceptCommunityInvite(db *sql.DB, c *User) error
- func (u *User) AccessToken() string
- func (u *User) DeclineCommunityInvite(db *sql.DB, c *User) error
- func (u *User) Delete(db sqlutil.Transactable) error
- func (u *User) Keys(db *sql.DB) ([]*Key, error)
- func (u User) MarshalJSON() ([]byte, error)
- func (u *User) Path() string
- func (u *User) Read(db sqlutil.Queryable) error
- func (u *User) ReadApiToken(db sqlutil.Queryable) error
- func (u *User) Save(db sqlutil.Transactable) error
- func (u *User) SavePassword(db sqlutil.Execable, password string) error
- func (u *User) SetCurrentKey(db sqlutil.Execable, key [32]byte) error
- func (u *User) Slug() string
- func (u *User) UnmarshalJSON(data []byte) error
- func (u *User) UnmarshalSQL(row sqlutil.Scannable) error
- type UserRequests
- func (r UserRequests) CommunityMembers(p *UsersCommunityMembersParams, res *[]*User) error
- func (r UserRequests) Create(p *UsersCreateParams, res *User) error
- func (r UserRequests) Get(p *UsersGetParams, res *User) error
- func (r UserRequests) List(p *UsersListParams, res *[]*User) error
- func (r UserRequests) Save(p *UsersSaveParams, res *User) error
- func (r UserRequests) Search(p *UsersSearchParams, res *[]*User) error
- func (r UserRequests) UserCommunities(p *UsersCommunitiesParams, res *[]*User) error
- type UserType
- type UsersCommunitiesParams
- type UsersCommunityMembersParams
- type UsersCreateParams
- type UsersGetParams
- type UsersListParams
- type UsersSaveParams
- type UsersSearchParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatasetExists ¶
check if dataset exists in a given dataset
func EmailTaken ¶
check if an email is taken
func UsernameTaken ¶
check if a username is taken, also checking against organization namespace to avoid collisions TODO - refactor to only return an error if taken
Types ¶
type Key ¶
type Key struct { Type string Sha256 [32]byte Created int64 LastSeen int64 Name string User *User Public []byte // contains filtered or unexported fields }
func (*Key) MarshalJSON ¶
type User ¶
type User struct { // version 4 uuid Id string `json:"id" sql:"id"` // Created timestamp rounded to seconds in UTC Created int64 `json:"created" sql:"created"` // Updated timestamp rounded to seconds in UTC Updated int64 `json:"updated" sql:"updated"` // handle for the user. min 1 character, max 80. composed of [_,-,a-z,A-Z,1-9] Username string `json:"username" sql:"username"` // specifies weather this is a user or an organization Type UserType `json:"type" sql:"type"` // user's email address Email string `json:"email,omitempty" sql:"email"` // user name field. could be first[space]last, but not strictly enforced Name string `json:"name" sql:"name"` // user-filled description of self Description string `json:"description" sql:"description"` // url this user wants the world to click HomeUrl string `json:"home_url" sql:"home_url"` // color this user likes to use as their theme color Color string `json:"color"` // url for their thumbnail ThumbUrl string `json:"thumbUrl"` // profile photo url ProfileUrl string `json:"profileUrl"` // header image url PosterUrl string `json:"posterUrl"` // sh256 multihash of public key that this user is currently using for signatures CurrentKey string `json:"currentKey"` // often users get auto-generated based on IP for rate lmiting & stuff // this flag tracks that. // TODO - for this to be useful it'll need to be Exported Anonymous bool `json:",omitempty"` // contains filtered or unexported fields }
le user
func AuthenticateUser ¶
attempt to authenticate a user, for now only returns either nil or errors.ErrAccessDenied TODO - should also return 500-type errors when service is down
func CommunityUsers ¶
func CreateUser ¶
func CreateUser(db sqlutil.Transactable, username, email, name, password string, t UserType) (u *User, err error)
create a new user from a given username, email, first, last, and password This is just a wrapper to turn args into a user & then call save, returning the user & error, But should be used to create users in case we want to inject analytics or whatever.
func NewAccessTokenUser ¶
func NewUserFromString ¶
NewUserFromFromString attempts to place the provided string in the right field. id if it's a valid uuid, username if it's a valid username, or throwing away the string if none of the above apply
func ReadUsers ¶
func ReadUsers(db sqlutil.Queryable, userType UserType, limit, offset int) (users []*User, err error)
ReadUsers reads a page of users
func UserCommunities ¶
func UserForPublicKey ¶
UserForPublicKey finds a user based on a provided public key
func UsersSearch ¶
func (*User) AcceptCommunityInvite ¶
func (*User) AccessToken ¶
func (*User) DeclineCommunityInvite ¶
func (*User) Delete ¶
func (u *User) Delete(db sqlutil.Transactable) error
"delete" a user TODO - deleting an account will require lots of cleanup:
- Close any open change requests
- Resolve any datasets that the user is the sole administrator of
func (User) MarshalJSON ¶
MarshalJSON is a custom JSON implementation that delivers a uuid-string if the model is blank, or an object otherwise
func (*User) Save ¶
func (u *User) Save(db sqlutil.Transactable) error
save a user model, creating it if it doesn't exist updating the user model if it doesn't
func (*User) SavePassword ¶
SavePassword sets a user's password
func (*User) UnmarshalJSON ¶
UnmarshalJSON is a custom json implementation that supports a few different inputs if a string is provided, it first checks if the string is a valid uuid, if so it'll set the string to the id. If not it'll check to see if the passed-in string is a valid username and if so it'll set the user's username accordingly. if an object is passed in we skip straight to regular json unmarshalling
type UserRequests ¶
type UserRequests struct {
Store sqlutil.Transactable
}
Requests holds all types of requests for users
func (UserRequests) CommunityMembers ¶
func (r UserRequests) CommunityMembers(p *UsersCommunityMembersParams, res *[]*User) error
func (UserRequests) Create ¶
func (r UserRequests) Create(p *UsersCreateParams, res *User) error
func (UserRequests) Get ¶
func (r UserRequests) Get(p *UsersGetParams, res *User) error
func (UserRequests) List ¶
func (r UserRequests) List(p *UsersListParams, res *[]*User) error
func (UserRequests) Save ¶
func (r UserRequests) Save(p *UsersSaveParams, res *User) error
func (UserRequests) Search ¶
func (r UserRequests) Search(p *UsersSearchParams, res *[]*User) error
func (UserRequests) UserCommunities ¶
func (r UserRequests) UserCommunities(p *UsersCommunitiesParams, res *[]*User) error
type UsersCommunitiesParams ¶
type UsersCreateParams ¶
type UsersGetParams ¶
type UsersListParams ¶
type UsersListParams struct { // the user performing the request User *User `required:"true"` Type UserType // users requests embeds pagination info Limit int Offset int }
UsersRequest defines a request for users, outlining all possible options for scoping & shaping the desired response