-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ Create user from admin panel * 🚧 Store registration preference * ⬆️ Upgrade packages * 🚧 Disable search on client side * 🗑️ Remove usage of global * ✨ Implement option to require login everywhere
- Loading branch information
Showing
49 changed files
with
1,695 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<script setup lang="ts"> | ||
import { useMessagesStore } from '@/store/messages'; | ||
const username = ref(''); | ||
const password = ref(''); | ||
const { createUser } = useCreateUser(); | ||
const messagesStore = useMessagesStore(); | ||
const createUserAdmin = async () => { | ||
if (username.value && password.value) { | ||
const createdUser = await createUser({ | ||
username: username.value, | ||
password: password.value | ||
}) | ||
.then( | ||
res => res, | ||
reason => { | ||
throw reason; | ||
} | ||
) | ||
.catch(err => { | ||
messagesStore.createMessage({ | ||
type: 'error', | ||
title: 'Error creating user', | ||
message: err?.data?.message ?? 'Unknown error' | ||
}); | ||
}); | ||
username.value = ''; | ||
password.value = ''; | ||
if (createdUser) { | ||
messagesStore.createMessage({ | ||
type: 'info', | ||
title: 'User created', | ||
message: `User ${createdUser.username} created` | ||
}); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<template> | ||
<SectionSubtitle title="Create new user" /> | ||
|
||
<form id="create-user" class="create-user-form" method="post" @submit.prevent="createUserAdmin"> | ||
<FormInput id="username" v-model="username" type="username" label="Username" /> | ||
<FormInput id="password" v-model="password" type="password" label="Password" /> | ||
<FormSubmitButton :label="'Create user'" /> | ||
</form> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.create-user-form { | ||
display: flex; | ||
flex-direction: row; | ||
@media screen and (max-width: $mobile-width) { | ||
flex-direction: column; | ||
} | ||
:deep(.submit-button) { | ||
width: auto; | ||
padding: 5px 15px; | ||
margin: 16px 0; | ||
} | ||
:deep(.form-input > .input) { | ||
margin-left: 0; | ||
margin-right: 10px; | ||
width: calc(100% - 10px); | ||
@media screen and (max-width: $mobile-width) { | ||
margin-right: 0; | ||
width: 100%; | ||
} | ||
} | ||
:deep(.form-input > .input-label) { | ||
left: 14px; | ||
} | ||
:deep(.form-input > .form-input-icon) { | ||
right: 25px; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<script setup lang="ts"> | ||
import { useMessagesStore } from '~/store/messages'; | ||
const { apiUrl } = useApiUrl(); | ||
const { vtFetch } = useVtFetch(); | ||
const messagesStore = useMessagesStore(); | ||
const { data, refresh } = useGetServerSettings(); | ||
const onRegistrationEnabledChange = async (value: boolean) => { | ||
await vtFetch(`${apiUrl.value}admin/server-settings`, { | ||
method: 'POST', | ||
body: { | ||
registrationEnabled: value | ||
} | ||
}); | ||
await refresh(); | ||
await nextTick(); | ||
messagesStore.createMessage({ | ||
type: 'info', | ||
title: 'Server settings updated', | ||
message: `Public registration ${ | ||
value ? 'enabled' : 'disabled' | ||
}. Restart the server for the changes to take effect.` | ||
}); | ||
}; | ||
const onRequireLoginEverywhereChange = async (value: boolean) => { | ||
await vtFetch(`${apiUrl.value}admin/server-settings`, { | ||
method: 'POST', | ||
body: { | ||
requireLoginEverywhere: value | ||
} | ||
}); | ||
await refresh(); | ||
await nextTick(); | ||
messagesStore.createMessage({ | ||
type: 'info', | ||
title: 'Server settings updated', | ||
message: `Require login everywhere ${ | ||
value ? 'enabled' : 'disabled' | ||
}. Restart the server for the changes to take effect.` | ||
}); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div v-if="data" class="user-management"> | ||
<ButtonsSwitchButton | ||
label="Enable public registration (restart required)" | ||
:value="data.registrationEnabled" | ||
small-label="Anyone can create an account" | ||
small-label-negative="Accounts can only be created by the admin" | ||
@valuechange="onRegistrationEnabledChange" | ||
/> | ||
<ButtonsSwitchButton | ||
label="Require login everywhere (restart required)" | ||
:value="data.requireLoginEverywhere" | ||
small-label="Users must be logged in to access the site" | ||
small-label-negative="Users can access the site without being logged in" | ||
@valuechange="onRequireLoginEverywhereChange" | ||
/> | ||
</div> | ||
<Spinner v-if="!data" /> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.user-management { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
margin: 0 0 15px 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script setup lang="ts"></script> | ||
|
||
<template> | ||
<div class="admin-users"> | ||
<SectionSubtitle title="Options" /> | ||
<AdminUserManagement /> | ||
<AdminCreateUser /> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.admin-users { | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const useRegistrationEnabled = () => { | ||
const config = useRuntimeConfig(); | ||
return { | ||
registrationEnabled: config.public.registrationEnabled | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.