rest

package
v0.0.0-...-686d10b Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResetTokenValidity

func CheckResetTokenValidity(username, token string) types.M

CheckResetTokenValidity 检查要重置密码的用户与 token 是否存在

func Create

func Create(auth *Auth, className string, object types.M, clientSDK map[string]string) (types.M, error)

Create 创建对象 返回数据格式如下:

{
	"status":201,
	"response":{...},
	"location":"http://..."
}

func Delete

func Delete(auth *Auth, className, objectID string) error

Delete 删除指定对象

func Find

func Find(auth *Auth, className string, where, options types.M, clientSDK map[string]string) (types.M, error)

Find 根据条件查找数据 返回格式如下:

{
	"results":[
		{...},
	],
	"count":10
}

func Get

func Get(auth *Auth, className, objectID string, options types.M, clientSDK map[string]string) (types.M, error)

Get ...

func ResendVerificationEmail

func ResendVerificationEmail(username string) error

ResendVerificationEmail 重新发送验证邮件

func SendPasswordResetEmail

func SendPasswordResetEmail(email string) error

SendPasswordResetEmail 发送密码重置邮件

func SendVerificationEmail

func SendVerificationEmail(user types.M)

SendVerificationEmail 发送验证邮件

func SetEmailVerifyToken

func SetEmailVerifyToken(user types.M)

SetEmailVerifyToken 设置需要验证的 token

func Update

func Update(auth *Auth, className, objectID string, object types.M, clientSDK map[string]string) (types.M, error)

Update 更新对象 返回更新后的字段,一般只有 updatedAt

func UpdatePassword

func UpdatePassword(username, token, newPassword string) error

UpdatePassword 更新指定用户的密码

func VerifyEmail

func VerifyEmail(username, token string) bool

VerifyEmail 更新邮箱验证标志

Types

type AccountLockout

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

AccountLockout 密码错误达到一定次数,锁定账户

func NewAccountLockout

func NewAccountLockout(username string) *AccountLockout

NewAccountLockout ...

func (*AccountLockout) HandleLoginAttempt

func (a *AccountLockout) HandleLoginAttempt(loginSuccessful bool) error

HandleLoginAttempt 处理登录结果

type Auth

type Auth struct {
	IsMaster       bool
	IsReadOnly     bool
	InstallationID string
	User           types.M
	UserRoles      []string
	FetchedRoles   bool
	RolePromise    []string
	Info           *types.RequestInfo
}

Auth 保存当前请求的用户权限信息

func GetAuthForLegacySessionToken

func GetAuthForLegacySessionToken(sessionToken, installationID string, info *types.RequestInfo) (*Auth, error)

GetAuthForLegacySessionToken 处理保存在 _User 中的 sessionToken。 该方法处理从 parse 中迁移过来的用户数据,在 tomato 中其实不需要处理这种类型的数据,以后考虑删除

func GetAuthForSessionToken

func GetAuthForSessionToken(sessionToken string, installationID string, info *types.RequestInfo) (*Auth, error)

GetAuthForSessionToken 返回 sessionToken 对应的用户权限信息

func Master

func Master(info ...*types.RequestInfo) *Auth

Master 生成 Master 级别用户

func Nobody

func Nobody(info ...*types.RequestInfo) *Auth

Nobody 生成空用户

func ReadOnly

func ReadOnly(info ...*types.RequestInfo) *Auth

ReadOnly 生成 Master 级别的只读用户

func (*Auth) CouldUpdateUserID

func (a *Auth) CouldUpdateUserID(objectID string) bool

CouldUpdateUserID Master 与当前用户可进行修改

func (*Auth) GetUserRoles

func (a *Auth) GetUserRoles() []string

GetUserRoles 获取用户所属的角色列表

type Destroy

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

Destroy 删除对象

func NewDestroy

func NewDestroy(
	auth *Auth,
	className string,
	query types.M,
	originalData types.M,
) *Destroy

NewDestroy 组装 Destroy

func (*Destroy) Execute

func (d *Destroy) Execute() error

Execute 执行删除请求

type Query

type Query struct {
	Where types.M
	// contains filtered or unexported fields
}

Query 处理查询请求的结构体

func NewQuery

func NewQuery(
	auth *Auth,
	className string,
	where types.M,
	options types.M,
	clientSDK map[string]string,
) (*Query, error)

NewQuery 组装查询对象

func (*Query) BuildRestWhere

func (q *Query) BuildRestWhere() error

BuildRestWhere 展开查询参数,组装设置项

func (*Query) Execute

func (q *Query) Execute(executeOptions ...types.M) (types.M, error)

Execute 执行查询请求,返回的数据包含 results count 两个字段

type Write

type Write struct {
	RunOptions types.M
	// contains filtered or unexported fields
}

Write ...

func NewWrite

func NewWrite(
	auth *Auth,
	className string,
	query types.M,
	data types.M,
	originalData types.M,
	clientSDK map[string]string,
) (*Write, error)

NewWrite 可用于 create 和 update , create 时 query 为 nil query 查询条件,当 update 请求时不为空 data 写入数据 originalData 原始对象数据,当 update 请求时不为空

func (*Write) Execute

func (w *Write) Execute() (types.M, error)

Execute 执行写入操作,并返回结果

Jump to

Keyboard shortcuts

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