0

Please or Register to create posts and topics.

Issue with the transition from version 2.7 to 2.8

Hi,

When I call ng serve with the old version, there are no warnings.

WARNING in ./src/app/services/db-Keys.ts
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* C:\Users\Ingo\source\repos\TipWeb8\QuickApp.Pro\ClientApp\node_modules\@ngtools\webpack\src\index.js!C:\Users\Ingo\source\repos\TipWeb8\QuickApp.Pro\ClientApp\src\app\services\db-Keys.ts
Used by 12 module(s), i. e.
C:\Users\Ingo\source\repos\TipWeb8\QuickApp.Pro\ClientApp\node_modules\@ngtools\webpack\src\index.js!C:\Users\Ingo\source\repos\TipWeb8\QuickApp.Pro\ClientApp\src\app\services\auth.service.ts
* C:\Users\Ingo\source\repos\TipWeb8\QuickApp.Pro\ClientApp\node_modules\@ngtools\webpack\src\index.js!C:\Users\Ingo\source\repos\TipWeb8\QuickApp.Pro\ClientApp\src\app\services\db-keys.ts
Used by 147 module(s), i. e.
C:\Users\Ingo\source\repos\TipWeb8\QuickApp.Pro\ClientApp\node_modules\@ngtools\webpack\src\index.js!C:\Users\Ingo\source\repos\TipWeb8\QuickApp.Pro\ClientApp\src\app\components\about\about.component.ts

Can someone help me here?

I do not know what to look for.

regards Ingo

export class DBkeys {

    public static readonly CURRENT_USER = 'current_user';
    public static readonly USER_PERMISSIONS = 'user_permissions';
    public static readonly ACCESS_TOKEN = 'access_token';
    public static readonly REFRESH_TOKEN = 'refresh_token';
    public static readonly TOKEN_EXPIRES_IN = 'expires_in';

    public static readonly REMEMBER_ME = 'remember_me';


    public static readonly LANGUAGE = 'language';
    public static readonly HOME_URL = 'home_url';
    public static readonly THEME_ID = 'themeId';
    public static readonly CULTURE = 'culture';
    public static readonly REFRESH_SOAP = 'refresh_soap';
    public static readonly SHOW_NAVIGATOR = 'show-navigator';
    public static readonly SHOW_DASHBOARD_COMPANY = 'show_dashboard_company';
    public static readonly SHOW_DASHBOARD_SOAP = 'show_dashboard_soap';
    public static readonly SHOW_DASHBOARD_CUSTOMER = 'show_dashboard_customer';
    public static readonly SHOW_DASHBOARD_LICENSE = 'show_dashboard_license';
    public static readonly SHOW_DASHBOARD_GROUPS = 'show_dashboard_groups';
    public static readonly CUSTOMER_PAGINATION = 'customer_pagination';
    public static readonly LICENSE_PAGINATION = 'license_pagination';

    public static readonly APPDATA_APPNAME = 'applicationName';
    public static readonly APPDATA_DBVERSION = 'appDbVersion';
    public static readonly APPDATA_PROJECTVERSION = 'appProjectVersion';
    public static readonly APPDATA_SERVICEONLYADMIN = 'appServiceOnlyAdmin';
    public static readonly APPDATA_URL = 'appUrl';
    public static readonly APPDATA_HOMEPAGELINK = 'appHomepageLink';
    public static readonly APPDATA_HOMEPAGENAME = 'appHomepageName';
    public static readonly APPDATA_COPYRIGHT = 'appCopyright';
    public static readonly APPDATA_SOAPREFRESH = 'soapRefresh';
    public static readonly APPDATA_LATITUDE = 'latitude';
    public static readonly APPDATA_LONGITUDE = 'longitude';
    public static readonly APPDATA_ZOOM = 'zoom';
    public static readonly APPDATA_INVOICE_IMAGE_NAME = 'invoiceImageName';
    public static readonly APPDATA_INVOICE_IMAGE_HEIGTH = 'invoiceImageHeigth';
    public static readonly APPDATA_INVOICE_IMAGE_WIDTH = 'invoiceImageWidth';
    public static readonly APPDATA_INVOICE_IMAGE_X = 'invoiceImageX';
    public static readonly APPDATA_INVOICE_IMAGE_Y = 'invoiceImageY';
    public static readonly APPDATA_NOTIFICATIONINTERVAL = 'NotificationInterval';

    // Rollen in der Datenbank
    public static readonly ROLE_ADMIN = 'administrator';
    public static readonly ROLE_RESELLER = 'reseller';
    public static readonly ROLE_CUSTOMRE = 'customer';
    public static readonly ROLE_EMPLOYEE = 'employee';
    // Erweiterungen
    public static readonly SERVICE = 'service';
    public static readonly COMP_NAME = 'company_name';
    public static readonly COMP_CURRENCY = 'company_currency';
    public static readonly COMP_ID = 'company_id';
    public static readonly COMP_BILLING = 'company_Billing';

    public static readonly CUSTOMER_NAME = 'customer_name';
    public static readonly CUSTOMER_ID = 'customer_id';
    public static readonly CUSTOMER_CURRENCY = 'customer_currency';
    public static readonly CUSTOMER_SELECTED = 'customer_selected';
    public static readonly CUSTOMER_SELECTEDCURRENCY = 'customer_selectedCurrency';
    public static readonly CUSTOMER_SELECTEDNAME = 'customer_selectedName';
    public static readonly CUSTOMER_NOEDITLICENSES = 'customer_noEditLicenses';
    public static readonly CUSTOMER_INSSOCIATION = 'customer_inAssociation';
    public static readonly PAGINATOR = 'paginator';
}
import { Component } from '@angular/core';
import { fadeInOut } from '../../services/animations';

import { AccountService } from '../../services/account.service';
import { AuthService } from '../../services/auth.service';
import { AppTranslationService } from '../../services/app-translation.service';
import { LocalStoreManager } from '../../services/local-store-manager.service';
import { ConfigurationService } from '../../services/configuration.service';
import { DBkeys } from '../../services/db-keys';


@Component({
    // tslint:disable-next-line:component-selector
    selector: 'about',
    templateUrl: './about.component.html',
    styleUrls: ['./about.component.scss'],
    animations: [fadeInOut]
})
export class AboutComponent  {
    gT = (key: string) => this.translationService.getTranslation(key);

    constructor(private accountService: AccountService,
                private translationService: AppTranslationService,
                public configurationService: ConfigurationService,
                private authService: AuthService,
                private storageManager: LocalStoreManager) {
    }
    get projectTitle(): string {
        return this.accountService.projectTitle;
    }
    get projectVersion(): string {
        return this.accountService.projectVersion;
    }
    get dbVersion(): number {
        return this.accountService.dbVersion;
    }
    get isAdmin(): boolean {
        return this.accountService.hasRoleAdmin;
    }
    get adminOnlyService(): boolean {
        return this.accountService.adminOnlyService;
    }
    get isEmployee(): boolean {
        return this.accountService.hasRoleEmployee;
    }
    get isCustomer(): boolean {
        return this.accountService.hasRoleCustomer;
    }
    get isReseller(): boolean {
        return this.accountService.hasRoleReseller;
    }
    get IsLogedIn(): boolean {
        return this.authService.isLoggedIn;
    }
    get copyright(): string {
        return this.storageManager.getDataObject<string>(DBkeys.APPDATA_COPYRIGHT);
    }
    get homepage(): string {
        return this.storageManager.getDataObject<string>(DBkeys.APPDATA_HOMEPAGELINK);
    }
    downloadManual() {
        let downloadLink = this.configurationService.baseUrl + '/api/download/manual/';
        if (this.configurationService.language === 'de') {
            downloadLink += '0';
        } else {
            downloadLink += '1';
        }
        window.open(downloadLink, '_blank');
    }
    downloadExcelTemplate() {
        const downloadLink = this.configurationService.baseUrl + '/api/download/excelTemplate';
        window.open(downloadLink, '_blank');
    }
}
import { Injectable } from '@angular/core';
import { Router, NavigationExtras } from '@angular/router';
import { Observable, Subject, from } from 'rxjs';
import { map, mergeMap } from 'rxjs/operators';
import { OAuthService } from 'angular-oauth2-oidc';

import { LocalStoreManager } from './local-store-manager.service';
import { AuthStorage } from './auth-storage';
import { ConfigurationService } from './configuration.service';
import { DBkeys } from './db-Keys';
import { JwtHelper } from './jwt-helper';
import { Utilities } from './utilities';
import { AccessToken } from '../models/access-token.model';
import { User } from '../models/user.model';
import { UserLogin } from '../models/user-login.model';
import { PermissionValues } from '../models/permission.model';

@Injectable()
export class AuthService {
  private readonly _discoveryDocUrl: string = '/.well-known/openid-configuration';

  private get discoveryDocUrl() { return this.configurations.tokenUrl + this._discoveryDocUrl; }
  public get baseUrl() { return this.configurations.baseUrl; }
  public get loginUrl() { return this.configurations.loginUrl; }
  public get homeUrl() { return this.configurations.homeUrl; }

  public loginRedirectUrl: string;
  public logoutRedirectUrl: string;

  public reLoginDelegate: () => void;

  private previousIsLoggedInCheck = false;
  private _loginStatus = new Subject<boolean>();

  constructor(
    private router: Router,
    private oauthService: OAuthService,
    private configurations: ConfigurationService,
    private localStorage: LocalStoreManager) {

    this.initializeLoginStatus();
  }

  private initializeLoginStatus() {
    this.localStorage.getInitEvent().subscribe(() => {
      this.reevaluateLoginStatus();
    });
  }

  gotoPage(page: string, preserveParams = true) {

    const navigationExtras: NavigationExtras = {
      queryParamsHandling: preserveParams ? 'merge' : '', preserveFragment: preserveParams
    };

    this.router.navigate([page], navigationExtras);
  }

  gotoHomePage() {
    this.router.navigate([this.homeUrl]);
  }

  redirectLoginUser() {
    const redirect = this.loginRedirectUrl && this.loginRedirectUrl !== '/' && this.loginRedirectUrl !==
          ConfigurationService.defaultHomeUrl ? this.loginRedirectUrl : this.homeUrl;
    this.loginRedirectUrl = null;

    const urlParamsAndFragment = Utilities.splitInTwo(redirect, '#');
    const urlAndParams = Utilities.splitInTwo(urlParamsAndFragment.firstPart, '?');

    const navigationExtras: NavigationExtras = {
      fragment: urlParamsAndFragment.secondPart,
      queryParams: Utilities.getQueryParamsFromString(urlAndParams.secondPart),
      queryParamsHandling: 'merge'
    };

    this.router.navigate([urlAndParams.firstPart], navigationExtras);
  }

  redirectLogoutUser() {
    const redirect = this.logoutRedirectUrl ? this.logoutRedirectUrl : this.loginUrl;
    this.logoutRedirectUrl = null;

    this.router.navigate([redirect]);
  }

  redirectForLogin() {
    this.loginRedirectUrl = this.router.url;
    this.router.navigate([this.loginUrl]);
  }

  reLogin() {
    if (this.reLoginDelegate) {
      this.reLoginDelegate();
    } else {
      this.redirectForLogin();
    }
  }

  refreshLogin(): Observable<User> {
    if (this.oauthService.discoveryDocumentLoaded) {
      return from(this.oauthService.refreshToken()).pipe(
        map(() => this.processLoginResponse(this.oauthService.getAccessToken(), this.rememberMe)));
    } else {
      this.configureOauthService(this.rememberMe);
      return from(this.oauthService.loadDiscoveryDocument(this.discoveryDocUrl)).pipe(mergeMap(() => this.refreshLogin()));
    }
  }

  login(user: UserLogin) {
    if (this.isLoggedIn) {
      this.logout();
    }

    this.configureOauthService(user.rememberMe);

    return from(this.oauthService.loadDiscoveryDocument(this.discoveryDocUrl)).pipe(mergeMap(() => {
      return from(this.oauthService.fetchTokenUsingPasswordFlow(user.userName, user.password)).pipe(
        map(() => this.processLoginResponse(this.oauthService.getAccessToken(), user.rememberMe))
      );
    }));
  }

  private configureOauthService(rememberMe?: boolean) {
    this.oauthService.issuer = this.baseUrl;
    this.oauthService.clientId = 'quickapp_spa';
    this.oauthService.scope = 'openid email phone profile offline_access roles quickapp_api';
    this.oauthService.skipSubjectCheck = true;
    this.oauthService.dummyClientSecret = 'not_used';

    AuthStorage.RememberMe = rememberMe;
  }


  private processLoginResponse(accessToken: string, rememberMe: boolean) {

    if (accessToken == null) {
      throw new Error('accessToken cannot be null');
    }

    const jwtHelper = new JwtHelper();
    const decodedAccessToken = jwtHelper.decodeToken(accessToken) as AccessToken;

    const permissions: PermissionValues[] = Array.isArray(decodedAccessToken.permission) ? decodedAccessToken.permission :
      [decodedAccessToken.permission];

    if (!this.isLoggedIn) {
      this.configurations.import(decodedAccessToken.configuration);
      this.configurations.clearCompanyLocalChanges();
      this.configurations.clearCustomerLocalChanges();
      if (decodedAccessToken.company) {
        this.configurations.importCompany(decodedAccessToken.company);
      }
      if (decodedAccessToken.customer) {
        this.configurations.importCustomer(decodedAccessToken.customer);
      }
    }

    const user = new User(
      decodedAccessToken.sub,
      decodedAccessToken.name,
      decodedAccessToken.fullname,
      decodedAccessToken.email,
      decodedAccessToken.jobtitle,
      decodedAccessToken.phone_number,
      Array.isArray(decodedAccessToken.role) ? decodedAccessToken.role : [decodedAccessToken.role]);
    user.isEnabled = true;

    this.saveUserDetails(user, permissions, rememberMe);

    this.reevaluateLoginStatus(user);

    return user;
  }

  private saveUserDetails(user: User, permissions: PermissionValues[], rememberMe: boolean) {
    if (rememberMe) {
      this.localStorage.savePermanentData(permissions, DBkeys.USER_PERMISSIONS);
      this.localStorage.savePermanentData(user, DBkeys.CURRENT_USER);
    } else {
      this.localStorage.saveSyncedSessionData(permissions, DBkeys.USER_PERMISSIONS);
      this.localStorage.saveSyncedSessionData(user, DBkeys.CURRENT_USER);
    }

    this.localStorage.savePermanentData(rememberMe, DBkeys.REMEMBER_ME);
  }

  logout(): void {
    this.localStorage.deleteData(DBkeys.USER_PERMISSIONS);
    this.localStorage.deleteData(DBkeys.CURRENT_USER);

    this.configurations.clearLocalChanges();
    this.oauthService.logOut(true);

    this.reevaluateLoginStatus();
  }

  private reevaluateLoginStatus(currentUser?: User) {
    const user = currentUser || this.localStorage.getDataObject<User>(DBkeys.CURRENT_USER);
    const isLoggedIn = user != null;

    if (this.previousIsLoggedInCheck !== isLoggedIn) {
      setTimeout(() => {
        this._loginStatus.next(isLoggedIn);
      });
    }

    this.previousIsLoggedInCheck = isLoggedIn;
  }

  getLoginStatusEvent(): Observable<boolean> {
    return this._loginStatus.asObservable();
  }

  get currentUser(): User {

    const user = this.localStorage.getDataObject<User>(DBkeys.CURRENT_USER);
    this.reevaluateLoginStatus(user);

    return user;
  }

  get userPermissions(): PermissionValues[] {
    return this.localStorage.getDataObject<PermissionValues[]>(DBkeys.USER_PERMISSIONS) || [];
  }

  get accessToken(): string {
    return this.oauthService.getAccessToken();
  }

  get accessTokenExpiryDate(): Date {
    return new Date(this.oauthService.getAccessTokenExpiration());
  }

  get isSessionExpired(): boolean {
    if (this.accessTokenExpiryDate == null) {
      return true;
    }

    return this.accessTokenExpiryDate.valueOf() <= new Date().valueOf();
  }

  get refreshToken(): string {
    return this.oauthService.getRefreshToken();
  }

  get isLoggedIn(): boolean {
    return this.currentUser != null;
  }

  get rememberMe(): boolean {
    return this.localStorage.getDataObject<boolean>(DBkeys.REMEMBER_ME) === true;
  }
}

 

Hi,

 

I found my error in AboutComponent

import { DBkeys } from './db-Keys';
right
import { DBkeys } from './db-keys';

 

Eben Monney has reacted to this post.
Eben Monney