mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-13 00:51:45 +01:00
return new/edited object for create/edit
This commit is contained in:
parent
79ef15c48f
commit
2ff868aeb3
@ -8,7 +8,8 @@ import { FolderService } from 'jslib/abstractions/folder.service';
|
||||
import { TokenService } from 'jslib/abstractions/token.service';
|
||||
|
||||
import { Response } from '../models/response';
|
||||
import { StringResponse } from '../models/response/stringResponse';
|
||||
import { CipherResponse } from '../models/response/cipherResponse';
|
||||
import { FolderResponse } from '../models/response/folderResponse';
|
||||
|
||||
import { Cipher } from '../models/cipher';
|
||||
import { Folder } from '../models/folder';
|
||||
@ -54,7 +55,10 @@ export class CreateCommand {
|
||||
const cipher = await this.cipherService.encrypt(Cipher.toView(req));
|
||||
try {
|
||||
await this.cipherService.saveWithServer(cipher);
|
||||
return Response.success(new StringResponse(cipher.id));
|
||||
const newCipher = await this.cipherService.get(cipher.id);
|
||||
const decCipher = await newCipher.decrypt();
|
||||
const res = new CipherResponse(decCipher);
|
||||
return Response.success(res);
|
||||
} catch (e) {
|
||||
return Response.error(e);
|
||||
}
|
||||
@ -92,7 +96,10 @@ export class CreateCommand {
|
||||
const fileBuf = fs.readFileSync(filePath);
|
||||
await this.cipherService.saveAttachmentRawWithServer(cipher, path.basename(filePath),
|
||||
new Uint8Array(fileBuf).buffer);
|
||||
return Response.success();
|
||||
const updatedCipher = await this.cipherService.get(cipher.id);
|
||||
const decCipher = await updatedCipher.decrypt();
|
||||
const res = new CipherResponse(decCipher);
|
||||
return Response.success(res);
|
||||
} catch (e) {
|
||||
return Response.error(e);
|
||||
}
|
||||
@ -102,7 +109,10 @@ export class CreateCommand {
|
||||
const folder = await this.folderService.encrypt(Folder.toView(req));
|
||||
try {
|
||||
await this.folderService.saveWithServer(folder);
|
||||
return Response.success(new StringResponse(folder.id));
|
||||
const newFolder = await this.folderService.get(folder.id);
|
||||
const decFolder = await newFolder.decrypt();
|
||||
const res = new FolderResponse(decFolder);
|
||||
return Response.success(res);
|
||||
} catch (e) {
|
||||
return Response.error(e);
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||
import { FolderService } from 'jslib/services/folder.service';
|
||||
|
||||
import { Response } from '../models/response';
|
||||
import { CipherResponse } from '../models/response/cipherResponse';
|
||||
import { FolderResponse } from '../models/response/folderResponse';
|
||||
|
||||
import { Cipher } from '../models/cipher';
|
||||
import { Folder } from '../models/folder';
|
||||
@ -55,7 +57,10 @@ export class EditCommand {
|
||||
const encCipher = await this.cipherService.encrypt(cipherView);
|
||||
try {
|
||||
await this.cipherService.saveWithServer(encCipher);
|
||||
return Response.success();
|
||||
const updatedCipher = await this.cipherService.get(cipher.id);
|
||||
const decCipher = await updatedCipher.decrypt();
|
||||
const res = new CipherResponse(decCipher);
|
||||
return Response.success(res);
|
||||
} catch (e) {
|
||||
return Response.error(e);
|
||||
}
|
||||
@ -72,7 +77,10 @@ export class EditCommand {
|
||||
const encFolder = await this.folderService.encrypt(folderView);
|
||||
try {
|
||||
await this.folderService.saveWithServer(encFolder);
|
||||
return Response.success();
|
||||
const updatedFolder = await this.folderService.get(folder.id);
|
||||
const decFolder = await updatedFolder.decrypt();
|
||||
const res = new FolderResponse(decFolder);
|
||||
return Response.success(res);
|
||||
} catch (e) {
|
||||
return Response.error(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user