Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX]Fixed case where it panics if no user is found #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions cmd/helper-reset-password/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"os"
"path"

helper_reset_password "github.com/portainer/helper-reset-password"
"github.com/portainer/helper-reset-password/password"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/crypto"
"github.com/portainer/portainer/api/database"
"github.com/portainer/portainer/api/datastore"
"github.com/portainer/portainer/api/filesystem"

helper_reset_password "github.com/portainer/helper-reset-password"
"github.com/portainer/helper-reset-password/password"
)

func main() {
Expand Down Expand Up @@ -75,9 +76,11 @@ func main() {
}
}

// If password is used for docker extension. It won't return an error if passwords are same.
if err := cryptoService.CompareHashAndData(user.Password, "K7yJPP5qNK4hf1QsRnfV"); err == nil {
log.Fatalf("Database from a Docker Desktop Portainer instance detected - exiting without resetting")
if user != nil {
// If password is used for docker extension. It won't return an error if passwords are same.
if err := cryptoService.CompareHashAndData(user.Password, "K7yJPP5qNK4hf1QsRnfV"); err == nil {
log.Fatalf("Database from a Docker Desktop Portainer instance detected - exiting without resetting")
}
}

// generate the new password
Expand Down