Skip to content

Commit

Permalink
frontend: fix login redirect and user validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Synar committed Jul 3, 2024
1 parent bdb907e commit 7f1b7e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion frontend/pages/admin/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ const awaiting_auth_response: Ref<boolean> = ref(false)
const redirect_query_param = useRoute().query.redirect
let redirectUrl = '/admin/home'
// type checking of the query parameter to correspond to the signature of navigateTo
if (typeof redirect_query_param === 'string') {
// matching to keep only internal urls
const match = redirect_query_param.match('/admin*')
const match = redirect_query_param.match(/\/admin\/.+/)
if (match) {
redirectUrl = match[0]
}
Expand Down
12 changes: 5 additions & 7 deletions frontend/pages/admin/users/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/>

<div
:hidden="!editPassword && !isNew"
:hidden="!editPassword"
class="flex-col gap-4"
:class="{ flex: isNew || editPassword }"
>
Expand All @@ -34,23 +34,21 @@
<Password
v-model="newPassword"
input-id="password"
:disabled="!isNew && !editPassword"
toggle-mask
class="-mt-2"
input-class="w-full"
:invalid="editPassword && (newPassword!=newPasswordConfirm || !newPassword)"
:invalid="editPassword && !isValidText(newPassword)"
/>
<label for="passwordConfirm">
Confirmer le nouveau mot de passe :
</label>
<Password
v-model="newPasswordConfirm"
input-id="passwordConfirm"
:disabled="!isNew && !editPassword"
toggle-mask
class="-mt-2"
input-class="w-full"
:invalid="editPassword && (newPassword!=newPasswordConfirm || !newPassword)"
:invalid="editPassword && newPassword!=newPasswordConfirm"
/>
</div>

Expand Down Expand Up @@ -90,7 +88,7 @@ const user = ref(isNew
: await state.client.getUser(userId),
)
const editPassword = ref(false)
const editPassword = ref(isNew)
const newPassword = ref('')
const newPasswordConfirm = ref('')
Expand All @@ -103,7 +101,7 @@ definePageMeta({
function isDisabled() {
return processingRequest.value
|| (editPassword.value && (newPassword.value != newPasswordConfirm.value || !!isValidText(newPassword.value)))
|| (editPassword.value && (newPassword.value != newPasswordConfirm.value || !isValidText(newPassword.value)))
|| !isValidText(user.value.name)
}
Expand Down
7 changes: 4 additions & 3 deletions frontend/pages/admin/users/self.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
toggle-mask
class=" -mt-2"
input-class="w-full"
:invalid="editPassword && (newPassword!=newPasswordConfirm || !newPassword)"
:invalid="editPassword && !isValidText(newPassword)"
/>
<label
for="passwordConfirm"
Expand All @@ -46,7 +46,7 @@
toggle-mask
class="-mt-2"
input-class="w-full"
:invalid="editPassword && (newPassword!=newPasswordConfirm || !newPassword)"
:invalid="editPassword && newPassword!=newPasswordConfirm"
/>
</div>

Expand All @@ -66,7 +66,7 @@
label="Sauvegarder"
type="submit"
:loading="processingRequest"
:disabled="processingRequest || (newPassword!=newPasswordConfirm || !newPassword)"
:disabled="processingRequest || (newPassword!=newPasswordConfirm || !isValidText(newPassword))"
/>
</span>
</form>
Expand All @@ -75,6 +75,7 @@
<script setup lang="ts">
import type { InitAdminLayout } from '~/layouts/admin-ui.vue'
import state from '~/lib/admin-state'
import { isValidText } from '~/lib/validation'
const editPassword = ref(false)
const newPassword = ref('')
Expand Down

0 comments on commit 7f1b7e6

Please sign in to comment.