Juice-shop: Error In Browser Console on facelift branch[馃悰]

Created on 11 Jun 2019  路  4Comments  路  Source: bkimminich/juice-shop

:bug: Bug report

Description


Error in console
Screenshot 2019-06-11 at 5 27 28 PM

Is this a regression?



Yes

:microscope: Minimal Reproduction


This error can be observed in the browser console by following steps:

  • Go to http://localhost:4200/#/
  • Login to the app.
  • Refresh the page.(Try the step more than once if error is not observed)
bug

Most helpful comment

The bug should be fixed with the next PullRequest in the Facelift Branch. The problem was that the dialog was always opened independently of the cookie and then closed in the next step after checking the cookie.

welcome.component.ts

ngOnInit (): void {
    this.configurationService.getApplicationConfiguration().subscribe((config: any) => {
      if (config && config.application && !config.application.welcomeBanner) {
        return
      }
      this.dialog.open(WelcomeBannerComponent, {
        minWidth: '320px',
        width: '35%',
        position: {
          top: '50px'
        }
      })
    }, (err) => console.log(err))
  }

&&

welcome-banner-component.ts

ngOnInit (): void {
    let welcomeBannerStatus = this.cookieService.get(this.welcomeBannerStatusCookieKey)
    if (welcomeBannerStatus === 'dismiss') {
      this.dialogRef.close()
    } else {
      this.configurationService.getApplicationConfiguration().subscribe((config) => {
        if (config && config.application) {
          if (config.application.name !== null) {
            this.applicationName = config.application.name
          }
        }
      }, (err) => console.log(err))
    }
  }

The problem has been fixed by now checking the cookie before opening the dialog.

welcome.component.ts

ngOnInit (): void {
    let welcomeBannerStatus = this.cookieService.get(this.welcomeBannerStatusCookieKey)
    if (welcomeBannerStatus === 'dismiss') {
      return
    } else {
      this.configurationService.getApplicationConfiguration().subscribe((config: any) => {
        if (config && config.application && !config.application.welcomeBanner) {
          return
        }
        this.dialog.open(WelcomeBannerComponent, {
          minWidth: '320px',
          width: '35%',
          position: {
            top: '50px'
          }
        })
      }, (err) => console.log(err))
    }
  }

All 4 comments

The error also persists in gsoc2019 branch. Post facelift merge, I suspect.馃槢

The bug should be fixed with the next PullRequest in the Facelift Branch. The problem was that the dialog was always opened independently of the cookie and then closed in the next step after checking the cookie.

welcome.component.ts

ngOnInit (): void {
    this.configurationService.getApplicationConfiguration().subscribe((config: any) => {
      if (config && config.application && !config.application.welcomeBanner) {
        return
      }
      this.dialog.open(WelcomeBannerComponent, {
        minWidth: '320px',
        width: '35%',
        position: {
          top: '50px'
        }
      })
    }, (err) => console.log(err))
  }

&&

welcome-banner-component.ts

ngOnInit (): void {
    let welcomeBannerStatus = this.cookieService.get(this.welcomeBannerStatusCookieKey)
    if (welcomeBannerStatus === 'dismiss') {
      this.dialogRef.close()
    } else {
      this.configurationService.getApplicationConfiguration().subscribe((config) => {
        if (config && config.application) {
          if (config.application.name !== null) {
            this.applicationName = config.application.name
          }
        }
      }, (err) => console.log(err))
    }
  }

The problem has been fixed by now checking the cookie before opening the dialog.

welcome.component.ts

ngOnInit (): void {
    let welcomeBannerStatus = this.cookieService.get(this.welcomeBannerStatusCookieKey)
    if (welcomeBannerStatus === 'dismiss') {
      return
    } else {
      this.configurationService.getApplicationConfiguration().subscribe((config: any) => {
        if (config && config.application && !config.application.welcomeBanner) {
          return
        }
        this.dialog.open(WelcomeBannerComponent, {
          minWidth: '320px',
          width: '35%',
          position: {
            top: '50px'
          }
        })
      }, (err) => console.log(err))
    }
  }

This thread has been automatically locked because it has not had recent activity after it was closed. :lock: Please open a new issue for regressions or related bugs.

This thread has been automatically locked because it has not had recent activity after it was closed. :lock: Please open a new issue for regressions or related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bkimminich picture bkimminich  路  7Comments

toptuto picture toptuto  路  7Comments

bkimminich picture bkimminich  路  5Comments

junathanadi picture junathanadi  路  3Comments

azqa picture azqa  路  7Comments