• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

juice-shop / juice-shop / 20126408331

11 Dec 2025 08:15AM UTC coverage: 86.013% (-0.07%) from 86.078%
20126408331

push

github

web-flow
Merge pull request #2930 from bogminic/spacing-tokens

Add spacing SCSS variables and replace hardcoded pixels in About Us page

1250 of 1676 branches covered (74.58%)

Branch coverage included in aggregate %.

5342 of 5988 relevant lines covered (89.21%)

40.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.45
/frontend/src/app/two-factor-auth-enter/two-factor-auth-enter.component.ts
1
/*
2
 * Copyright (c) 2014-2026 Bjoern Kimminich & the OWASP Juice Shop contributors.
3
 * SPDX-License-Identifier: MIT
4
 */
5

6
import { Component, NgZone, inject } from '@angular/core'
7
import { UntypedFormControl, UntypedFormGroup, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms'
8
import { TwoFactorAuthService } from '../Services/two-factor-auth-service'
9
import { CookieService } from 'ngy-cookie'
10
import { UserService } from '../Services/user.service'
11
import { Router } from '@angular/router'
12
import { library } from '@fortawesome/fontawesome-svg-core'
13
import { faUnlockAlt } from '@fortawesome/free-solid-svg-icons'
14
import { MatButtonModule } from '@angular/material/button'
15
import { MatTooltip } from '@angular/material/tooltip'
16
import { MatIconModule } from '@angular/material/icon'
17
import { MatInputModule } from '@angular/material/input'
18
import { MatFormFieldModule, MatLabel, MatSuffix, MatHint, MatError } from '@angular/material/form-field'
19

20
import { TranslateModule } from '@ngx-translate/core'
21
import { MatCardModule } from '@angular/material/card'
22

23
library.add(faUnlockAlt)
1✔
24

25
interface TokenEnterFormFields {
26
  token: string
27
}
28

29
@Component({
30
  selector: 'app-two-factor-auth-enter',
31
  templateUrl: './two-factor-auth-enter.component.html',
32
  styleUrls: ['./two-factor-auth-enter.component.scss'],
33
  imports: [MatCardModule, TranslateModule, FormsModule, ReactiveFormsModule, MatFormFieldModule, MatLabel, MatInputModule, MatIconModule, MatSuffix, MatTooltip, MatHint, MatError, MatButtonModule, MatIconModule]
34
})
35
export class TwoFactorAuthEnterComponent {
1✔
36
  private readonly twoFactorAuthService = inject(TwoFactorAuthService)
5✔
37
  private readonly cookieService = inject(CookieService)
5✔
38
  private readonly userService = inject(UserService)
5✔
39
  private readonly router = inject(Router)
5✔
40
  private readonly ngZone = inject(NgZone)
5✔
41

42
  public twoFactorForm: UntypedFormGroup = new UntypedFormGroup({
5✔
43
    token: new UntypedFormControl('', [Validators.minLength(6), Validators.maxLength(6), Validators.required, Validators.pattern('^[\\d]{6}$')])
44
  })
45

46
  public errored = false
5✔
47

48
  verify () {
49
    const fields: TokenEnterFormFields = this.twoFactorForm.value
4✔
50

51
    this.twoFactorAuthService.verify(fields.token).subscribe({
4✔
52
      next: (authentication) => {
53
        localStorage.setItem('token', authentication.token)
3✔
54
        const expires = new Date()
3✔
55
        expires.setHours(expires.getHours() + 8)
3✔
56
        this.cookieService.put('token', authentication.token, { expires })
3✔
57
        sessionStorage.setItem('bid', authentication.bid?.toString())
3✔
58
        /* Use userService to notifiy if user has logged in */
59
        /* this.userService.isLoggedIn = true; */
60
        this.userService.isLoggedIn.next(true)
3✔
61
        this.ngZone.run(async () => await this.router.navigate(['/search']))
3✔
62
      },
63
      error: (error) => {
64
        this.errored = true
1✔
65
        setTimeout(() => {
1✔
66
          this.errored = false
×
67
        }, 5 * 1000)
68
        return error
1✔
69
      }
70
    })
71
  }
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc