mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add collaborator now handles role, added macaron-contrib/binding for binding and validation
This commit is contained in:
@@ -134,11 +134,15 @@ func GetAccountByToken(query *m.GetAccountByTokenQuery) error {
|
||||
}
|
||||
|
||||
func GetAccountByLogin(query *m.GetAccountByLoginQuery) error {
|
||||
if query.LoginOrEmail == "" {
|
||||
return m.ErrAccountNotFound
|
||||
}
|
||||
|
||||
account := new(m.Account)
|
||||
if strings.Contains(query.Login, "@") {
|
||||
account = &m.Account{Email: query.Login}
|
||||
if strings.Contains(query.LoginOrEmail, "@") {
|
||||
account = &m.Account{Email: query.LoginOrEmail}
|
||||
} else {
|
||||
account = &m.Account{Login: strings.ToLower(query.Login)}
|
||||
account = &m.Account{Login: strings.ToLower(query.LoginOrEmail)}
|
||||
}
|
||||
|
||||
has, err := x.Get(account)
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestAccountDataAccess(t *testing.T) {
|
||||
cmd := m.AddCollaboratorCommand{
|
||||
AccountId: ac1.Id,
|
||||
CollaboratorId: ac2.Id,
|
||||
Role: m.ROLE_READ_WRITE,
|
||||
Role: m.ROLE_VIEWER,
|
||||
}
|
||||
|
||||
err := AddCollaborator(&cmd)
|
||||
|
||||
@@ -45,7 +45,7 @@ func init() {
|
||||
}
|
||||
|
||||
func EnsureAdminUser() {
|
||||
adminQuery := m.GetAccountByLoginQuery{Login: setting.AdminUser}
|
||||
adminQuery := m.GetAccountByLoginQuery{LoginOrEmail: setting.AdminUser}
|
||||
|
||||
if err := bus.Dispatch(&adminQuery); err == m.ErrAccountNotFound {
|
||||
cmd := m.CreateAccountCommand{}
|
||||
|
||||
Reference in New Issue
Block a user