GithubHelp home page GithubHelp logo

buffalo-auth's Introduction

Auth Generator for Buffalo

Installation

$ go get -u github.com/gobuffalo/buffalo-auth

Usage

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

$ buffalo generate auth

This will do:

  • Generate User authentication actions in actions/auth.go:

    • AuthNew
    • AuthCreate
    • AuthDestroy
  • Generate User signup actions in actions/users.go:

    • UsersNew
    • UsersCreate
  • Generate User model and migration ( model will be in models/user.go):

  • Generate Auth Middlewares

    • SetCurrentUser
    • Authorize
  • Add actions and middlewares in app.go:

    • [GET] /users/new -> UsersNew
    • [POST] /users -> UsersCreate
    • [GET] /signin -> AuthNew
    • [POST] /signin -> AuthCreate
    • [DELETE] /signout -> AuthDestroy
  • Use middlewares for all your actions and skip

    • HomeHandler
    • UsersNew
    • UsersCreate
    • AuthNew
    • AuthCreate

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 auth first_name last_name phone_number 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:"-"`
}

buffalo-auth's People

Contributors

markbates avatar paganotoni avatar mclark4386 avatar robbyoconnor avatar baccenfutter avatar bryanmoslo avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.