Skip to content

Commit

Permalink
fix(admin-ui): remove generation of specific access_token #1477
Browse files Browse the repository at this point in the history
Signed-off-by: Jeet Viramgama <jviramgama5@gmail.com>
  • Loading branch information
jv18creator committed Nov 27, 2023
1 parent 6b7e231 commit b927d1a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 45 deletions.
6 changes: 1 addition & 5 deletions admin-ui/app/redux/features/attributesSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ const initialState = {
items: [],
loading: false,
initLoading: true,
accessToken: null
}

const attributesSlice = createSlice({
name: 'attributes',
initialState,
reducers: {
setAccessToken: (state, action) => {
state.accessToken = action.payload
},
getAttributesRoot: (state, action) => {
state.loading = true
},
Expand All @@ -32,7 +28,7 @@ const attributesSlice = createSlice({
}
})

export const { getAttributesRoot, getAttributesResponseRoot, toggleInitAttributeLoader, setAccessToken } =
export const { getAttributesRoot, getAttributesResponseRoot, toggleInitAttributeLoader } =
attributesSlice.actions

export default attributesSlice.reducer
Expand Down
18 changes: 1 addition & 17 deletions admin-ui/app/redux/sagas/AttributesSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { call, all, put, fork, takeLatest, select } from 'redux-saga/effects'
import { isFourZeroOneError, addAdditionalData } from 'Utils/TokenController'
import {
getAttributesResponseRoot,
setAccessToken,
toggleInitAttributeLoader
} from '../features/attributesSlice'
import { getAPIAccessToken } from 'Redux/features/authSlice'
Expand All @@ -14,28 +13,13 @@ import {
import AttributeApi from '../api/AttributeApi'
import { getClient } from 'Redux/api/base'
import { initAudit } from 'Redux/sagas/SagaUtils'
import { ATTRIBUTES_TAG } from 'Utils/PermChecker'

const PERSON_SCHEMA = 'person schema'

const JansConfigApi = require('jans_config_api')

function* newFunction() {
let token
token = yield select((state) => state.attributesReducerRoot.accessToken)

if (!token) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
const apiToken = yield call(fetchApiAccessToken, jwt, [ATTRIBUTES_TAG])
if (apiToken.access_token) {
token = apiToken.access_token
yield put(setAccessToken(apiToken.access_token))
} else {
token = yield select((state) => state.authReducer.token.access_token)
}
}


const token = yield select((state) => state.authReducer.token.access_token)
const issuer = yield select((state) => state.authReducer.issuer)
const api = new JansConfigApi.AttributeApi(
getClient(JansConfigApi, token, issuer),
Expand Down
5 changes: 0 additions & 5 deletions admin-ui/plugins/auth-server/redux/features/scopeSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ const initialState = {
clientScopes: [],
loadingClientScopes: false,
selectedClientScopes: [],
accessToken: null
}

const scopeSlice = createSlice({
name: 'scope',
initialState,
reducers: {
setAccessToken: (state, action) => {
state.accessToken = action.payload
},
scopeHandleLoading: (state) => {
state.loading = true
state.saveOperationFlag = false
Expand Down Expand Up @@ -156,7 +152,6 @@ export const {
getClientScopes,
emptyScopes,
setClientSelectedScopes,
setAccessToken
} = scopeSlice.actions
export { initialState }
export const { actions, reducer, state } = scopeSlice
Expand Down
23 changes: 5 additions & 18 deletions admin-ui/plugins/auth-server/redux/sagas/OAuthScopeSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import ScopeApi from '../api/ScopeApi'
import { getClient } from 'Redux/api/base'
import { isFourZeroOneError, addAdditionalData } from 'Utils/TokenController'
import { postUserAction, fetchApiAccessToken } from 'Redux/api/backend-api'
import { postUserAction } from 'Redux/api/backend-api'

const JansConfigApi = require('jans_config_api')
import { initAudit } from 'Redux/sagas/SagaUtils'
Expand All @@ -32,27 +32,14 @@ import {
addScopeResponse,
getScopeByCreatorResponse,
getClientScopesResponse,
setAccessToken
} from '../features/scopeSlice'
import { SCOPE_TAG } from 'Utils/PermChecker'

function* newFunction() {
let token
token = yield select((state) => state.scopeReducer.accessToken)

if (!token) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
const apiToken = yield call(fetchApiAccessToken, jwt, [SCOPE_TAG])
if (apiToken.access_token) {
token = apiToken.access_token
yield put(setAccessToken(apiToken.access_token))
} else {
token = yield select((state) => state.authReducer.token.access_token)
}
}

const token = yield select((state) => state.authReducer.token.access_token)
const issuer = yield select((state) => state.authReducer.issuer)
const api = new JansConfigApi.OAuthScopesApi(getClient(JansConfigApi, token, issuer))
const api = new JansConfigApi.OAuthScopesApi(
getClient(JansConfigApi, token, issuer)
)
return new ScopeApi(api)
}

Expand Down

0 comments on commit b927d1a

Please sign in to comment.