Beispiel #1
0
const (
	PW_SALT_BYTES = 32
)

var (
	userHasIdError          = errors.New("Cannot create new user, key must be nil")
	userHasNoIdError        = errors.New("Cannot create new user, key must be defined")
	EmailAlreadyExistsError = errors.New("Cannot create user, email already in use")
	UserNotFoundError       = errors.New("User does not exist in datastore")
	invalidSessionError     = errors.New("Invalid user session")
	passwordCanNotBeEmpty   = errors.New("Can not set update password when password is blank")
)

var (
	userCollectionParentKey = AppEngineHelper.CollectionParentKeyGetFnGenerator(USER_KIND, USER_PARENT_STRING_ID, 0)
	userIntIDToKeyInt64     = AppEngineHelper.IntIDToKeyInt64(USER_KIND, userCollectionParentKey)
)

type UserDTO struct {
	Key                string    `json:"key",datastore:"-"`
	Email              string    `json:"email"`
	Password           string    `json:"password,omitempty",datastore:",noindex"`
	PasswordHash       []byte    `json:"-",datastore:",noindex"`
	PasswordSalt       []byte    `json:"-",datastore:",noindex"`
	NavitasId          string    `json:"navitasId"`
	CreatedDate        time.Time `json:"createdDate"`
	CurrentSessionUUID string    `json:"currentSessionKey"`
	IsAdmin            bool      `json:"isAdmin,omitempty"`
}

func (user *UserDTO) hasKey() bool {
	"time"

	"appengine"
	"appengine/datastore"

	"AppEngineHelper"
)

const (
	TXN_KIND             = "txn"
	TXN_PARENT_STRING_ID = "default_txn"
)

var (
	txnCollectionParentKey = AppEngineHelper.CollectionParentKeyGetFnGenerator(TXN_KIND, TXN_PARENT_STRING_ID, 0)
	txnIntIDToKeyInt64     = AppEngineHelper.IntIDToKeyInt64(TXN_KIND, txnCollectionParentKey)
)

func NewTransactionMsgDTOFromIpn(ipnMessage string) *TransactionMsgDTO {
	t := TransactionMsgDTO{
		key:   nil,
		dsDto: *new(transactionMsgDsDTO),
	}

	t.AddNewIpnMessage(ipnMessage)

	return &t
}

func NewTransactionMsgDTOFromDs(dto transactionMsgDsDTO, key *datastore.Key) *TransactionMsgDTO {
	t := TransactionMsgDTO{