You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
876 B
29 lines
876 B
package user
|
|
|
|
import (
|
|
"log"
|
|
|
|
"gorm.io/gorm/clause"
|
|
)
|
|
|
|
func (env *Env) setProfile(currUser *User, ktmTrainUsername string, ktmTrainPassword string, ktmTrainCreditCardType string, ktmTrainCreditCard string, ktmTrainCreditCardExpiry string, ktmTrainCreditCardCVV string) (*User, error) {
|
|
profile := &Profile{
|
|
UserID: currUser.ID,
|
|
KtmTrainUsername: ktmTrainUsername,
|
|
KtmTrainPassword: ktmTrainPassword,
|
|
KtmTrainCreditCardType: ktmTrainCreditCardType,
|
|
KtmTrainCreditCard: ktmTrainCreditCard,
|
|
KtmTrainCreditCardExpiry: ktmTrainCreditCardExpiry,
|
|
KtmTrainCreditCardCVV: ktmTrainCreditCardCVV,
|
|
}
|
|
|
|
if err := env.DB.Clauses(clause.OnConflict{
|
|
UpdateAll: true,
|
|
}).Create(profile).Error; err != nil {
|
|
log.Println("Error creating profile", err)
|
|
return nil, err
|
|
}
|
|
|
|
currUser.Profile = *profile
|
|
return currUser, nil
|
|
}
|