You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

142 lines
6.0 KiB

  1. <!--<style>
  2. #passwordGenerator .form-control {
  3. background-color: #31353A;
  4. color: #8F9394;
  5. border: 1px solid #31353A;
  6. }
  7. </style>-->
  8. <template>
  9. <div class="container m-y-3">
  10. <form id="passwordGenerator">
  11. <div class="form-group row">
  12. <label for="email" class="sr-only form-control-label">{{ $t('passwordgenerator.email') }}</label>
  13. <div class="col-sm-3">
  14. <input type="email" class="form-control" id="email"
  15. placeholder="{{ $t('passwordgenerator.email') }}" v-model="email"
  16. v-on:blur="updateMasterPassword">
  17. </div>
  18. <label for="password" class="sr-only form-control-label">{{ $t('passwordgenerator.password') }}</label>
  19. <div class="col-sm-3">
  20. <input type="password" class="form-control" id="password"
  21. placeholder="{{ $t('passwordgenerator.password') }}"
  22. v-model="password" v-on:blur="updateMasterPassword">
  23. </div>
  24. <label for="site" class="sr-only form-control-label">{{ $t('passwordgenerator.site') }}</label>
  25. <div class="col-sm-3">
  26. <input type="text" class="form-control" id="site"
  27. placeholder="{{ $t('passwordgenerator.site_placeholder') }}"
  28. v-model="site">
  29. </div>
  30. <label for="generatedPassword" class="sr-only form-control-label">Generated Password</label>
  31. <div class="col-sm-3">
  32. <div class="input-group">
  33. <input type="text" id="generatedPassword" class="form-control" v-model="generatedPassword">
  34. <span class="input-group-btn">
  35. <button id="copyBtn" data-clipboard-target="#generatedPassword"
  36. class="btn btn-primary" type="button">
  37. {{ $t('passwordgenerator.copy') }}
  38. </button>
  39. </span>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="form-group row">
  44. <div class="col-lg-12">
  45. <div class="checkbox">
  46. <label>
  47. <input type="checkbox" v-model="showAdvancedOptions"> {{
  48. $t('passwordgenerator.advanced_options') }}
  49. </label>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="form-group row" v-if="showAdvancedOptions">
  54. <div class="col-lg-12">
  55. <label class="checkbox-inline">
  56. <input type="checkbox" id="lowercase" value="lowercase" v-model="passwordInfo.settings" checked>
  57. {{ $t('passwordgenerator.lowercase_options') }}
  58. </label>
  59. <label class="checkbox-inline">
  60. <input type="checkbox" id="uppercase" value="uppercase" v-model="passwordInfo.settings" checked>
  61. {{ $t('passwordgenerator.uppercase_options') }}
  62. </label>
  63. <label class="checkbox-inline">
  64. <input type="checkbox" id="numbers" value="numbers" v-model="passwordInfo.settings" checked>
  65. {{ $t('passwordgenerator.numbers_options') }}
  66. </label>
  67. <label class="checkbox-inline">
  68. <input type="checkbox" id="symbols" value="symbols" v-model="passwordInfo.settings" checked>
  69. {{ $t('passwordgenerator.symbols_options') }}
  70. </label>
  71. </div>
  72. </div>
  73. <div class="form-group row" v-if="showAdvancedOptions">
  74. <label for="passwordLength" class="col-xs-2 col-sm-1 form-control-label">{{
  75. $t('passwordgenerator.length') }}</label>
  76. <div class="col-xs-8 col-sm-4">
  77. <input id="passwordLength" type="range" value="12" min="6" max="64" v-model="passwordInfo.length"
  78. class="form-control">
  79. </div>
  80. <div class="col-xs-2 col-sm-1">
  81. {{ passwordInfo.length }}
  82. </div>
  83. </div>
  84. </form>
  85. </div>
  86. </template>
  87. <script>
  88. import Lesspass from '../lesspass'
  89. import Clipboard from 'clipboard';
  90. export default {
  91. data: function () {
  92. return {
  93. email: '',
  94. password: '',
  95. site: '',
  96. passwordInfo: {
  97. counter: 1,
  98. length: 12,
  99. settings: ["lowercase", "uppercase", "numbers", "symbols"]
  100. },
  101. showAdvancedOptions: false
  102. }
  103. },
  104. methods: {
  105. updateMasterPassword: function (event) {
  106. var self = this;
  107. var email = this.email;
  108. var password = this.password;
  109. if (email && password) {
  110. Lesspass.createMasterPassword(email, password).then(function (masterPassword) {
  111. self.$set('masterPassword', masterPassword)
  112. });
  113. }
  114. }
  115. },
  116. computed: {
  117. generatedPassword: function () {
  118. var masterPassword = this.masterPassword;
  119. var site = this.site;
  120. if (masterPassword && site) {
  121. var entry = {
  122. site: site,
  123. password: this.passwordInfo
  124. };
  125. return Lesspass.createPassword(masterPassword, entry);
  126. }
  127. }
  128. }
  129. }
  130. var cb = new Clipboard('#copyBtn');
  131. cb.on('success', function (e) {
  132. e.clearSelection();
  133. });
  134. cb.on('error', function (e) {
  135. });
  136. </script>