Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
0f6e5e29
Commit
0f6e5e29
authored
Jul 13, 2018
by
Mark Meyer
Committed by
Torkel Ödegaard
Jul 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow settting of default org id to auto-assign to (#12401)
Author: Mark Meyer <mark@ofosos.org>
parent
7ae84451
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
4 deletions
+21
-4
docs/sources/installation/configuration.md
+6
-0
pkg/services/sqlstore/dashboard_test.go
+1
-0
pkg/services/sqlstore/org_test.go
+1
-0
pkg/services/sqlstore/user.go
+11
-4
pkg/setting/setting.go
+2
-0
No files found.
docs/sources/installation/configuration.md
View file @
0f6e5e29
...
...
@@ -296,6 +296,12 @@ Set to `true` to automatically add new users to the main organization
(id 1). When set to
`false`
, new users will automatically cause a new
organization to be created for that new user.
### auto_assign_org_id
Set this value to automatically add new users to the provided org.
This requires
`auto_assign_org`
to be set to
`true`
. Please make sure
that this organization does already exists.
### auto_assign_org_role
The role new users will be assigned for the main organization (if the
...
...
pkg/services/sqlstore/dashboard_test.go
View file @
0f6e5e29
...
...
@@ -387,6 +387,7 @@ func insertTestDashboardForPlugin(title string, orgId int64, folderId int64, isF
func
createUser
(
name
string
,
role
string
,
isAdmin
bool
)
m
.
User
{
setting
.
AutoAssignOrg
=
true
setting
.
AutoAssignOrgId
=
1
setting
.
AutoAssignOrgRole
=
role
currentUserCmd
:=
m
.
CreateUserCommand
{
Login
:
name
,
Email
:
name
+
"@test.com"
,
Name
:
"a "
+
name
,
IsAdmin
:
isAdmin
}
...
...
pkg/services/sqlstore/org_test.go
View file @
0f6e5e29
...
...
@@ -17,6 +17,7 @@ func TestAccountDataAccess(t *testing.T) {
Convey
(
"Given single org mode"
,
func
()
{
setting
.
AutoAssignOrg
=
true
setting
.
AutoAssignOrgId
=
1
setting
.
AutoAssignOrgRole
=
"Viewer"
Convey
(
"Users should be added to default organization"
,
func
()
{
...
...
pkg/services/sqlstore/user.go
View file @
0f6e5e29
...
...
@@ -42,16 +42,23 @@ func getOrgIdForNewUser(cmd *m.CreateUserCommand, sess *DBSession) (int64, error
var
org
m
.
Org
if
setting
.
AutoAssignOrg
{
// right now auto assign to org with id 1
has
,
err
:=
sess
.
Where
(
"id=?"
,
1
)
.
Get
(
&
org
)
has
,
err
:=
sess
.
Where
(
"id=?"
,
setting
.
AutoAssignOrgId
)
.
Get
(
&
org
)
if
err
!=
nil
{
return
0
,
err
}
if
has
{
return
org
.
Id
,
nil
}
}
else
{
if
setting
.
AutoAssignOrgId
==
1
{
org
.
Name
=
"Main Org."
org
.
Id
=
1
org
.
Id
=
int64
(
setting
.
AutoAssignOrgId
)
}
else
{
sqlog
.
Info
(
"Could not create user: organization id %v does not exist"
,
setting
.
AutoAssignOrgId
)
return
0
,
fmt
.
Errorf
(
"Could not create user: organization id %v does not exist"
,
setting
.
AutoAssignOrgId
)
}
}
}
else
{
org
.
Name
=
cmd
.
OrgName
if
len
(
org
.
Name
)
==
0
{
...
...
pkg/setting/setting.go
View file @
0f6e5e29
...
...
@@ -100,6 +100,7 @@ var (
AllowUserSignUp
bool
AllowUserOrgCreate
bool
AutoAssignOrg
bool
AutoAssignOrgId
int
AutoAssignOrgRole
string
VerifyEmailEnabled
bool
LoginHint
string
...
...
@@ -592,6 +593,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
AllowUserSignUp
=
users
.
Key
(
"allow_sign_up"
)
.
MustBool
(
true
)
AllowUserOrgCreate
=
users
.
Key
(
"allow_org_create"
)
.
MustBool
(
true
)
AutoAssignOrg
=
users
.
Key
(
"auto_assign_org"
)
.
MustBool
(
true
)
AutoAssignOrgId
=
users
.
Key
(
"auto_assign_org_id"
)
.
MustInt
(
1
)
AutoAssignOrgRole
=
users
.
Key
(
"auto_assign_org_role"
)
.
In
(
"Editor"
,
[]
string
{
"Editor"
,
"Admin"
,
"Viewer"
})
VerifyEmailEnabled
=
users
.
Key
(
"verify_email_enabled"
)
.
MustBool
(
false
)
LoginHint
=
users
.
Key
(
"login_hint"
)
.
String
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment