@@ -332,7 +332,7 @@ func updateActivation(ctx context.Context, email *EmailAddress, activate bool) e
332
332
return UpdateUserCols (ctx , user , "rands" )
333
333
}
334
334
335
- func makeEmailPrimary (ctx context.Context , user * User , email * EmailAddress ) error {
335
+ func MakeEmailPrimaryWithUser (ctx context.Context , user * User , email * EmailAddress ) error {
336
336
ctx , committer , err := db .TxContext (ctx )
337
337
if err != nil {
338
338
return err
@@ -362,33 +362,6 @@ func makeEmailPrimary(ctx context.Context, user *User, email *EmailAddress) erro
362
362
return committer .Commit ()
363
363
}
364
364
365
- // ReplaceInactivePrimaryEmail replaces the primary email of a given user, even if the primary is not yet activated.
366
- func ReplaceInactivePrimaryEmail (ctx context.Context , oldEmail string , email * EmailAddress ) error {
367
- user := & User {}
368
- has , err := db .GetEngine (ctx ).ID (email .UID ).Get (user )
369
- if err != nil {
370
- return err
371
- } else if ! has {
372
- return ErrUserNotExist {
373
- UID : email .UID ,
374
- Name : "" ,
375
- KeyID : 0 ,
376
- }
377
- }
378
-
379
- err = AddEmailAddress (ctx , email )
380
- if err != nil {
381
- return err
382
- }
383
-
384
- err = makeEmailPrimary (ctx , user , email )
385
- if err != nil {
386
- return err
387
- }
388
-
389
- return DeleteEmailAddress (ctx , & EmailAddress {UID : email .UID , Email : oldEmail })
390
- }
391
-
392
365
// MakeEmailPrimary sets primary email address of given user.
393
366
func MakeEmailPrimary (ctx context.Context , email * EmailAddress ) error {
394
367
has , err := db .GetEngine (ctx ).Get (email )
@@ -410,7 +383,7 @@ func MakeEmailPrimary(ctx context.Context, email *EmailAddress) error {
410
383
return ErrUserNotExist {UID : email .UID }
411
384
}
412
385
413
- return makeEmailPrimary (ctx , user , email )
386
+ return MakeEmailPrimaryWithUser (ctx , user , email )
414
387
}
415
388
416
389
// VerifyActiveEmailCode verifies active email code when active account
0 commit comments