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
884a99e3
Unverified
Commit
884a99e3
authored
Feb 16, 2021
by
dupondje
Committed by
GitHub
Feb 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable Change Password for OAuth users (#27886)
parent
4dfce12a
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
35 deletions
+65
-35
public/app/core/utils/UserProvider.tsx
+3
-3
public/app/features/profile/ChangePasswordForm.tsx
+9
-2
public/app/features/profile/ChangePasswordPage.tsx
+30
-20
public/app/features/profile/UserOrganizations.tsx
+2
-2
public/app/features/profile/UserProfileEdit.tsx
+9
-2
public/app/features/profile/UserProfileEditForm.tsx
+10
-4
public/app/features/profile/UserSessions.tsx
+2
-2
No files found.
public/app/core/utils/UserProvider.tsx
View file @
884a99e3
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
{
getBackendSrv
}
from
'@grafana/runtime'
;
import
{
getBackendSrv
}
from
'@grafana/runtime'
;
import
{
User
,
Team
,
UserOrg
,
UserSession
}
from
'app/types'
;
import
{
User
DTO
,
Team
,
UserOrg
,
UserSession
}
from
'app/types'
;
import
{
config
}
from
'app/core/config'
;
import
{
config
}
from
'app/core/config'
;
import
{
dateTimeFormat
,
dateTimeFormatTimeAgo
}
from
'@grafana/data'
;
import
{
dateTimeFormat
,
dateTimeFormatTimeAgo
}
from
'@grafana/data'
;
...
@@ -45,12 +45,12 @@ export interface Props {
...
@@ -45,12 +45,12 @@ export interface Props {
teams
:
Team
[],
teams
:
Team
[],
orgs
:
UserOrg
[],
orgs
:
UserOrg
[],
sessions
:
UserSession
[],
sessions
:
UserSession
[],
user
?:
User
user
?:
User
DTO
)
=>
JSX
.
Element
;
)
=>
JSX
.
Element
;
}
}
export
interface
State
{
export
interface
State
{
user
?:
User
;
user
?:
User
DTO
;
teams
:
Team
[];
teams
:
Team
[];
orgs
:
UserOrg
[];
orgs
:
UserOrg
[];
sessions
:
UserSession
[];
sessions
:
UserSession
[];
...
...
public/app/features/profile/ChangePasswordForm.tsx
View file @
884a99e3
import
React
,
{
FC
}
from
'react'
;
import
React
,
{
FC
}
from
'react'
;
import
config
from
'app/core/config'
;
import
config
from
'app/core/config'
;
import
{
UserDTO
}
from
'app/types'
;
import
{
Button
,
LinkButton
,
Form
,
Field
,
Input
,
HorizontalGroup
}
from
'@grafana/ui'
;
import
{
Button
,
LinkButton
,
Form
,
Field
,
Input
,
HorizontalGroup
}
from
'@grafana/ui'
;
import
{
ChangePasswordFields
}
from
'app/core/utils/UserProvider'
;
import
{
ChangePasswordFields
}
from
'app/core/utils/UserProvider'
;
import
{
css
}
from
'emotion'
;
import
{
css
}
from
'emotion'
;
export
interface
Props
{
export
interface
Props
{
user
:
UserDTO
;
isSaving
:
boolean
;
isSaving
:
boolean
;
onChangePassword
:
(
payload
:
ChangePasswordFields
)
=>
void
;
onChangePassword
:
(
payload
:
ChangePasswordFields
)
=>
void
;
}
}
export
const
ChangePasswordForm
:
FC
<
Props
>
=
({
onChangePassword
,
isSaving
})
=>
{
export
const
ChangePasswordForm
:
FC
<
Props
>
=
({
user
,
onChangePassword
,
isSaving
})
=>
{
const
{
ldapEnabled
,
authProxyEnabled
}
=
config
;
const
{
ldapEnabled
,
authProxyEnabled
,
disableLoginForm
}
=
config
;
const
authSource
=
user
.
authLabels
?.
length
&&
user
.
authLabels
[
0
];
if
(
ldapEnabled
||
authProxyEnabled
)
{
if
(
ldapEnabled
||
authProxyEnabled
)
{
return
<
p
>
You cannot change password when ldap or auth proxy authentication is enabled.
</
p
>;
return
<
p
>
You cannot change password when ldap or auth proxy authentication is enabled.
</
p
>;
}
}
if
(
authSource
&&
disableLoginForm
)
{
return
<
p
>
Password cannot be changed here!
</
p
>;
}
return
(
return
(
<
div
<
div
className=
{
css
`
className=
{
css
`
...
...
public/app/features/profile/ChangePasswordPage.tsx
View file @
884a99e3
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
FC
}
from
'react'
;
import
{
hot
}
from
'react-hot-loader'
;
import
{
hot
}
from
'react-hot-loader'
;
import
{
connect
}
from
'react-redux'
;
import
{
connect
}
from
'react-redux'
;
import
{
StoreState
}
from
'app/types'
;
import
{
config
}
from
'@grafana/runtime'
;
import
{
LoadingPlaceholder
}
from
'@grafana/ui'
;
import
{
UserDTO
,
Team
,
UserOrg
,
UserSession
,
StoreState
}
from
'app/types'
;
import
{
NavModel
}
from
'@grafana/data'
;
import
{
NavModel
}
from
'@grafana/data'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
UserProvider
}
from
'app/core/utils/UserProvider'
;
import
{
UserProvider
,
UserAPI
,
LoadingStates
}
from
'app/core/utils/UserProvider'
;
import
Page
from
'app/core/components/Page/Page'
;
import
Page
from
'app/core/components/Page/Page'
;
import
{
ChangePasswordForm
}
from
'./ChangePasswordForm'
;
import
{
ChangePasswordForm
}
from
'./ChangePasswordForm'
;
...
@@ -12,23 +14,31 @@ export interface Props {
...
@@ -12,23 +14,31 @@ export interface Props {
navModel
:
NavModel
;
navModel
:
NavModel
;
}
}
export
class
ChangePasswordPage
extends
PureComponent
<
Props
>
{
export
const
ChangePasswordPage
:
FC
<
Props
>
=
({
navModel
})
=>
(
render
()
{
<
Page
navModel=
{
navModel
}
>
const
{
navModel
}
=
this
.
props
;
<
UserProvider
userId=
{
config
.
bootData
.
user
.
id
}
>
return
(
{
(
<
Page
navModel=
{
navModel
}
>
api
:
UserAPI
,
<
UserProvider
>
states
:
LoadingStates
,
{
({
changePassword
},
states
)
=>
(
teams
:
Team
[],
<
Page
.
Contents
>
orgs
:
UserOrg
[],
<
h3
className=
"page-sub-heading"
>
Change Your Password
</
h3
>
sessions
:
UserSession
[],
<
ChangePasswordForm
onChangePassword=
{
changePassword
}
isSaving=
{
states
.
changePassword
}
/>
user
:
UserDTO
</
Page
.
Contents
>
)
=>
{
)
}
return
(
</
UserProvider
>
<
Page
.
Contents
>
</
Page
>
<
h3
className=
"page-sub-heading"
>
Change Your Password
</
h3
>
);
{
states
.
loadUser
?
(
}
<
LoadingPlaceholder
text=
"Loading user profile..."
/>
}
)
:
(
<
ChangePasswordForm
user=
{
user
}
onChangePassword=
{
api
.
changePassword
}
isSaving=
{
states
.
changePassword
}
/>
)
}
</
Page
.
Contents
>
);
}
}
</
UserProvider
>
</
Page
>
);
function
mapStateToProps
(
state
:
StoreState
)
{
function
mapStateToProps
(
state
:
StoreState
)
{
return
{
return
{
...
...
public/app/features/profile/UserOrganizations.tsx
View file @
884a99e3
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
{
User
,
UserOrg
}
from
'app/types'
;
import
{
User
DTO
,
UserOrg
}
from
'app/types'
;
import
{
LoadingPlaceholder
,
Button
}
from
'@grafana/ui'
;
import
{
LoadingPlaceholder
,
Button
}
from
'@grafana/ui'
;
export
interface
Props
{
export
interface
Props
{
user
:
User
;
user
:
User
DTO
;
orgs
:
UserOrg
[];
orgs
:
UserOrg
[];
isLoading
:
boolean
;
isLoading
:
boolean
;
loadOrgs
:
()
=>
void
;
loadOrgs
:
()
=>
void
;
...
...
public/app/features/profile/UserProfileEdit.tsx
View file @
884a99e3
...
@@ -6,7 +6,7 @@ import { config } from '@grafana/runtime';
...
@@ -6,7 +6,7 @@ import { config } from '@grafana/runtime';
import
{
NavModel
}
from
'@grafana/data'
;
import
{
NavModel
}
from
'@grafana/data'
;
import
{
UserProvider
,
UserAPI
,
LoadingStates
}
from
'app/core/utils/UserProvider'
;
import
{
UserProvider
,
UserAPI
,
LoadingStates
}
from
'app/core/utils/UserProvider'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
User
,
Team
,
UserOrg
,
UserSession
,
StoreState
}
from
'app/types'
;
import
{
User
DTO
,
Team
,
UserOrg
,
UserSession
,
StoreState
}
from
'app/types'
;
import
{
SharedPreferences
}
from
'app/core/components/SharedPreferences/SharedPreferences'
;
import
{
SharedPreferences
}
from
'app/core/components/SharedPreferences/SharedPreferences'
;
import
Page
from
'app/core/components/Page/Page'
;
import
Page
from
'app/core/components/Page/Page'
;
import
{
UserTeams
}
from
'./UserTeams'
;
import
{
UserTeams
}
from
'./UserTeams'
;
...
@@ -21,7 +21,14 @@ export interface Props {
...
@@ -21,7 +21,14 @@ export interface Props {
export
const
UserProfileEdit
:
FC
<
Props
>
=
({
navModel
})
=>
(
export
const
UserProfileEdit
:
FC
<
Props
>
=
({
navModel
})
=>
(
<
Page
navModel=
{
navModel
}
>
<
Page
navModel=
{
navModel
}
>
<
UserProvider
userId=
{
config
.
bootData
.
user
.
id
}
>
<
UserProvider
userId=
{
config
.
bootData
.
user
.
id
}
>
{
(
api
:
UserAPI
,
states
:
LoadingStates
,
teams
:
Team
[],
orgs
:
UserOrg
[],
sessions
:
UserSession
[],
user
:
User
)
=>
{
{
(
api
:
UserAPI
,
states
:
LoadingStates
,
teams
:
Team
[],
orgs
:
UserOrg
[],
sessions
:
UserSession
[],
user
:
UserDTO
)
=>
{
return
(
return
(
<
Page
.
Contents
>
<
Page
.
Contents
>
{
states
.
loadUser
?
(
{
states
.
loadUser
?
(
...
...
public/app/features/profile/UserProfileEditForm.tsx
View file @
884a99e3
import
React
,
{
FC
}
from
'react'
;
import
React
,
{
FC
}
from
'react'
;
import
{
Button
,
Tooltip
,
Icon
,
Form
,
Input
,
Field
,
FieldSet
}
from
'@grafana/ui'
;
import
{
Button
,
Tooltip
,
Icon
,
Form
,
Input
,
Field
,
FieldSet
}
from
'@grafana/ui'
;
import
{
User
}
from
'app/types'
;
import
{
User
DTO
}
from
'app/types'
;
import
config
from
'app/core/config'
;
import
config
from
'app/core/config'
;
import
{
ProfileUpdateFields
}
from
'app/core/utils/UserProvider'
;
import
{
ProfileUpdateFields
}
from
'app/core/utils/UserProvider'
;
export
interface
Props
{
export
interface
Props
{
user
:
User
;
user
:
User
DTO
;
isSavingUser
:
boolean
;
isSavingUser
:
boolean
;
updateProfile
:
(
payload
:
ProfileUpdateFields
)
=>
void
;
updateProfile
:
(
payload
:
ProfileUpdateFields
)
=>
void
;
}
}
...
@@ -22,8 +22,14 @@ export const UserProfileEditForm: FC<Props> = ({ user, isSavingUser, updateProfi
...
@@ -22,8 +22,14 @@ export const UserProfileEditForm: FC<Props> = ({ user, isSavingUser, updateProfi
{
({
register
,
errors
})
=>
{
{
({
register
,
errors
})
=>
{
return
(
return
(
<
FieldSet
label=
"Edit Profile"
>
<
FieldSet
label=
"Edit Profile"
>
<
Field
label=
"Name"
invalid=
{
!!
errors
.
name
}
error=
"Name is required"
>
<
Field
label=
"Name"
invalid=
{
!!
errors
.
name
}
error=
"Name is required"
disabled=
{
disableLoginForm
}
>
<
Input
name=
"name"
ref=
{
register
({
required
:
true
})
}
placeholder=
"Name"
defaultValue=
{
user
.
name
}
/>
<
Input
name=
"name"
ref=
{
register
({
required
:
true
})
}
placeholder=
"Name"
defaultValue=
{
user
.
name
}
suffix=
{
<
InputSuffix
/>
}
/>
</
Field
>
</
Field
>
<
Field
label=
"Email"
invalid=
{
!!
errors
.
email
}
error=
"Email is required"
disabled=
{
disableLoginForm
}
>
<
Field
label=
"Email"
invalid=
{
!!
errors
.
email
}
error=
"Email is required"
disabled=
{
disableLoginForm
}
>
<
Input
<
Input
...
...
public/app/features/profile/UserSessions.tsx
View file @
884a99e3
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
{
User
,
UserSession
}
from
'app/types'
;
import
{
User
DTO
,
UserSession
}
from
'app/types'
;
import
{
LoadingPlaceholder
,
Button
,
Icon
}
from
'@grafana/ui'
;
import
{
LoadingPlaceholder
,
Button
,
Icon
}
from
'@grafana/ui'
;
export
interface
Props
{
export
interface
Props
{
user
:
User
;
user
:
User
DTO
;
sessions
:
UserSession
[];
sessions
:
UserSession
[];
isLoading
:
boolean
;
isLoading
:
boolean
;
loadSessions
:
()
=>
void
;
loadSessions
:
()
=>
void
;
...
...
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