Skip to content

Commit

Permalink
fix(admin-ui): code review changes
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 6, 2023
1 parent 210a29b commit d825300
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
10 changes: 4 additions & 6 deletions admin-ui/app/redux/sagas/AttributesSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,25 @@ import {
import AttributeApi from '../api/AttributeApi'
import { getClient } from 'Redux/api/base'
import { initAudit } from 'Redux/sagas/SagaUtils'
import { ATTRIBUTES_TAGS } from 'Utils/PermChecker'
import { ATTRIBUTES_TAG } from 'Utils/PermChecker'

const PERSON_SCHEMA = 'person schema'

const JansConfigApi = require('jans_config_api')

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

if (!savedToken) {
if (!token) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
const apiToken = yield call(fetchApiAccessToken, jwt, ATTRIBUTES_TAGS)
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)
}
} else {
token = savedToken;
}


Expand Down
4 changes: 2 additions & 2 deletions admin-ui/app/utils/PermChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export const AGAMA_DELETE = BASE_URL + '/config/agama.delete'
export const SESSION_READ = BASE_URL + '/jans-auth-server/session.readonly'
export const SESSION_DELETE = BASE_URL + '/jans-auth-server/session.delete'

export const SCOPE_TAGS = ['scopes']
export const ATTRIBUTES_TAGS = ['attributes']
export const SCOPE_TAG = 'scopes'
export const ATTRIBUTES_TAG = 'attributes'

export const hasPermission = (scopes, scope) => {
let available = false
Expand Down
10 changes: 4 additions & 6 deletions admin-ui/plugins/auth-server/redux/sagas/OAuthScopeSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,21 @@ import {
getClientScopesResponse,
setAccessToken
} from '../features/scopeSlice'
import { SCOPE_TAGS } from 'Utils/PermChecker'
import { SCOPE_TAG } from 'Utils/PermChecker'

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

if (!savedToken) {
if (!token) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
const apiToken = yield call(fetchApiAccessToken, jwt, SCOPE_TAGS)
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)
}
} else {
token = savedToken;
}

const issuer = yield select((state) => state.authReducer.issuer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const UserDetailViewPage = ({ row }) => {
: ''
}
isDirect={true}
value={valueToShow}
value={typeof valueToShow === "boolean" ? JSON.stringify(valueToShow) : valueToShow}
/>
</Col>
) : null}
Expand Down

0 comments on commit d825300

Please sign in to comment.