user

package
v0.0.0-...-d3d53d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2016 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitModels

func InitModels()

InitModels initialize models in mongo, if required.

func ValidateUsername

func ValidateUsername(username string) (valid bool)

Types

type Address

type Address struct {
	City       string `json:"city" validate:"max=30"`
	Country    string `json:"country" validate:"max=40"`
	Nr         string `json:"nr" validate:"max=10"`
	Other      string `json:"other" validate:"max=30"`
	Postalcode string `json:"postalcode" validate:"max=20"`
	Street     string `json:"street" validate:"max=50"`
	Label      string `json:"label"`
}

type Authorization

type Authorization struct {
	Addresses      []AuthorizationMap           `json:"addresses,omitempty"`
	BankAccounts   []AuthorizationMap           `json:"bankaccounts,omitempty"`
	DigitalWallet  []DigitalWalletAuthorization `json:"digitalwallet,omitempty"`
	EmailAddresses []AuthorizationMap           `json:"emailaddresses,omitempty"`
	Facebook       bool                         `json:"facebook,omitempty"`
	Github         bool                         `json:"github,omitempty"`
	GrantedTo      string                       `json:"grantedTo"`
	Organizations  []string                     `json:"organizations"`
	Phonenumbers   []AuthorizationMap           `json:"phonenumbers,omitempty"`
	PublicKeys     []AuthorizationMap           `json:"publicKeys,omitempty"`
	Username       string                       `json:"username"`
	Name           bool                         `json:"name"`
}

Authorization defines what userinformation is authorized to be seen by an organization For an explanation about scopes and scopemapping, see https://github.com/itsyouonline/identityserver/blob/master/docs/oauth2/scopes.md

func (Authorization) FilterAuthorizedScopes

func (authorization Authorization) FilterAuthorizedScopes(requestedscopes []string) (authorizedScopes []string)

FilterAuthorizedScopes filters the requested scopes to the ones this Authorization covers

type AuthorizationMap

type AuthorizationMap struct {
	RequestedLabel string `json:"requestedlabel"`
	RealLabel      string `json:"reallabel"`
}

type BankAccount

type BankAccount struct {
	Bic     string `json:"bic"`
	Country string `json:"country"`
	Iban    string `json:"iban"`
	Label   string `json:"label"`
}

type ContractSigningRequest

type ContractSigningRequest struct {
	ContractId string `json:"contractId"`
	Party      string `json:"party"`
}

type DigitalAssetAddress

type DigitalAssetAddress struct {
	CurrencySymbol string      `json:"currencysymbol"`
	Address        string      `json:"address"`
	Label          string      `json:"label"`
	Expire         db.DateTime `json:"expire"`
	Noexpiration   bool        `json:"noexpiration"`
}

type DigitalWalletAuthorization

type DigitalWalletAuthorization struct {
	RequestedLabel string `json:"requestedlabel"`
	RealLabel      string `json:"reallabel"`
	Currency       string `json:"currency"`
}

type EmailAddress

type EmailAddress struct {
	EmailAddress string `json:"emailaddress"`
	Label        string `json:"label"`
}

type FBInfo

type FBInfo struct {
	Id      string
	Picture FacebookDataPic
	Link    string
	Name    string
}

type FacebookAccount

type FacebookAccount struct {
	Id      string `json:"id"`
	Picture string `json:"picture"`
	Link    string `json:"link"`
	Name    string `json:"name"`
}

type FacebookDataPic

type FacebookDataPic struct {
	Data FacebookPic
}

type FacebookError

type FacebookError struct {
	Message    string
	Type       string
	Code       int
	Fbtrace_id string
}

type FacebookPic

type FacebookPic struct {
	Is_silhouette bool
	Url           string
}

type GithubAccount

type GithubAccount struct {
	Login      string `json:"login"`
	Id         int    `json:"id"`
	Avatar_url string `json:"avatar_url"`
	Html_url   string `json:"html_url"`
	Name       string `json:"name"`
}

type JoinOrganizationRequest

type JoinOrganizationRequest struct {
	Organization string   `json:"organization"`
	Role         []string `json:"role"`
	User         string   `json:"user"`
}

type Label

type Label string

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is used to store users

func NewManager

func NewManager(r *http.Request) *Manager

NewManager creates and initializes a new Manager

func (*Manager) Delete

func (m *Manager) Delete(u *User) error

Delete a user.

func (*Manager) DeleteAllAuthorizations

func (m *Manager) DeleteAllAuthorizations(organization string) (err error)

DeleteAllAuthorizations removes all authorizations from an organization

func (*Manager) DeleteAuthorization

func (m *Manager) DeleteAuthorization(username, organization string) (err error)

DeleteAuthorization removes an authorization

func (*Manager) DeleteFacebookAccount

func (m *Manager) DeleteFacebookAccount(username string) (err error)

func (*Manager) DeleteGithubAccount

func (m *Manager) DeleteGithubAccount(username string) (err error)

func (*Manager) Exists

func (m *Manager) Exists(username string) (bool, error)

Exists checks if a user with this username already exists.

func (*Manager) Get

func (m *Manager) Get(id string) (*User, error)

Get user by ID.

func (*Manager) GetAuthorization

func (m *Manager) GetAuthorization(username, organization string) (authorization *Authorization, err error)

GetAuthorization returns the authorization for a specific organization, nil if no such auhorization exists

func (*Manager) GetAuthorizationsByUser

func (m *Manager) GetAuthorizationsByUser(username string) (authorizations []Authorization, err error)

GetAuthorizationsByUser returns all authorizations for a specific user

func (*Manager) GetByName

func (m *Manager) GetByName(username string) (*User, error)

GetByName gets a user by it's username.

func (*Manager) GetPendingRegistrationsCount

func (m *Manager) GetPendingRegistrationsCount() (int, error)

func (*Manager) RemoveAddress

func (m *Manager) RemoveAddress(username, label string) error

RemoveAddress remove address associated with label

func (*Manager) RemoveBank

func (m *Manager) RemoveBank(u *User, label string) error

RemoveBank remove bank associated with label

func (*Manager) RemoveEmail

func (m *Manager) RemoveEmail(username string, label string) error

RemoveEmail remove email associated with label

func (*Manager) RemoveExpireDate

func (m *Manager) RemoveExpireDate(username string) (err error)

func (*Manager) RemovePhone

func (m *Manager) RemovePhone(username string, label string) error

RemovePhone remove phone associated with label

func (*Manager) RemovePublicKey

func (m *Manager) RemovePublicKey(username string, label string) error

RemovePublicKey remove public key associated with label

func (*Manager) RemoveVirtualCurrency

func (m *Manager) RemoveVirtualCurrency(username string, label string) error

RemoveVirtualCurrency remove phone associated with label

func (*Manager) Save

func (m *Manager) Save(u *User) error

Save a user.

func (*Manager) SaveAddress

func (m *Manager) SaveAddress(username string, address Address) error

SaveAddress save or update address

func (*Manager) SaveBank

func (m *Manager) SaveBank(u *User, bank BankAccount) error

SaveBank save or update bank account

func (*Manager) SaveEmail

func (m *Manager) SaveEmail(username string, email EmailAddress) error

SaveEmail save or update email along with its label

func (*Manager) SavePhone

func (m *Manager) SavePhone(username string, phonenumber Phonenumber) error

SavePhone save or update phone along with its label

func (*Manager) SavePublicKey

func (m *Manager) SavePublicKey(username string, key PublicKey) error

SavePublicKey save or update public key along with its label

func (*Manager) SaveVirtualCurrency

func (m *Manager) SaveVirtualCurrency(username string, currency DigitalAssetAddress) error

SaveVirtualCurrency save or update virtualcurrency along with its label

func (*Manager) UpdateAuthorization

func (m *Manager) UpdateAuthorization(authorization *Authorization) (err error)

UpdateAuthorization inserts or updates an authorization

func (*Manager) UpdateFacebookAccount

func (m *Manager) UpdateFacebookAccount(username string, facebookaccount FacebookAccount) (err error)

func (*Manager) UpdateGithubAccount

func (m *Manager) UpdateGithubAccount(username string, githubaccount GithubAccount) (err error)

func (*Manager) UpdateName

func (m *Manager) UpdateName(username string, firstname string, lastname string) (err error)

type Phonenumber

type Phonenumber struct {
	Label       string `json:"label"`
	Phonenumber string `json:"phonenumber"`
}

Phonenumber defines a phonenumber and has functions for validation

func (Phonenumber) IsValid

func (phonenumber Phonenumber) IsValid() (valid bool)

IsValid checks if a phonenumber is in a valid format

type PublicKey

type PublicKey struct {
	PublicKey string `json:"publickey"`
	Label     string `json:"label"`
}

type User

type User struct {
	ID             bson.ObjectId         `json:"-" bson:"_id,omitempty"`
	Addresses      []Address             `json:"addresses"`
	BankAccounts   []BankAccount         `json:"bankaccounts"`
	EmailAddresses []EmailAddress        `json:"emailaddresses"`
	Expire         db.DateTime           `json:"expire" bson:"expire,omitempty"`
	Facebook       FacebookAccount       `json:"facebook"`
	Github         GithubAccount         `json:"github"`
	Phonenumbers   []Phonenumber         `json:"phonenumbers"`
	DigitalWallet  []DigitalAssetAddress `json:"digitalwallet"`
	PublicKeys     []PublicKey           `json:"publicKeys"`
	Username       string                `json:"username"`
	Firstname      string                `json:"firstname"`
	Lastname       string                `json:"lastname"`
}

func (*User) GetAddressByLabel

func (u *User) GetAddressByLabel(label string) (address Address, err error)

func (*User) GetBankAccountByLabel

func (u *User) GetBankAccountByLabel(label string) (bankaccount BankAccount, err error)

func (*User) GetDigitalAssetAddressByLabel

func (u *User) GetDigitalAssetAddressByLabel(label string) (walletAddress DigitalAssetAddress, err error)

func (*User) GetEmailAddressByLabel

func (u *User) GetEmailAddressByLabel(label string) (email EmailAddress, err error)

func (*User) GetPhonenumberByLabel

func (u *User) GetPhonenumberByLabel(label string) (phonenumber Phonenumber, err error)

func (*User) GetPublicKeyByLabel

func (u *User) GetPublicKeyByLabel(label string) (publicKey PublicKey, err error)

GetPublicKeyByLabel Gets the public key associated with this label

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL