qor / auth

Golang Authentication solution
MIT License
734 stars 98 forks source link

'Unknow column...' error #12

Closed aldorac337 closed 6 years ago

aldorac337 commented 6 years ago

I tried to run an authentication example but has an error : Error 1054: Unknown column 'basics.provider' in 'where clause' . Here is my source code:

import (
  "github.com/qor/auth"
  "github.com/qor/auth/auth_identity"
  "github.com/qor/auth/providers/github"
  "github.com/qor/auth/providers/google"
  "github.com/qor/auth/providers/password"
  "github.com/qor/auth/providers/facebook"
  "github.com/qor/auth/providers/twitter"
  "github.com/qor/session/manager"
  "github.com/jinzhu/gorm”
)

var (
  // Initialize gorm DB
  gormDB, _ = gorm.Open("mysql", "root:123456@/qor_example?charset=utf8&parseTime=True&loc=Local")

  // Initialize Auth with configuration
  Auth = auth.New(&auth.Config{
    DB: gormDB,
  })
)

func init() {
  // Migrate AuthIdentity model, AuthIdentity will be used to save auth info, like username/password, oauth token, you could change that.
  gormDB.AutoMigrate(&auth_identity.AuthIdentity{})

  // Register Auth providers
  // Allow use username/password
  Auth.RegisterProvider(password.New(&password.Config{}))

  // Allow use Github
  Auth.RegisterProvider(github.New(&github.Config{
    ClientID:     "github client id",
    ClientSecret: "github client secret",
  }))

  // Allow use Google
  Auth.RegisterProvider(google.New(&google.Config{
    ClientID:     "google client id",
    ClientSecret: "google client secret",
  }))

  // Allow use Facebook
  Auth.RegisterProvider(facebook.New(&facebook.Config{
    ClientID:     "facebook client id",
    ClientSecret: "facebook client secret",
  }))

  // Allow use Twitter
  Auth.RegisterProvider(twitter.New(&twitter.Config{
    ClientID:     "twitter client id",
    ClientSecret: "twitter client secret",
  }))
}

func main() {
  mux := http.NewServeMux()

  // Mount Auth to Router
  mux.Handle("/auth/", Auth.NewServeMux())
  http.ListenAndServe(":9000", manager.SessionManager.Middleware(mux))
}
sio2boss commented 6 years ago

+1. I get the same error.

alex77g commented 6 years ago

same here with go 1.10.2 mysql and sqlite

arinkverma commented 6 years ago

Is this fixed? I am also facing same issue.

sadegh-shahbazi commented 5 years ago

I have also same issue... in May 2019 It seems qor has been stopped

sadegh-shahbazi commented 5 years ago

qor-admin without auth is unusable

sagikazarmark commented 5 years ago

We faced this issue when upgraded GORM from v1.9.1 to v1.9.10. Downgrading back fixed the issue.