Skip to content

Commit

Permalink
feat: change to Spontaneous Scope should not be allowed #334
Browse files Browse the repository at this point in the history
  • Loading branch information
duttarnab committed Jul 26, 2022
1 parent 7522f6e commit 9361de9
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions admin-ui/plugins/auth-server/components/Scopes/ScopeForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect, useContext } from 'react'
import { useHistory } from 'react-router-dom'
import { connect } from 'react-redux'
import { useSelector, useDispatch } from 'react-redux'
import { Formik, ErrorMessage } from 'formik'
import * as Yup from 'yup'
import {
Expand Down Expand Up @@ -36,14 +36,16 @@ import {
PATTERN,
} from 'Plugins/auth-server/common/Constants'

function ScopeForm({ client, scope, scripts, attributes, handleSubmit, dispatch }) {
function ScopeForm({ scope, scripts, attributes, handleSubmit}) {
const { t } = useTranslation()
let dynamicScopeScripts = []
const theme = useContext(ThemeContext)
const selectedTheme = theme.state.theme
const history = useHistory()
const spontaneousClientScopes = scope.attributes.spontaneousClientScopes || []
const [options, setOptions] = useState();
const dispatch = useDispatch()
const client = useSelector((state) => state.oidcReducer.items)
let claims = []
scripts = scripts || []
attributes = attributes || []
Expand All @@ -55,15 +57,9 @@ function ScopeForm({ client, scope, scripts, attributes, handleSubmit, dispatch

const [init, setInit] = useState(false)
const [modal, setModal] = useState(false)
const [showClaimsPanel, handleClaimsPanel] = useState(
enableClaims(scope.scopeType),
)
const [showDynamicPanel, handleDynamicPanel] = useState(
enableDynamic(scope.scopeType),
)
const [showSpontaneousPanel, handleShowSpontaneousPanel] = useState(
enableSpontaneous(scope.scopeType),
)
const [showClaimsPanel, handleClaimsPanel] = useState(scope.scopeType === 'openid')
const [showDynamicPanel, handleDynamicPanel] = useState(scope.scopeType === 'dynamic')
const [showSpontaneousPanel, handleShowSpontaneousPanel] = useState(scope.scopeType === 'spontaneous')

useEffect(() => {
if (showSpontaneousPanel) {
Expand All @@ -79,15 +75,6 @@ function ScopeForm({ client, scope, scripts, attributes, handleSubmit, dispatch
setOptions(obj);
}

const enableClaims = (type) => {
return type === 'openid'
}
const enableDynamic = (type) => {
return type === 'dynamic'
}
const enableSpontaneous = (type) => {
return type === 'spontaneous'
}
const handleScopeTypeChanged = (type) => {
if (type && type === 'openid') {
handleClaimsPanel(true)
Expand Down

0 comments on commit 9361de9

Please sign in to comment.