Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions apollo/validation.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
import { z } from 'zod'
import type { LoginInput, SignupInput } from './graphql'
import {
LoginInputSchema as InternalLoginInputSchema,
SignupInputSchema as InternalSignupInputSchema,
} from './validation.internal'

type Properties<T> = Required<{
[K in keyof T]: z.ZodType<T[K], any, T[K]>
}>

const passwordSchema = z
.string()
.min(8, { message: 'The password must be at least 8 characters long' })

export const SignupInputSchema: z.ZodObject<Properties<SignupInput>> =
InternalSignupInputSchema.extend({
email: z.string().email(),
password: passwordSchema,
})
export const SignupInputSchema = z.object({
email: z.string().email(),
password: passwordSchema,
})

export const LoginInputSchema: z.ZodObject<Properties<LoginInput>> =
InternalLoginInputSchema.extend({
email: z.string().email(),
password: passwordSchema,
})
export const LoginInputSchema = z.object({
email: z.string().email(),
password: passwordSchema,
})
3 changes: 2 additions & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export function constructConfig() {
databaseUrl: 'postgresql://localhost/jabref',
emailClient: undefined,
session: {
password: 'session_password', // It's too short by design, so that it's not used in production
password:
'somerandompasswordNxFHaqCSPpBe6n5kRz2dru4hJ7K9bjgEtmsV8QAT3MDXcUfWGL', // 32+ chars required for iron-webcrypto
},
githubRepoToken: undefined,
public: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"vee-validate": "4.15.0",
"vue": "3.5.21",
"vue-router": "4.5.1",
"zod": "3.24.1"
"zod": "4.1.5"
},
"devDependencies": {
"@adonisjs/hash": "9.1.1",
Expand All @@ -99,7 +99,7 @@
"@graphql-typed-document-node/core": "3.2.0",
"@nuxt/content": "3.6.3",
"@nuxt/eslint": "1.5.2",
"@nuxt/icon": "1.15.0",
"@nuxt/icon": "2.0.0",
"@nuxt/kit": "4.0.1",
"@nuxt/test-utils": "3.19.2",
"@nuxtjs/seo": "3.1.0",
Expand Down
19 changes: 17 additions & 2 deletions pages/user/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
:validation-status="errors.email ? 'error' : undefined"
>
<n-input
v-model:value="email"
v-model:value="emailValue"
v-bind="emailAttrs"
v-focus
/>
Expand All @@ -46,7 +46,7 @@
:validation-status="errors.password ? 'error' : undefined"
>
<n-input
v-model:value="password"
v-model:value="passwordValue"
v-bind="passwordAttrs"
type="password"
show-password-on="mousedown"
Expand Down Expand Up @@ -109,6 +109,21 @@ const { handleSubmit, errors, defineField } = useForm({
const [email, emailAttrs] = defineField('email')
const [password, passwordAttrs] = defineField('password')

// Explicitly cast to string for naive-ui compatibility
const emailValue = computed({
get: () => email.value as string,
set: (value) => {
email.value = value
},
})

const passwordValue = computed({
get: () => password.value as string,
set: (value) => {
password.value = value
},
})

const otherError = ref('')

const { mutate: loginUser, error: graphqlError } = useMutation(
Expand Down
Loading