aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-settings/my-account-two-factor/my-account-two-factor.component.html
blob: 16c344e3bc6a299f44787ea6cb5d77f773f721c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<h1>
  <my-global-icon iconName="cog" aria-hidden="true"></my-global-icon>
  <ng-container i18n>Two factor authentication</ng-container>
</h1>

<div i18n *ngIf="twoFactorAlreadyEnabled === true" class="root already-enabled">
  Two factor authentication is already enabled.
</div>

<div class="root" *ngIf="twoFactorAlreadyEnabled === false">
  <ng-container *ngIf="step === 'request'">
    <form role="form" (ngSubmit)="requestTwoFactor()" [formGroup]="formPassword">

      <label i18n for="current-password">Your password</label>
      <div class="form-group-description" i18n>Confirm your password to enable two factor authentication</div>

      <my-input-text
        formControlName="current-password" inputId="current-password" i18n-placeholder placeholder="Current password"
        [formError]="formErrorsPassword['current-password']" autocomplete="current-password"
      ></my-input-text>

      <input class="peertube-button orange-button mt-3" type="submit" i18n-value value="Confirm" [disabled]="!formPassword.valid">
    </form>
  </ng-container>

  <ng-container *ngIf="step === 'confirm'">

    <p i18n>
      Scan this QR code into a TOTP app on your phone. This app will generate tokens that you will have to enter when logging in.
    </p>

    <qrcode [qrdata]="twoFactorURI" [width]="256" level="Q"></qrcode>

    <div i18n>
      If you can't scan the QR code and need to enter it manually, here is the plain-text secret:
    </div>

    <div class="secret-plain-text">{{ twoFactorSecret }}</div>

    <form class="mt-3" role="form" (ngSubmit)="confirmTwoFactor()" [formGroup]="formOTP">

      <label i18n for="otp-token">Two-factor code</label>
      <div class="form-group-description" i18n>Enter the code generated by your authenticator app to confirm</div>

      <my-input-text
        [show]="true" formControlName="otp-token" inputId="otp-token"
        [formError]="formErrorsOTP['otp-token']" autocomplete="otp-token"
      ></my-input-text>

      <input class="peertube-button orange-button mt-3" type="submit" i18n-value value="Confirm" [disabled]="!formOTP.valid">
    </form>
  </ng-container>

</div>