1
0
Fork 0
mirror of synced 2024-07-04 22:11:23 +12:00

Validate password on reset

This commit is contained in:
Adria Navarro 2024-01-02 13:05:48 +01:00
parent 1633284f9d
commit 7b9fadc3ba

View file

@ -7,6 +7,7 @@ import {
tenancy,
utils as coreUtils,
cache,
security,
} from "@budibase/backend-core"
import { PlatformLogoutOpts, User } from "@budibase/types"
import jwt from "jsonwebtoken"
@ -73,6 +74,11 @@ export const reset = async (email: string) => {
* Perform the user password update if the provided reset code is valid.
*/
export const resetUpdate = async (resetCode: string, password: string) => {
const validation = security.validatePassword(password)
if (!validation.valid) {
throw new HTTPError(validation.error, 400)
}
const { userId } = await cache.passwordReset.getCode(resetCode)
let user = await userSdk.db.getUser(userId)