models

package
v0.0.0-...-5d64da7 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Character

type Character struct {
	Name     string   `json:"name" gorethink:"name"`
	SpriteID string   `json:"spriteid" gorethink:"spriteid"`
	Gender   string   `json:"gender" gorethink:"gender"`
	MapID    string   `json:"mapid" gorethink:"mapid"`
	Location Position `json:"position" gorethink:"position"`
	OwnerID  string   `json:"ownerid" gorethink:"ownerid"`
}

Character type

type Exception

type Exception struct {
	Message string `json:"message"`
}

Exception type

type JwtToken

type JwtToken struct {
	Owner string `json:"owner" gorethink:"owner"`
	Token string `json:"token" gorethink:"token"`
}

JwtToken holds jwt tokens

type Position

type Position struct {
	X int `json:"x" gorethink:"x"`
	Y int `json:"y" gorethink:"y"`
}

type Role

type Role int
const (
	ROLE_GUEST Role = iota
	ROLE_USER
	ROLE_PREMIUM
	ROLE_ADMIN
)

type Transaction

type Transaction struct {
	ID        string                       `json:"id" gorethink:"id"`
	Owner     string                       `json:"owner" gorethink:"owner"`
	State     string                       `json:"state" gorethink:"state"`
	Payment   *paypalsdk.CreatePaymentResp `json:"payment" gorethink:"payment"`
	Execution *paypalsdk.ExecuteResponse   `json:"execution" gorethink:"execution"`
}

Transaction struct for holding transactions with database

func NewTransaction

func NewTransaction(owner User, payment *paypalsdk.CreatePaymentResp) *Transaction

NewTransaction will create a new transaction in the database

func (*Transaction) Executed

func (t *Transaction) Executed(response *paypalsdk.ExecuteResponse)

Executed will save a successful execution response from paypal into the transaction object

type User

type User struct {
	Username      string      `json:"username" gorethink:"username"`
	PasswordHash  string      `json:"-" gorethink:"password_hash"`
	Email         string      `json:"email" gorethink:"email"`
	Characters    []Character `json:"characters" gorethink:"characters"`
	LoggedIn      bool        `json:"logged_in" gorethink:"logged_in"`
	Role          Role        `json:"role" gorethink:"role"`
	CurrentToken  string      `json:"-" gorethink:"current_token"`
	CurrentClient int         `json:"-" gorethink:"-"`
}

User struct for holding user data

func NewUser

func NewUser(username string, passwordhash string, email string) User

NewUser returns a new user with default settings

func (*User) IsAuthenticatedForRole

func (u *User) IsAuthenticatedForRole(r Role) bool

IsAuthenticatedForRole returns true if the user is AT OR ABOVE the requested security level

Jump to

Keyboard shortcuts

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