mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-28 15:09:28 +01:00
when entering/generating the password it's helpful to at least be asked to confirm the input so if you get something like an extraneous character, on confirmation, you could catch that
This commit is contained in:
parent
f1af7a2e2a
commit
dcf4cb7cde
21
oragono.go
21
oragono.go
@ -24,6 +24,15 @@ import (
|
|||||||
|
|
||||||
var commit = ""
|
var commit = ""
|
||||||
|
|
||||||
|
// get a password from stdin from the user
|
||||||
|
func getPassword() string {
|
||||||
|
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Error reading password:", err.Error())
|
||||||
|
}
|
||||||
|
return string(bytePassword)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
version := irc.SemVer
|
version := irc.SemVer
|
||||||
usage := `oragono.
|
usage := `oragono.
|
||||||
@ -56,16 +65,18 @@ Options:
|
|||||||
|
|
||||||
if arguments["genpasswd"].(bool) {
|
if arguments["genpasswd"].(bool) {
|
||||||
fmt.Print("Enter Password: ")
|
fmt.Print("Enter Password: ")
|
||||||
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
|
password := getPassword()
|
||||||
if err != nil {
|
fmt.Print("\n")
|
||||||
log.Fatal("Error reading password:", err.Error())
|
fmt.Print("Reenter Password: ")
|
||||||
|
confirm := getPassword()
|
||||||
|
fmt.Print("\n")
|
||||||
|
if confirm != password {
|
||||||
|
log.Fatal("passwords do not match")
|
||||||
}
|
}
|
||||||
password := string(bytePassword)
|
|
||||||
encoded, err := passwd.GenerateEncodedPassword(password)
|
encoded, err := passwd.GenerateEncodedPassword(password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("encoding error:", err.Error())
|
log.Fatal("encoding error:", err.Error())
|
||||||
}
|
}
|
||||||
fmt.Print("\n")
|
|
||||||
fmt.Println(encoded)
|
fmt.Println(encoded)
|
||||||
} else if arguments["initdb"].(bool) {
|
} else if arguments["initdb"].(bool) {
|
||||||
irc.InitDB(config.Datastore.Path)
|
irc.InitDB(config.Datastore.Path)
|
||||||
|
Loading…
Reference in New Issue
Block a user