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
if leg.UserName != "" {
Admin.UserName = leg.UserName Admin.UserName = leg.UserName
}
if leg.PrimaryEmail != "" {
Admin.UserEmail = leg.PrimaryEmail Admin.UserEmail = leg.PrimaryEmail
}
if leg.FullName != "" {
Admin.DisplayName = leg.FullName Admin.DisplayName = leg.FullName
}
if leg.LoginAt != nil {
Admin.LoginAt = leg.LoginAt Admin.LoginAt = leg.LoginAt
}
log.Infof("users: migrating %s account", Admin.UserName) log.Infof("users: migrating %s account", Admin.UserName)
} }