Skip to content

Commit

Permalink
fix: do not display create initial user with ldap enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
bayang committed Jun 2, 2022
1 parent dd77866 commit bb0a89c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
17 changes: 9 additions & 8 deletions src/jelu-ui/src/components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const progress: Ref<boolean> = ref(false)
useTitle('Jelu | Login')
watch(form, (oldVal, newVal) => {
if (isInitialSetup.value) {
if (displayInitialSetup.value) {
validateInput()
}
else {
Expand All @@ -37,9 +37,10 @@ watch(loginValidation, (oldVal, newVal) => {
validateInput()
})
const isInitialSetup = computed(() => {
return store.getters.getInitialSetup
})
const displayInitialSetup = computed(() => {
return store.getters.getDisplayInitialSetup
})
const logUser = async () => {
if (validateInputLight()) {
progress.value = true
Expand Down Expand Up @@ -107,7 +108,7 @@ onMounted(() => {
})
const submit = () => {
if (isInitialSetup.value) {
if (displayInitialSetup.value) {
createInitialUser()
}
else {
Expand All @@ -133,7 +134,7 @@ const submit = () => {
/>
</div>
<div
v-if="isInitialSetup"
v-if="displayInitialSetup"
class="field"
>
<label class="label">
Expand Down Expand Up @@ -162,7 +163,7 @@ const submit = () => {
/>
</div>
<div
v-if="isInitialSetup"
v-if="displayInitialSetup"
class="field"
>
<label class="label">
Expand All @@ -180,7 +181,7 @@ const submit = () => {
</div>
<div class="field">
<p
v-if="isInitialSetup"
v-if="displayInitialSetup"
class="control"
>
<button
Expand Down
8 changes: 7 additions & 1 deletion src/jelu-ui/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ const store = createStore<State>({
},
},
actions: {
async setupStatus({commit, state}) {
async setupStatus({dispatch, commit, state}) {
commit('initialSetup', await dataService.setupStatus())
if (state.isInitialSetup) {
dispatch('getServerSettings')
}
},
async getUser({commit}) {
try {
Expand Down Expand Up @@ -136,6 +139,9 @@ const store = createStore<State>({
},
getInitialSetup(state): boolean {
return state.isInitialSetup
},
getDisplayInitialSetup(state, getters): boolean {
return (getters.getInitialSetup && !getters.getLdapEnabled)
}
},
plugins : [createLogger()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SecurityConfig(
}
.authorizeRequests {
it.antMatchers(
"/api/v1/token", "/api/v1/setup/status"
"/api/v1/token", "/api/v1/setup/status", "/api/v1/server-settings"
).permitAll()
it.mvcMatchers(HttpMethod.POST, "/api/v1/users").hasAnyRole("ADMIN", "INITIAL_SETUP")
it.mvcMatchers(HttpMethod.PUT, "/api/v1/users/**").hasAnyRole("USER")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ class ServerSettingsController(
@GetMapping(path = ["/server-settings"])
fun getServerSettings(): ServerSettingsDto {
return if (properties.metadata.calibre.path.isNullOrEmpty()) {
ServerSettingsDto(metadataFetchEnabled = false, metadataFetchCalibreEnabled = false, buildProperties.version)
ServerSettingsDto(
metadataFetchEnabled = false,
metadataFetchCalibreEnabled = false,
buildProperties.version,
ldapEnabled = properties.auth.ldap.enabled
)
} else {
ServerSettingsDto(metadataFetchEnabled = true, metadataFetchCalibreEnabled = true, buildProperties.version)
ServerSettingsDto(
metadataFetchEnabled = true,
metadataFetchCalibreEnabled = true,
buildProperties.version,
ldapEnabled = properties.auth.ldap.enabled
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ data class ServerSettingsDto(
* Is the calibre metadata provider activated
*/
val metadataFetchCalibreEnabled: Boolean,
val appVersion: String
val appVersion: String,
val ldapEnabled: Boolean
)

0 comments on commit bb0a89c

Please sign in to comment.