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
630a8ed8
Commit
630a8ed8
authored
Sep 20, 2016
by
Dan Cech
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support setting default org role when adding user via grafana.net auth
parent
da95a230
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
14 deletions
+23
-14
pkg/api/login_oauth.go
+5
-4
pkg/models/user.go
+10
-9
pkg/services/sqlstore/user.go
+5
-1
pkg/social/grafananet_oauth.go
+2
-0
pkg/social/social.go
+1
-0
No files found.
pkg/api/login_oauth.go
View file @
630a8ed8
...
...
@@ -83,10 +83,11 @@ func OAuthLogin(ctx *middleware.Context) {
return
}
cmd
:=
m
.
CreateUserCommand
{
Login
:
userInfo
.
Email
,
Email
:
userInfo
.
Email
,
Name
:
userInfo
.
Name
,
Company
:
userInfo
.
Company
,
Login
:
userInfo
.
Email
,
Email
:
userInfo
.
Email
,
Name
:
userInfo
.
Name
,
Company
:
userInfo
.
Company
,
DefaultOrgRole
:
userInfo
.
Role
,
}
if
err
=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
...
...
pkg/models/user.go
View file @
630a8ed8
...
...
@@ -44,15 +44,16 @@ func (u *User) NameOrFallback() string {
// COMMANDS
type
CreateUserCommand
struct
{
Email
string
Login
string
Name
string
Company
string
OrgName
string
Password
string
EmailVerified
bool
IsAdmin
bool
SkipOrgSetup
bool
Email
string
Login
string
Name
string
Company
string
OrgName
string
Password
string
EmailVerified
bool
IsAdmin
bool
SkipOrgSetup
bool
DefaultOrgRole
string
Result
User
}
...
...
pkg/services/sqlstore/user.go
View file @
630a8ed8
...
...
@@ -128,7 +128,11 @@ func CreateUser(cmd *m.CreateUserCommand) error {
}
if
setting
.
AutoAssignOrg
&&
!
user
.
IsAdmin
{
orgUser
.
Role
=
m
.
RoleType
(
setting
.
AutoAssignOrgRole
)
if
len
(
cmd
.
DefaultOrgRole
)
>
0
{
orgUser
.
Role
=
m
.
RoleType
(
cmd
.
DefaultOrgRole
)
}
else
{
orgUser
.
Role
=
m
.
RoleType
(
setting
.
AutoAssignOrgRole
)
}
}
if
_
,
err
=
sess
.
Insert
(
&
orgUser
);
err
!=
nil
{
...
...
pkg/social/grafananet_oauth.go
View file @
630a8ed8
...
...
@@ -83,6 +83,7 @@ func (s *SocialGrafanaNet) UserInfo(token *oauth2.Token) (*BasicUserInfo, error)
Id
int
`json:"id"`
Name
string
`json:"login"`
Email
string
`json:"email"`
Role
string
`json:"role"`
}
var
err
error
...
...
@@ -102,6 +103,7 @@ func (s *SocialGrafanaNet) UserInfo(token *oauth2.Token) (*BasicUserInfo, error)
Identity
:
strconv
.
Itoa
(
data
.
Id
),
Name
:
data
.
Name
,
Email
:
data
.
Email
,
Role
:
data
.
Role
,
}
if
!
s
.
IsOrganizationMember
(
client
)
{
...
...
pkg/social/social.go
View file @
630a8ed8
...
...
@@ -15,6 +15,7 @@ type BasicUserInfo struct {
Email
string
Login
string
Company
string
Role
string
}
type
SocialConnector
interface
{
...
...
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