Auth: Only migrate non-empty legacy user fields #98

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2022-11-03 11:02:36 +01:00
parent ef9b76a54a
commit 36298b39d7

View file

@ -66,10 +66,18 @@ func CreateDefaultUsers() {
// Set legacy values. // Set legacy values.
if leg := FindLegacyUser(Admin); leg != nil { if leg := FindLegacyUser(Admin); leg != nil {
Admin.UserUID = leg.UserUID Admin.UserUID = leg.UserUID
Admin.UserName = leg.UserName if leg.UserName != "" {
Admin.UserEmail = leg.PrimaryEmail Admin.UserName = leg.UserName
Admin.DisplayName = leg.FullName }
Admin.LoginAt = leg.LoginAt if leg.PrimaryEmail != "" {
Admin.UserEmail = leg.PrimaryEmail
}
if leg.FullName != "" {
Admin.DisplayName = leg.FullName
}
if leg.LoginAt != nil {
Admin.LoginAt = leg.LoginAt
}
log.Infof("users: migrating %s account", Admin.UserName) log.Infof("users: migrating %s account", Admin.UserName)
} }