qor-example
qor-example copied to clipboard
qor-example registration bug on fresh new installation (mariadb)
Fresh new qor-example installation
MariaDB: 10.3.10 O.S: Windows 10 x64 Go version: 1.9.2
Just installed qor-example to play around. After installation I can load the page on port 7000 but when I try to register a new user the UI launches this error "Invalid account".
qor logs:
(Error 1054: Unknown column 'basics.provider' in 'where clause') [2018-10-27 20:24:32] 2018/10/27 20:24:32 "POST http://localhost:7000/auth/password/register HTTP/1.1" from [::1]:61478 - 200 8951B in 8.0356ms
Could it be a bug related with mariadb?
Thank you
Best regards.
For a quick fix,
Change DefaultAuthorizeHandler line 27 on /go/src/github.com/qor/auth/providers/password/handlers.go with that:
if tx.Model(context.Auth.AuthIdentityModel).Where(
map[string]interface{}{
"provider": authInfo.Provider,
"uid": authInfo.UID,
}).Scan(&authInfo).RecordNotFound() {
return nil, auth.ErrInvalidAccount
}
Thank you @turgayozgur but after applying this "patch", and "go clean"... re-launched and found the same error.
(Error 1054: Unknown column 'basics.provider' in 'where clause') [2018-10-28 12:33:32] 2018/10/28 12:33:32 "POST http://localhost:7000/auth/password/register HTTP/1.1" from 127.0.0.1:49675 - 200 8951B in 6.9773ms
Ok. this workaround works for login page.
You can do it the same method for register handle. Just change the Where clause of register handle from Where(authInfo)
to
.Where(
map[string]interface{}{
"provider": authInfo.Provider,
"uid": authInfo.UID,
})
`
``
sorry @turgayozgur I'm not sure about what are you proposing this time. The usage of this map is not the same thing that we tried just before? Thank you and sorry, I'm just beggining with go language.
Like I said before for line 27, same for line ~73. /go/src/github.com/qor/auth/providers/password/handlers.go line ~73 from
if !tx.Model(context.Auth.AuthIdentityModel).Where(authInfo).Scan(&authInfo).RecordNotFound() {
return nil, auth.ErrInvalidAccount
}
to
if tx.Model(context.Auth.AuthIdentityModel).Where(
map[string]interface{}{
"provider": authInfo.Provider,
"uid": authInfo.UID,
}).Scan(&authInfo).RecordNotFound() {
return nil, auth.ErrInvalidAccount
}
Hi @turgayozgur thank you for the try.
The log error gone but the UI error remains. "Invalid account" when triying to sign up.
log:
2018/10/28 18:49:01 "POST http://localhost:7000/auth/password/register HTTP/1.1" from [::1]:49357 - 200 8951B in 7.9805ms 2018/10/28 18:49:06 "POST http://localhost:7000/auth/password/register HTTP/1.1" from [::1]:49357 - 200 8951B in 10.003ms
Hi @manuelbcd I checked again and make some fixes. Here is the last password/handlers.go
https://gist.github.com/turgayozgur/c2e7449d5e2e0caeb9961760757eb7de
There are a few places in the auth/providers/password/*.go
that incorrectly use auth_identity.Basic
instead of auth_identity.AuthIdentity
. I was able to get the demo to work by changing Basic
to AuthIdentity
. Might want to review all uses of the auth_identity.Basic
type.
Without that change the confirmation link will corrupt the auth_identities
table by setting the uid
field of all records to the confirmed email address.
+1
Thanks @Neopallium , I change auth/providers/password/handlers
var authInfo auth_identity.AuthIdentity
It works~
Please see https://github.com/qor/auth/issues/12#issuecomment-524820403