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.
34 lines
1007 B
34 lines
1007 B
package user
|
|
|
|
import (
|
|
"log"
|
|
)
|
|
|
|
func (env *Env) setProfile(currUser *User, ktmTrainUsername string, ktmTrainPassword string, ktmTrainCreditCardType string, ktmTrainCreditCard string, ktmTrainCreditCardExpiry string, ktmTrainCreditCardCVV string) (*User, error) {
|
|
profile := &Profile{}
|
|
|
|
err := env.DB.Where(&Profile{UserID: currUser.ID}).FirstOrInit(profile).Error
|
|
if err != nil {
|
|
log.Println("Error initialising profile", err)
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
|
|
profile.UserID = currUser.ID
|
|
profile.KtmTrainUsername = ktmTrainUsername
|
|
profile.KtmTrainPassword = ktmTrainPassword
|
|
profile.KtmTrainCreditCardType = ktmTrainCreditCardType
|
|
profile.KtmTrainCreditCard = ktmTrainCreditCard
|
|
profile.KtmTrainCreditCardExpiry = ktmTrainCreditCardExpiry
|
|
profile.KtmTrainCreditCardCVV = ktmTrainCreditCardCVV
|
|
|
|
err = env.DB.Save(profile).Error
|
|
if err != nil {
|
|
log.Println("Error creating profile", err)
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
|
|
currUser.Profile = *profile
|
|
return currUser, nil
|
|
}
|