generated from PenaSide/GolangTemplate
add parse cookie for addaccount method
This commit is contained in:
parent
a49ba93b6b
commit
c9bdc6c501
@ -180,6 +180,12 @@ func (api *API2) AddAccount(ctx echo.Context) error {
|
||||
if !ok {
|
||||
return api.noauth(ctx)
|
||||
}
|
||||
// todo test
|
||||
var quizFrom string
|
||||
cookie, er := ctx.Request().Cookie("quizFrom")
|
||||
if er == nil {
|
||||
quizFrom = cookie.Value
|
||||
}
|
||||
|
||||
account, err := api.account.FindByUserID(ctx.Request().Context(), userID)
|
||||
if err != nil && err.Type() != errors.ErrNotFound {
|
||||
@ -195,7 +201,7 @@ func (api *API2) AddAccount(ctx echo.Context) error {
|
||||
return api.errorOld(ctx, err)
|
||||
}
|
||||
|
||||
account, err = api.account.Insert(ctx.Request().Context(), &models.Account{UserID: user.ID, Wallet: models.Wallet{Currency: defaultCurrency}})
|
||||
account, err = api.account.Insert(ctx.Request().Context(), &models.Account{UserID: user.ID, Wallet: models.Wallet{Currency: defaultCurrency}, From: quizFrom})
|
||||
if err != nil {
|
||||
return api.errorOld(ctx, err)
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ type Account struct {
|
||||
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
|
||||
DeletedAt *time.Time `json:"deletedAt,omitempty" bson:"deletedAt,omitempty"`
|
||||
From string `json:"from" bson:"from"`
|
||||
}
|
||||
|
||||
func (receiver *Account) Sanitize() *Account {
|
||||
|
Loading…
Reference in New Issue
Block a user