mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fixes
This commit is contained in:
parent
d2eab2ff4c
commit
23f163e8cf
@ -53,6 +53,17 @@ func UpsertUser(ctx *m.ReqContext, cmd *m.UpsertUserCommand) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if userQuery.UserAuth == nil && extUser.AuthModule != "" && extUser.AuthId != "" {
|
||||||
|
cmd2 := m.SetAuthInfoCommand{
|
||||||
|
UserId: cmd.User.Id,
|
||||||
|
AuthModule: extUser.AuthModule,
|
||||||
|
AuthId: extUser.AuthId,
|
||||||
|
}
|
||||||
|
if err := bus.Dispatch(&cmd2); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = syncOrgRoles(cmd.User, extUser)
|
err = syncOrgRoles(cmd.User, extUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -71,15 +82,6 @@ func createUser(extUser *m.ExternalUserInfo) (*m.User, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd2 := m.SetAuthInfoCommand{
|
|
||||||
UserId: cmd.Result.Id,
|
|
||||||
AuthModule: extUser.AuthModule,
|
|
||||||
AuthId: extUser.AuthId,
|
|
||||||
}
|
|
||||||
if err := bus.Dispatch(&cmd2); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &cmd.Result, nil
|
return &cmd.Result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type UserAuth struct {
|
type UserAuth struct {
|
||||||
Id int64
|
Id int64
|
||||||
UserId int64
|
UserId int64
|
||||||
AuthModule string
|
AuthModule string
|
||||||
AuthId string
|
AuthId string
|
||||||
|
Created time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExternalUserInfo struct {
|
type ExternalUserInfo struct {
|
||||||
|
@ -8,7 +8,7 @@ func addUserAuthMigrations(mg *Migrator) {
|
|||||||
Columns: []*Column{
|
Columns: []*Column{
|
||||||
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
|
||||||
{Name: "user_id", Type: DB_BigInt, Nullable: false},
|
{Name: "user_id", Type: DB_BigInt, Nullable: false},
|
||||||
{Name: "auth_module", Type: DB_NVarchar, Length: 30, Nullable: false},
|
{Name: "auth_module", Type: DB_NVarchar, Length: 190, Nullable: false},
|
||||||
{Name: "auth_id", Type: DB_NVarchar, Length: 100, Nullable: false},
|
{Name: "auth_id", Type: DB_NVarchar, Length: 100, Nullable: false},
|
||||||
{Name: "created", Type: DB_DateTime, Nullable: false},
|
{Name: "created", Type: DB_DateTime, Nullable: false},
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package sqlstore
|
package sqlstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
m "github.com/grafana/grafana/pkg/models"
|
m "github.com/grafana/grafana/pkg/models"
|
||||||
)
|
)
|
||||||
@ -107,6 +109,7 @@ func SetAuthInfo(cmd *m.SetAuthInfoCommand) error {
|
|||||||
UserId: cmd.UserId,
|
UserId: cmd.UserId,
|
||||||
AuthModule: cmd.AuthModule,
|
AuthModule: cmd.AuthModule,
|
||||||
AuthId: cmd.AuthId,
|
AuthId: cmd.AuthId,
|
||||||
|
Created: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := sess.Insert(&authUser)
|
_, err := sess.Insert(&authUser)
|
||||||
|
Loading…
Reference in New Issue
Block a user