gobuffalo / buffalo-auth

Buffalo auth plugin helps adding username password authentication to your app
https://gobuffalo.io
MIT License
41 stars 28 forks source link
authentication generator go gobuffalo golang plugin

Auth Generator for Buffalo

Standard Test Go Reference Go Report Card

Installation

$ buffalo plugins install github.com/gobuffalo/buffalo-auth@latest

Usage

To generate a basic username / password authentication you can run:

$ buffalo generate auth

This will do:

User model Fields

Sometimes you would want to add extra fields to the user model, to do so, you can pass those to the auth command and use the pop notation for those fields, for example:

$ buffalo generate auth first_name last_name notes:text

Will generate a User model (inside models/user.go) that looks like:

type User struct {
  ID                   uuid.UUID `json:"id" db:"id"`
  CreatedAt            time.Time `json:"created_at" db:"created_at"`
  UpdatedAt            time.Time `json:"updated_at" db:"updated_at"`
  Email                string    `json:"email" db:"email"`
  PasswordHash         string    `json:"password_hash" db:"password_hash"`
  FirstName            string    `json:"first_name" db:"first_name"`
  LastName             string    `json:"last_name" db:"last_name"`
  Notes                string    `json:"notes" db:"notes"`
  Password             string    `json:"-" db:"-"`
  PasswordConfirmation string    `json:"-" db:"-"`
}