Validate password on reset
This commit is contained in:
parent
1633284f9d
commit
7b9fadc3ba
|
@ -7,6 +7,7 @@ import {
|
||||||
tenancy,
|
tenancy,
|
||||||
utils as coreUtils,
|
utils as coreUtils,
|
||||||
cache,
|
cache,
|
||||||
|
security,
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import { PlatformLogoutOpts, User } from "@budibase/types"
|
import { PlatformLogoutOpts, User } from "@budibase/types"
|
||||||
import jwt from "jsonwebtoken"
|
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.
|
* Perform the user password update if the provided reset code is valid.
|
||||||
*/
|
*/
|
||||||
export const resetUpdate = async (resetCode: string, password: string) => {
|
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)
|
const { userId } = await cache.passwordReset.getCode(resetCode)
|
||||||
|
|
||||||
let user = await userSdk.db.getUser(userId)
|
let user = await userSdk.db.getUser(userId)
|
||||||
|
|
Loading…
Reference in New Issue