services

package
v0.0.0-...-4471eec Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthenticationFailedUserNotFound     = errors.New("Authentication failed. User does not exists")
	ErrAuthenticationFailedValidationError  = errors.New("Authentication failed. Validation Error")
	ErrAuthenticationFailedPasswordMismatch = errors.New("Authentication failed. Password does not match")
)

Errors

View Source
var (
	ErrInvalidAccessToken  = errors.New("Invalid Access Token")
	ErrInvalidRefreshToken = errors.New("Invalid Refresh Token")
)

Errors

View Source
var (
	// ErrNotAnOrganizationOwner is raised when a user that is not an organization member tries to perform an action
	ErrNotAnOrganizationOwner = errors.New("Authenticated user is not an organization owner")

	// ErrCannotChangeMembershipVisibility is raised when a user tries to change membership visibility of another user
	ErrCannotChangeMembershipVisibility = errors.New("Cannot change other member's membership visibility")
)
View Source
var (
	ErrNamespaceAlreadyExists = errors.New("Namespace already exists")
	ErrNamespaceDuplicateKey  = errors.New("Namespace duplicate key error")
	ErrUserDuplicateKey       = errors.New("Duplicate Key for Organization")
)

Errors

View Source
var Auth = &authService{signingKey, refreshKey}

Auth is the singleton instance for the Auth service

View Source
var (
	// ErrOrganizationDuplicateKey is raised when there is an error saving an organization to the database because of unique index conflict
	ErrOrganizationDuplicateKey = errors.New("Duplicate Key for Organization")
)

Functions

func CreateConversation

func CreateConversation(namespaceID int, json bindings.CreateConversation) (*schema.Conversation, error)

CreateConversation creates a new conversation in the namespace

func CreateOrganization

func CreateOrganization(newOrg bindings.CreateOrganization, currentUser *schema.User) (*schema.Organization, error)

CreateOrganization creates a new organization and makes the current user the owner of the new organization

func ListAllUsers

func ListAllUsers() ([]*schema.User, error)

ListAllUsers returns a list of all users

func ListPublicConversations

func ListPublicConversations(options interface{}) ([]*schema.Conversation, error)

ListPublicConversations returns all the conversations

func RegisterNewUser

func RegisterNewUser(newUser bindings.RegisterNewUser) (*schema.User, error)

RegisterNewUser creates a new user account

Types

type AccountService

type AccountService struct {
	User *schema.User
}

AccountService is a service that allows actions on the authenticated user

func NewAccountService

func NewAccountService(userParam interface{}) (*AccountService, error)

NewAccountService creates a new service for authenticated user

func (*AccountService) AddEmailAddress

func (s *AccountService) AddEmailAddress(form bindings.UpdateEmail) error

AddEmailAddress adds a new email address to the user's account

func (*AccountService) ChangePassword

func (s *AccountService) ChangePassword(form bindings.ChangePassword) (bool, error)

ChangePassword updates the authenticated user's password

func (*AccountService) ChangeUsername

func (s *AccountService) ChangeUsername(form bindings.ChangeUsername) (bool, error)

ChangeUsername updates the authenticated users' username

func (*AccountService) EditMyMembership

func (s *AccountService) EditMyMembership(orgID interface{}, json bindings.EditMyMembership) (*schema.Member, error)

EditMyMembership edits the membership for an organization that the authenticated user is a member of

func (*AccountService) GetMyMembership

func (s *AccountService) GetMyMembership(orgID interface{}) (*schema.Member, error)

GetMyMembership returns the membership for an organization that the authenticated user is a member of

func (*AccountService) ListMyMemberships

func (s *AccountService) ListMyMemberships() ([]*schema.Member, error)

ListMyMemberships returns all active memberships for the authenticated user

func (*AccountService) ListMyOrganizations

func (s *AccountService) ListMyOrganizations() ([]*schema.Organization, error)

ListMyOrganizations returns all active organizations for the authenticated user

func (*AccountService) RemoveEmailAddress

func (s *AccountService) RemoveEmailAddress(form bindings.UpdateEmail) error

RemoveEmailAddress removes an email existing email address from the user's account

type ConversationService

type ConversationService struct {
	Conversation *schema.Conversation
	CurrentUser  *schema.User
}

ConversationService is responsible for all related actions and properties for a single Conversation

func NewConversationService

func NewConversationService(conversationParam interface{}, currentUser *schema.User) (*ConversationService, error)

NewConversationService creates a service that wraps an organization and the current user making API requests

func (*ConversationService) GetConversation

func (s *ConversationService) GetConversation() (*schema.Conversation, error)

GetConversation retrieves the conversation

type OrganizationMembershipService

type OrganizationMembershipService struct {
	Org         *schema.Organization
	CurrentUser *schema.User
}

OrganizationMembershipService is a service that allows actions on an organization's membership

func (*OrganizationMembershipService) AddOrUpdateMembership

func (s *OrganizationMembershipService) AddOrUpdateMembership(user *schema.User, form bindings.AddUpdateMembership) (*schema.Member, error)

AddOrUpdateMembership adds or updates the membership for the user in the organization

func (*OrganizationMembershipService) CheckMembership

func (s *OrganizationMembershipService) CheckMembership(user *schema.User) (bool, error)

CheckMembership verifies if the provided user has a membership in the organization

func (*OrganizationMembershipService) CheckMembershipByUsername

func (s *OrganizationMembershipService) CheckMembershipByUsername(username string) (bool, error)

CheckMembershipByUsername verifies if the provided username has a membership in the organization

func (*OrganizationMembershipService) CheckPublicMembership

func (s *OrganizationMembershipService) CheckPublicMembership(user *schema.User) (bool, error)

CheckPublicMembership verifies if the provided user has a public membership in the organization

func (*OrganizationMembershipService) ConcealMembership

func (s *OrganizationMembershipService) ConcealMembership(user *schema.User) error

ConcealMembership conceals the authenticated user membership

func (*OrganizationMembershipService) GetCurrentMembership

func (s *OrganizationMembershipService) GetCurrentMembership() (*schema.Member, error)

GetCurrentMembership returns the organization membership for the authenticated user

func (*OrganizationMembershipService) GetMembers

func (s *OrganizationMembershipService) GetMembers() ([]*schema.Member, error)

GetMembers returns the list of all members of the organization

func (*OrganizationMembershipService) GetMembership

func (s *OrganizationMembershipService) GetMembership(user *schema.User) (*schema.Member, error)

GetMembership returns the Member record for the provided user

func (*OrganizationMembershipService) GetPublicMembers

func (s *OrganizationMembershipService) GetPublicMembers() ([]*schema.Member, error)

GetPublicMembers returns the organization public member

func (*OrganizationMembershipService) PublicizeMembership

func (s *OrganizationMembershipService) PublicizeMembership(user *schema.User) error

PublicizeMembership publishes the authenticated user membership

func (*OrganizationMembershipService) RemoveMembership

func (s *OrganizationMembershipService) RemoveMembership(user *schema.User) error

RemoveMembership removes the user from the organization

type OrganizationService

type OrganizationService struct {
	Org         *schema.Organization
	CurrentUser *schema.User

	*OrganizationMembershipService
}

OrganizationService is a service that allows operations on an organization. It wraps an organization and the current user making API requests. It enforces access-controls based on the current user to make sure it has permissions to perform the desired operations

func NewOrganizationService

func NewOrganizationService(orgParam interface{}, currentUser *schema.User) (*OrganizationService, error)

NewOrganizationService creates a service that wraps an organization and the current user making API requests

func (*OrganizationService) UpdateOrganization

func (s *OrganizationService) UpdateOrganization(newOrg bindings.UpdateOrganization) (*schema.Organization, error)

UpdateOrganization modifies the organization wrapped by the service

type TokenFields

type TokenFields struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token"`
	ExpiresAt    time.Time `json:"expires_at"`
}

TokenFields represents the security tokens that gets generated and sent as API response

type UserService

type UserService struct {
	User *schema.User
}

UserService is a service that allows actions on specific user

func NewUserService

func NewUserService(userParam interface{}) (*UserService, error)

NewUserService creates a new service for authenticated user

func (*UserService) ListMemberships

func (s *UserService) ListMemberships() ([]*schema.Member, error)

ListMemberships returns all public memberships for the user

func (*UserService) ListOrganizations

func (s *UserService) ListOrganizations() ([]*schema.Organization, error)

ListOrganizations returns all the active publicized organizations for the user

Jump to

Keyboard shortcuts

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