diff --git a/src/server/lib/updatePassword.ts b/src/server/lib/updatePassword.ts index 026d21b..adf08ef 100644 --- a/src/server/lib/updatePassword.ts +++ b/src/server/lib/updatePassword.ts @@ -39,18 +39,18 @@ async function getUserDN(username: string): Promise { export async function updatePassword({ username, - password, + currentPassword, newPassword }: { username: string - password: string + currentPassword: string newPassword: string }): Promise<'SUCCESS' | 'FAIL'> { try { const userDN = await getUserDN(username) // Check if user can bind with current password - await ldapClient.bind(userDN, password) + await ldapClient.bind(userDN, currentPassword) await ldapClient.unbind() // Bind with admin user to change password @@ -68,7 +68,7 @@ export async function updatePassword({ // operation: 'delete', // modification: new Attribute({ // type: 'unicodePwd', - // values: [encodePassword(password)] + // values: [encodePassword(currentPassword)] // }) // }), diff --git a/src/server/trpc.ts b/src/server/trpc.ts index 46bffcc..1ece952 100644 --- a/src/server/trpc.ts +++ b/src/server/trpc.ts @@ -16,15 +16,16 @@ export const appRouter = router({ updatePassword: input( z.object({ username: z.string(), - password: z.string(), + currentPassword: z.string(), newPassword: z.string().min(8) }) ).mutation(async ({ input }) => { - const { username, password, newPassword } = input + const { username, currentPassword, newPassword } = input + try { await updatePassword({ username, - password, + currentPassword, newPassword }) diff --git a/src/web/components/MainForm.vue b/src/web/components/MainForm.vue index 3b69cfb..e281cb8 100644 --- a/src/web/components/MainForm.vue +++ b/src/web/components/MainForm.vue @@ -1,6 +1,6 @@ diff --git a/src/web/components/PasswordChecker.vue b/src/web/components/PasswordChecker.vue index b3ebde9..239af2d 100644 --- a/src/web/components/PasswordChecker.vue +++ b/src/web/components/PasswordChecker.vue @@ -1,15 +1,15 @@ @@ -44,3 +44,9 @@ const alerts = [ } ] + + diff --git a/src/web/views/Home.vue b/src/web/views/Home.vue index af101e4..05c48fe 100644 --- a/src/web/views/Home.vue +++ b/src/web/views/Home.vue @@ -1,19 +1,23 @@