Skip to content

Commit c095506

Browse files
committed
fix(core): simplify admin password warning per review feedback
- Remove updateInitPasswordWithMgr wrapper function per reviewer request - Add userID == adminUserID check before showing admin-specific warning - Remove unit tests that depended on the removed DI pattern Signed-off-by: thc1006 <[email protected]>
1 parent 3760df0 commit c095506

File tree

2 files changed

+2
-110
lines changed

2 files changed

+2
-110
lines changed

src/core/main.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ const (
8787
)
8888

8989
func updateInitPassword(ctx context.Context, userID int, password string) error {
90-
return updateInitPasswordWithMgr(ctx, pkguser.Mgr, userID, password)
91-
}
92-
93-
func updateInitPasswordWithMgr(ctx context.Context, userMgr pkguser.Manager, userID int, password string) error {
90+
userMgr := pkguser.Mgr
9491
user, err := userMgr.Get(ctx, userID)
9592
if err != nil {
9693
return fmt.Errorf("failed to get user, userID: %d %v", userID, err)
@@ -103,7 +100,7 @@ func updateInitPasswordWithMgr(ctx context.Context, userMgr pkguser.Manager, use
103100
log.Infof("User id: %d updated its encrypted password successfully.", userID)
104101
} else {
105102
log.Infof("User id: %d already has its encrypted password.", userID)
106-
if password != "" {
103+
if userID == adminUserID && password != "" {
107104
log.Warningf("The admin password in configuration (HARBOR_ADMIN_PASSWORD) will not be applied " +
108105
"because a password already exists in the database. To change the admin password, use the Harbor UI or API.")
109106
}

src/core/main_test.go

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)