Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-26 03:36:10 +01:00

Delete from email_address table

This commit is contained in:
JakobDev 2024-10-28 17:50:26 +01:00
parent 351ed1ab8a
commit dbb331fde0
No known key found for this signature in database
GPG key ID: 39DEF62C3ED6DC4C

View file

@ -214,8 +214,24 @@ func DeletePrimaryEmailAddressOfUser(ctx context.Context, uid int64) error {
return fmt.Errorf("%s is not a organization", user.Name)
}
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
defer committer.Close()
_, err = db.GetEngine(ctx).Exec("DELETE FROM email_address WHERE uid = ? AND is_primary = true", uid)
if err != nil {
return err
}
user.Email = ""
return UpdateUserCols(ctx, user, "email")
err = UpdateUserCols(ctx, user, "email")
if err != nil {
return err
}
return committer.Commit()
}
// GetEmailAddresses returns all email addresses belongs to given user.