mirror of https://github.com/status-im/fathom.git
use real cli flags for email & password args
This commit is contained in:
parent
a152331ca8
commit
f1b2ba1775
|
@ -16,7 +16,7 @@ For getting a development version of Fathom up & running, please go through the
|
|||
1. Ensure you have [Golang](https://golang.org/doc/install#install) installed properly
|
||||
1. Get code: `git clone git@github.com:usefathom/fathom.git $GOPATH/src/github.com/usefathom/fathom`
|
||||
1. Compile into binary & prepare assets: `make all`
|
||||
1. Register your user account: `fathom register <email> <password>`
|
||||
1. Register your user account: `fathom register --email=<email> --password=<password>`
|
||||
1. Start the webserver: `fathom server` and then visit **http://localhost:8080** to access your analytics dashboard.
|
||||
|
||||
To start tracking, include the following JavaScript on your site and replace `yourfathom.com` with the URL to your Fathom instance (twice).
|
||||
|
|
|
@ -59,8 +59,17 @@ func main() {
|
|||
Name: "register",
|
||||
Aliases: []string{"r"},
|
||||
Usage: "register a new admin user",
|
||||
ArgsUsage: "<email> <password>",
|
||||
Action: register,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "email, e",
|
||||
Usage: "user email",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "password, p",
|
||||
Usage: "user password",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
"github.com/usefathom/fathom/pkg/models"
|
||||
|
@ -8,21 +11,25 @@ import (
|
|||
)
|
||||
|
||||
func register(c *cli.Context) error {
|
||||
if c.NArg() < 2 {
|
||||
cli.ShowSubcommandHelp(c)
|
||||
return nil
|
||||
email := c.String("email")
|
||||
if email == "" {
|
||||
return errors.New("invalid args: missing email address")
|
||||
}
|
||||
|
||||
hash, _ := bcrypt.GenerateFromPassword([]byte(c.String("password")), 10)
|
||||
password := c.String("password")
|
||||
if password == "" {
|
||||
return errors.New("invalid args: missing password")
|
||||
}
|
||||
|
||||
hash, _ := bcrypt.GenerateFromPassword([]byte(password), 10)
|
||||
user := &models.User{
|
||||
Email: c.String("email"),
|
||||
Email: email,
|
||||
Password: string(hash),
|
||||
}
|
||||
err := app.database.SaveUser(user)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("error creating user: %s", err)
|
||||
return err
|
||||
return fmt.Errorf("error creating user: %s", err)
|
||||
}
|
||||
|
||||
log.Infof("created user %s", user.Email)
|
||||
|
|
|
@ -109,7 +109,7 @@ function new_fathom_user() {
|
|||
echo "Create user account: "
|
||||
read -p " Email address: " USER_EMAIL
|
||||
read -p " Password: " USER_PASSWORD
|
||||
fathom --config="$SITE_DIR_ABS/config.env" register "$USER_EMAIL" "$USER_PASSWORD"
|
||||
fathom --config="$SITE_DIR_ABS/config.env" register --email="$USER_EMAIL" --password="$USER_PASSWORD"
|
||||
echo ""
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue