fathom/commands/users.go

21 lines
474 B
Go
Raw Normal View History

package commands
2016-12-11 14:50:01 +01:00
import (
"github.com/dannyvankooten/ana/datastore"
2016-12-11 14:50:01 +01:00
"github.com/dannyvankooten/ana/models"
"golang.org/x/crypto/bcrypt"
"log"
)
// Register creates a new user with the given email & password
func Register(email string, password string) {
hash, _ := bcrypt.GenerateFromPassword([]byte(password), 10)
2016-12-11 14:50:01 +01:00
user := models.User{
Email: email,
2016-12-11 14:50:01 +01:00
Password: string(hash),
}
user.Save(datastore.DB)
log.Printf("User %s #%d created.\n", email, user.ID)
}