Skip to content

Commit

Permalink
Add ability to set username
Browse files Browse the repository at this point in the history
  • Loading branch information
riptl committed Aug 6, 2023
1 parent eff4838 commit 8f381b2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions srepanel/database/passwords.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,12 @@ func (d *DB) SetPassword(ctx context.Context, id uint64, username, password stri
)
return err
}

func (d *DB) SetUsername(ctx context.Context, id uint64, username string) error {
_, err := d.ExecContext(
ctx,
`UPDATE passwords SET username = ? WHERE id = ?`,
username, id,
)
return err
}
17 changes: 17 additions & 0 deletions srepanel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ func main() {
// cli args
if len(os.Args) > 1 {
switch os.Args[1] {
case "rename":
os.Args = os.Args[1:]
dbPath := flag.String("db", "ghidra_panel.db", "path to database file")
argUserID := flag.Uint64("user-id", 0, "ID of user to rename")
argUser := flag.String("user", "", "new username")
flag.Parse()
db, err := database.Open(dbPath)
if err != nil {
log.Fatal(err)
}
defer db.Close()

ctx := context.Background()
if err := db.SetPassword(ctx, userID, user, pass); err != nil {
log.Fatal(err)
}
return
case "set-password":
os.Args = os.Args[1:]
dbPath := flag.String("db", "ghidra_panel.db", "path to database file")
Expand Down

0 comments on commit 8f381b2

Please sign in to comment.