Skip to content

Commit

Permalink
fix: public secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarneo committed Nov 1, 2024
1 parent fdfde66 commit 9f24c60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions client/routes/secret/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ const Secret = () => {
setError(json.error);
} else {
try {
const text = decrypt(json.secret, decryptionKey + password);
const text = json.isPublic
? json.secret
: decrypt(json.secret, decryptionKey + password);

setSecret(text);

if (json.title) {
setTitle(decrypt(json.title, decryptionKey + password));
setTitle(
json.isPublic ? json.title : decrypt(json.title, decryptionKey + password)
);
}

if (json.files) {
Expand Down
8 changes: 6 additions & 2 deletions client/stores/secretStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ const useSecretStore = create((set, get) => ({
const password = state.enablePassword ? state.formData.password : '';
const key = generateKey(password);

const encryptedText = await encrypt(state.formData.text, key + password);
const encryptedTitle = await encrypt(state.formData.title, key + password);
const encryptedText = state.isPublic
? state.formData.text
: await encrypt(state.formData.text, key + password);
const encryptedTitle = state.isPublic
? state.formData.title
: await encrypt(state.formData.title, key + password);

const encryptedFiles = [];
if (state.formData.files.length > 0) {
Expand Down

0 comments on commit 9f24c60

Please sign in to comment.