feat: Rollback signup on error, cleanup userDto and comment createdBy
This commit is contained in:
@@ -3,15 +3,14 @@ import type { CreateCommentDto, CommentDto } from '~/.api-client'
|
||||
export function useComment(applicationFormId: string) {
|
||||
const commentStore = useCommentStore()
|
||||
const { createComment, updateComment } = commentStore
|
||||
const { userDto } = useAuth()
|
||||
const { user } = useAuth()
|
||||
const isEditingComment = ref(false)
|
||||
const currentEditedComment = ref<CommentDto | null>(null)
|
||||
const commentTextAreaValue = ref('')
|
||||
|
||||
async function submitComment(formElementId: string) {
|
||||
const newCommentDto: CreateCommentDto = {
|
||||
message: commentTextAreaValue.value,
|
||||
createdBy: userDto.value
|
||||
message: commentTextAreaValue.value
|
||||
}
|
||||
try {
|
||||
await createComment(applicationFormId, formElementId, newCommentDto)
|
||||
@@ -51,7 +50,7 @@ export function useComment(applicationFormId: string) {
|
||||
}
|
||||
|
||||
function isCommentByUser(comment: CommentDto) {
|
||||
return comment.createdBy.id === userDto.value.id
|
||||
return comment.createdBy.id === user.value?.id
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -50,6 +50,11 @@ export function useAuth() {
|
||||
fetchOptions: {
|
||||
headers
|
||||
},
|
||||
user: {
|
||||
deleteUser: {
|
||||
enabled: true
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
organizationClient({
|
||||
// Pass the same access control instance and roles to client
|
||||
@@ -158,25 +163,19 @@ export function useAuth() {
|
||||
return res
|
||||
}
|
||||
|
||||
const userDto = computed<UserDto>(() => ({
|
||||
id: user.value?.id ?? '',
|
||||
name: user.value?.name ?? 'Unknown'
|
||||
}))
|
||||
|
||||
return {
|
||||
session,
|
||||
user,
|
||||
userDto,
|
||||
loggedIn: computed(() => !!session.value),
|
||||
signIn: client.signIn,
|
||||
signUp: client.signUp,
|
||||
deleteUser: client.deleteUser,
|
||||
signOut,
|
||||
organization: client.organization,
|
||||
organizations,
|
||||
selectedOrganization,
|
||||
options,
|
||||
fetchSession,
|
||||
fetchJwtAndOrganizations,
|
||||
client,
|
||||
jwt,
|
||||
isPublicRoute,
|
||||
|
||||
@@ -15,7 +15,7 @@ export function useBetterAuth() {
|
||||
return Promise.reject()
|
||||
}
|
||||
|
||||
await organization.create(
|
||||
return await organization.create(
|
||||
{ name, slug, logo },
|
||||
{
|
||||
onSuccess: () => {
|
||||
|
||||
Reference in New Issue
Block a user