3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 13:29:27 +01:00

Merge pull request #229 from enckse/master

genpasswd confirmation of entered password
This commit is contained in:
Daniel Oaks 2018-04-11 08:28:11 +10:00 committed by GitHub
commit 74af078f7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,15 @@ import (
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() {
version := irc.SemVer
usage := `oragono.
@ -56,16 +65,18 @@ Options:
if arguments["genpasswd"].(bool) {
fmt.Print("Enter Password: ")
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil {
log.Fatal("Error reading password:", err.Error())
password := getPassword()
fmt.Print("\n")
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)
if err != nil {
log.Fatal("encoding error:", err.Error())
}
fmt.Print("\n")
fmt.Println(encoded)
} else if arguments["initdb"].(bool) {
irc.InitDB(config.Datastore.Path)