logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

mfa.vue (4507B)


  1. <template>
  2. <div
  3. v-if="readyInit && settings.available"
  4. class="setting-item mfa-settings"
  5. >
  6. <div class="mfa-heading">
  7. <h2>{{ $t('settings.mfa.title') }}</h2>
  8. </div>
  9. <div>
  10. <div
  11. v-if="!setupInProgress"
  12. class="setting-item"
  13. >
  14. <!-- Enabled methods -->
  15. <h3>{{ $t('settings.mfa.authentication_methods') }}</h3>
  16. <totp-item
  17. :settings="settings"
  18. @deactivate="fetchSettings"
  19. @activate="activateOTP"
  20. />
  21. <br>
  22. <div v-if="settings.enabled">
  23. <!-- backup codes block-->
  24. <recovery-codes
  25. v-if="!confirmNewBackupCodes"
  26. :backup-codes="backupCodes"
  27. />
  28. <button
  29. v-if="!confirmNewBackupCodes"
  30. class="btn button-default"
  31. @click="getBackupCodes"
  32. >
  33. {{ $t('settings.mfa.generate_new_recovery_codes') }}
  34. </button>
  35. <div v-if="confirmNewBackupCodes">
  36. <confirm
  37. :disabled="backupCodes.inProgress"
  38. @confirm="confirmBackupCodes"
  39. @cancel="cancelBackupCodes"
  40. >
  41. <p class="warning">
  42. {{ $t('settings.mfa.warning_of_generate_new_codes') }}
  43. </p>
  44. </confirm>
  45. </div>
  46. </div>
  47. </div>
  48. <div v-if="setupInProgress">
  49. <!-- setup block-->
  50. <h3>{{ $t('settings.mfa.setup_otp') }}</h3>
  51. <recovery-codes
  52. v-if="!setupOTPInProgress"
  53. :backup-codes="backupCodes"
  54. />
  55. <button
  56. v-if="canSetupOTP"
  57. class="btn button-default"
  58. @click="cancelSetup"
  59. >
  60. {{ $t('general.cancel') }}
  61. </button>
  62. <button
  63. v-if="canSetupOTP"
  64. class="btn button-default"
  65. @click="setupOTP"
  66. >
  67. {{ $t('settings.mfa.setup_otp') }}
  68. </button>
  69. <template v-if="setupOTPInProgress">
  70. <i v-if="prepareOTP">{{ $t('settings.mfa.wait_pre_setup_otp') }}</i>
  71. <div v-if="confirmOTP">
  72. <div class="setup-otp">
  73. <div class="qr-code">
  74. <h4>{{ $t('settings.mfa.scan.title') }}</h4>
  75. <p>{{ $t('settings.mfa.scan.desc') }}</p>
  76. <qrcode
  77. :value="otpSettings.provisioning_uri"
  78. :options="{ width: 200 }"
  79. />
  80. <p>
  81. {{ $t('settings.mfa.scan.secret_code') }}:
  82. {{ otpSettings.key }}
  83. </p>
  84. </div>
  85. <div class="verify">
  86. <h4>{{ $t('general.verify') }}</h4>
  87. <p>{{ $t('settings.mfa.verify.desc') }}</p>
  88. <input
  89. v-model="otpConfirmToken"
  90. type="text"
  91. class="input"
  92. >
  93. <p>{{ $t('settings.enter_current_password_to_confirm') }}:</p>
  94. <input
  95. v-model="currentPassword"
  96. type="password"
  97. class="input"
  98. >
  99. <div class="confirm-otp-actions">
  100. <button
  101. class="btn button-default"
  102. @click="doConfirmOTP"
  103. >
  104. {{ $t('settings.mfa.confirm_and_enable') }}
  105. </button>
  106. <button
  107. class="btn button-default"
  108. @click="cancelSetup"
  109. >
  110. {{ $t('general.cancel') }}
  111. </button>
  112. </div>
  113. <div
  114. v-if="error"
  115. class="alert error"
  116. >
  117. {{ error }}
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </template>
  123. </div>
  124. </div>
  125. </div>
  126. </template>
  127. <script src="./mfa.js"></script>
  128. <style lang="scss">
  129. .mfa-settings {
  130. .mfa-heading,
  131. .method-item {
  132. display: flex;
  133. flex-wrap: wrap;
  134. justify-content: space-between;
  135. align-items: baseline;
  136. }
  137. .warning {
  138. color: var(--cOrange);
  139. }
  140. .setup-otp {
  141. display: flex;
  142. justify-content: center;
  143. flex-wrap: wrap;
  144. .qr-code {
  145. flex: 1;
  146. padding-right: 10px;
  147. }
  148. .verify { flex: 1; }
  149. .error { margin: 4px 0 0; }
  150. .confirm-otp-actions {
  151. button {
  152. width: 15em;
  153. margin-top: 5px;
  154. }
  155. }
  156. }
  157. }
  158. </style>