示例#1
0
// AuthorizeAccount checks that the request sender has the right to access these data.
func AuthorizeAccount(c *pi.RequestContext) error {
	account, err := db.AuthorizeAccountByAccessToken(c.GetHeader(apiTokenHeader))
	if err != nil {
		return pi.NewError(401, err)
	}
	c.Data["account"] = account
	return nil
}
示例#2
0
// ExtendsSessionInterceptor extends the duration of the session of the player.
func ExtendsSessionInterceptor(c *pi.RequestContext) error {
	if err := db.ExtendsPlayerAccountTTLByAccessToken(c.GetHeader(apiTokenHeader), time.Now().Add(30*time.Minute)); err != nil {
		return pi.NewError(500, err)
	}
	return nil
}