Fix tests
This commit is contained in:
parent
1a0361e33f
commit
874c3f9dd4
|
@ -229,7 +229,7 @@ describe("/api/global/auth", () => {
|
|||
)
|
||||
|
||||
expect(res.body).toEqual({
|
||||
message: "Cannot reset password.",
|
||||
message: "Password change is disabled for this user",
|
||||
status: 400,
|
||||
})
|
||||
}
|
||||
|
@ -261,8 +261,13 @@ describe("/api/global/auth", () => {
|
|||
)
|
||||
|
||||
// convert to account owner now that password has been requested
|
||||
const account = structures.accounts.ssoAccount() as CloudAccount
|
||||
mocks.accounts.getAccount.mockReturnValueOnce(
|
||||
const account: CloudAccount = {
|
||||
...structures.accounts.ssoAccount(),
|
||||
budibaseUserId: user._id!,
|
||||
email: user.email,
|
||||
tenantId: config.getTenantId(),
|
||||
}
|
||||
mocks.accounts.getAccountByTenantId.mockReturnValueOnce(
|
||||
Promise.resolve(account)
|
||||
)
|
||||
|
||||
|
|
|
@ -74,14 +74,14 @@ 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 { userId } = await cache.passwordReset.getCode(resetCode)
|
||||
let user = await userSdk.db.getUser(userId)
|
||||
|
||||
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)
|
||||
user.password = password
|
||||
user = await userSdk.db.save(user)
|
||||
|
||||
|
|
Loading…
Reference in New Issue