40 lines
663 B
TypeScript
40 lines
663 B
TypeScript
|
|
namespace _zeitbild.service.auth_internal
|
|
{
|
|
|
|
/**
|
|
*/
|
|
export function set(
|
|
name : string,
|
|
password : string
|
|
) : Promise<void>
|
|
{
|
|
return (
|
|
lib_plankton.bcrypt.compute(password)
|
|
.then<void>(
|
|
(password_image) => _zeitbild.repository.auth_internal.write(name, password_image)
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
*/
|
|
export async function check(
|
|
name : string,
|
|
password : string
|
|
) : Promise<boolean>
|
|
{
|
|
try {
|
|
const password_image : string = await _zeitbild.repository.auth_internal.read(name);
|
|
return lib_plankton.bcrypt.compare(
|
|
password_image,
|
|
password
|
|
);
|
|
}
|
|
catch (error) {
|
|
return Promise.resolve<boolean>(false);
|
|
}
|
|
}
|
|
|
|
}
|