Skip to content

Commit

Permalink
fix: hide password answer in sessionStore (AnWeber/httpbook#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnWeber committed Jan 26, 2024
1 parent 647f552 commit 0fecef6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [unreleased]

### Fix
- hide password answer in sessionStore (AnWeber/httpbook#111)

## [6.11.1] (2023-01-14)

### Fix
Expand Down
11 changes: 6 additions & 5 deletions src/plugins/core/replacer/showInputBoxVariableReplacer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function showInputBoxVariableReplacer(
): Promise<unknown> {
return utils.parseHandlebarsString(text, async (variable: string) => {
const inputRegex =
/^\$(?<type>(prompt|input|password))(?<save>-askonce)?\s*(?<placeholder>[^$]*)(\$value:\s*(?<value>.*))?\s*$/u;
/^\$(?<type>(prompt|input|password))(?<askonce>-askonce)?\s*(?<placeholder>[^$]*)(\$value:\s*(?<value>.*))?\s*$/u;
const matchInput = inputRegex.exec(variable);

if (matchInput?.groups?.placeholder) {
Expand All @@ -27,7 +27,7 @@ export async function showInputBoxVariableReplacer(

const session = userSessionStore.getUserSession<InputSession>(id);

if (matchInput.groups.save) {
if (matchInput.groups.askonce) {
if (variables?.[placeholder] !== undefined) {
return variables[placeholder];
}
Expand All @@ -36,21 +36,22 @@ export async function showInputBoxVariableReplacer(
}
}

const isPassword = inputType === 'password';
const answer = await userInteractionProvider.showInputPrompt(
placeholder,
session?.answer || matchInput.groups.value,
inputType === 'password'
isPassword
);
if (answer !== undefined) {
userSessionStore.setUserSession({
id,
title: `${placeholder}=${answer}`,
title: isPassword ? placeholder : `${placeholder}=${answer}`,
description: `Cache for ${inputType}`,
type: 'input',
details: {
placeholder,
inputType,
answer: inputType !== 'password' ? answer : undefined,
answer: isPassword ? undefined : answer,
},
answer,
});
Expand Down

0 comments on commit 0fecef6

Please sign in to comment.