本文整理匯總了TypeScript中klay-db/lib/password.createNewPasswordHashSalt函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createNewPasswordHashSalt函數的具體用法?TypeScript createNewPasswordHashSalt怎麽用?TypeScript createNewPasswordHashSalt使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了createNewPasswordHashSalt函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should fail when not given current password', async () => {
const hashedPassword = await createNewPasswordHashSalt('password', passwordOptions)
const middleware = createMiddleware({kiln, databaseExtensionName: 'db'})
req.grants.userContext.password = hashedPassword
const {next, err} = await utils.runMiddleware([middleware], req)
expect(next).toHaveBeenCalled()
expect(err.message).toMatchSnapshot()
})
示例2: it
it('should set cookie', async () => {
const handler = createHandler({secret: 'secret', kiln, databaseExtensionName: 'db'})
const body = {username: 'klay', password: 'rocko'}
const hashedPassword = createNewPasswordHashSalt('rocko', passwordModel.spec.db.password)
const cookie = jest.fn()
jest.spyOn(executor, 'findOne').mockReturnValue({password: hashedPassword})
await handler({body}, {json, cookie}, next)
expect(next).not.toHaveBeenCalled()
expect(cookie).toHaveBeenCalled()
})