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
a1b1d2fe
Unverified
Commit
a1b1d2fe
authored
Mar 23, 2018
by
Dan Cech
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switch to Result
parent
d5dd1c9b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
16 deletions
+16
-16
pkg/api/login_oauth.go
+3
-3
pkg/login/ext_user.go
+5
-5
pkg/login/ldap.go
+1
-1
pkg/middleware/auth_proxy.go
+3
-3
pkg/middleware/middleware_test.go
+3
-3
pkg/models/user_auth.go
+1
-1
No files found.
pkg/api/login_oauth.go
View file @
a1b1d2fe
...
...
@@ -164,18 +164,18 @@ func OAuthLogin(ctx *m.ReqContext) {
}
// add/update user in grafana
userQuery
:=
&
m
.
UpsertUserCommand
{
cmd
:=
&
m
.
UpsertUserCommand
{
ExternalUser
:
&
extUser
,
SignupAllowed
:
connect
.
IsSignupAllowed
(),
}
err
=
login
.
UpsertUser
(
ctx
,
userQuery
)
err
=
login
.
UpsertUser
(
ctx
,
cmd
)
if
err
!=
nil
{
redirectWithError
(
ctx
,
err
)
return
}
// login
loginUserWithUser
(
userQuery
.
User
,
ctx
)
loginUserWithUser
(
cmd
.
Result
,
ctx
)
metrics
.
M_Api_Login_OAuth
.
Inc
()
...
...
pkg/login/ext_user.go
View file @
a1b1d2fe
...
...
@@ -39,15 +39,15 @@ var UpsertUser = func(ctx *m.ReqContext, cmd *m.UpsertUserCommand) error {
return
ErrUsersQuotaReached
}
cmd
.
User
,
err
=
createUser
(
extUser
)
cmd
.
Result
,
err
=
createUser
(
extUser
)
if
err
!=
nil
{
return
err
}
}
else
{
cmd
.
User
=
userQuery
.
User
cmd
.
Result
=
userQuery
.
User
// sync user info
err
=
updateUser
(
cmd
.
User
,
extUser
)
err
=
updateUser
(
cmd
.
Result
,
extUser
)
if
err
!=
nil
{
return
err
}
...
...
@@ -55,7 +55,7 @@ var UpsertUser = func(ctx *m.ReqContext, cmd *m.UpsertUserCommand) error {
if
userQuery
.
UserAuth
==
nil
&&
extUser
.
AuthModule
!=
""
&&
extUser
.
AuthId
!=
""
{
cmd2
:=
m
.
SetAuthInfoCommand
{
UserId
:
cmd
.
User
.
Id
,
UserId
:
cmd
.
Result
.
Id
,
AuthModule
:
extUser
.
AuthModule
,
AuthId
:
extUser
.
AuthId
,
}
...
...
@@ -64,7 +64,7 @@ var UpsertUser = func(ctx *m.ReqContext, cmd *m.UpsertUserCommand) error {
}
}
err
=
syncOrgRoles
(
cmd
.
User
,
extUser
)
err
=
syncOrgRoles
(
cmd
.
Result
,
extUser
)
if
err
!=
nil
{
return
err
}
...
...
pkg/login/ldap.go
View file @
a1b1d2fe
...
...
@@ -199,7 +199,7 @@ func (a *ldapAuther) GetGrafanaUserFor(ctx *m.ReqContext, ldapUser *LdapUserInfo
return
nil
,
err
}
return
userQuery
.
User
,
nil
return
userQuery
.
Result
,
nil
}
func
(
a
*
ldapAuther
)
serverBind
()
error
{
...
...
pkg/middleware/auth_proxy.go
View file @
a1b1d2fe
...
...
@@ -71,17 +71,17 @@ func initContextWithAuthProxy(ctx *m.ReqContext, orgID int64) bool {
}
// add/update user in grafana
userQuery
:=
&
m
.
UpsertUserCommand
{
cmd
:=
&
m
.
UpsertUserCommand
{
ExternalUser
:
&
extUser
,
SignupAllowed
:
setting
.
AuthProxyAutoSignUp
,
}
err
:=
login
.
UpsertUser
(
ctx
,
userQuery
)
err
:=
login
.
UpsertUser
(
ctx
,
cmd
)
if
err
!=
nil
{
ctx
.
Handle
(
500
,
"Failed to login as user specified in auth proxy header"
,
err
)
return
true
}
query
.
UserId
=
userQuery
.
User
.
Id
query
.
UserId
=
cmd
.
Result
.
Id
if
err
:=
bus
.
Dispatch
(
query
);
err
!=
nil
{
ctx
.
Handle
(
500
,
"Failed to find user"
,
err
)
...
...
pkg/middleware/middleware_test.go
View file @
a1b1d2fe
...
...
@@ -184,7 +184,7 @@ func TestMiddlewareContext(t *testing.T) {
})
login
.
UpsertUser
=
func
(
ctx
*
m
.
ReqContext
,
cmd
*
m
.
UpsertUserCommand
)
error
{
cmd
.
User
=
&
m
.
User
{
Id
:
12
}
cmd
.
Result
=
&
m
.
User
{
Id
:
12
}
return
nil
}
...
...
@@ -215,7 +215,7 @@ func TestMiddlewareContext(t *testing.T) {
})
login
.
UpsertUser
=
func
(
ctx
*
m
.
ReqContext
,
cmd
*
m
.
UpsertUserCommand
)
error
{
cmd
.
User
=
&
m
.
User
{
Id
:
33
}
cmd
.
Result
=
&
m
.
User
{
Id
:
33
}
return
nil
}
...
...
@@ -277,7 +277,7 @@ func TestMiddlewareContext(t *testing.T) {
})
login
.
UpsertUser
=
func
(
ctx
*
m
.
ReqContext
,
cmd
*
m
.
UpsertUserCommand
)
error
{
cmd
.
User
=
&
m
.
User
{
Id
:
33
}
cmd
.
Result
=
&
m
.
User
{
Id
:
33
}
return
nil
}
...
...
pkg/models/user_auth.go
View file @
a1b1d2fe
...
...
@@ -29,7 +29,7 @@ type UpsertUserCommand struct {
ExternalUser
*
ExternalUserInfo
SignupAllowed
bool
User
*
User
Result
*
User
}
type
SetAuthInfoCommand
struct
{
...
...
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