1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

move last sync and generapte password out to other commands

This commit is contained in:
Kyle Spearrin
2018-05-16 13:53:12 -04:00
parent 8a337893da
commit 3a53e2d208
4 changed files with 66 additions and 50 deletions

View File

@@ -0,0 +1,31 @@
import * as program from 'commander';
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
import { Response } from '../models/response';
import { StringResponse } from '../models/response/stringResponse';
export class GenerateCommand {
constructor(private passwordGenerationService: PasswordGenerationService) { }
async run(cmd: program.Command): Promise<Response> {
const options = {
uppercase: cmd.uppercase || false,
lowercase: cmd.lowercase || false,
number: cmd.number || false,
special: cmd.special || false,
length: cmd.length || 14,
};
if (!options.uppercase && !options.lowercase && !options.special && !options.number) {
options.lowercase = true;
options.uppercase = true;
options.number = true;
}
if (options.length < 5) {
options.length = 5;
}
const password = await this.passwordGenerationService.generatePassword(options);
const res = new StringResponse(password);
return Response.success(res);
}
}