<commit_before>import * as React from 'react'
import { ModifiableEntity, EntityPack, is } from '@framework/Signum.Entities';
import { ifError } from '@framework/Globals';
import { ajaxPost, ajaxGet, ajaxGetRaw, saveFile, ServiceError } from '@framework/Services';
import * as Services from '@framework/Services';
import { EntitySettings } from '@framework/Navigator'
import { tasks, LineBase, LineBaseProps } from '@framework/Lines/LineBase'
import * as Navigator from '@framework/Navigator'
import * as Finder from '@framework/Finder'
import * as QuickLinks from '@framework/QuickLinks'
import { EntityOperationSettings } from '@framework/Operations'
import { PropertyRouteEntity } from '@framework/Signum.Entities.Basics'
import { PseudoType, getTypeInfo, OperationInfo, getQueryInfo, GraphExplorer, PropertyRoute } from '@framework/Reflection'
import * as Operations from '@framework/Operations'
import { UserEntity, RoleEntity, UserOperation, PermissionSymbol, PropertyAllowed, TypeAllowedBasic, AuthAdminMessage, BasicPermission } from './Signum.Entities.Authorization'
import { PermissionRulePack, TypeRulePack, OperationRulePack, PropertyRulePack, QueryRulePack, QueryAllowed } from './Signum.Entities.Authorization'
import * as OmniboxClient from '../Omnibox/OmniboxClient'
import { ImportRoute } from "@framework/AsyncImport";

Services.AuthTokenFilter.addAuthToken = addAuthToken;

export function registerUserTicketAuthenticator() {
  authenticators.push(loginFromCookie);
}

/* Install and enable Windows authentication in IIS https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-2.2&tabs=visual-studio */
export function registerWindowsAuthenticator() {
  authenticators.push(loginWindowsAuthentication);
}

export function startPublic(options: { routes: JSX.Element[], userTicket: boolean, windowsAuthentication: boolean, resetPassword: boolean, notifyLogout: boolean }) {
  Options.userTicket = options.userTicket;
  Options.windowsAuthentication = options.windowsAuthentication;
  Options.resetPassword = options.resetPassword;

  if (Options.userTicket) {
    if (!authenticators.contains(loginFromCookie))
      throw new Error("call AuthClient.registerUserTicketAuthenticator in Main.tsx before AuthClient.autoLogin");
  }

  if (Options.windowsAuthentication) {
    if (!authenticators.contains(loginWindowsAuthentication))
      throw new Error("call AuthClient.registerUserTicketAuthenticator in Main.tsx before AuthClient.autoLogin");
  }

  options.routes.push(<ImportRoute path="~/auth/login" onImportModule={() => import("./Login/Login")} />);
  options.routes.push(<ImportRoute path="~/auth/changePassword" onImportModule={() => import("./Login/ChangePassword")} />);


  if (options.notifyLogout) {
    notifyLogout = options.notifyLogout;

    window.addEventListener("storage", se => {
      if (se.key == 'requestLogout' + Services.SessionSharing.getAppName()) {<commit_msg>fix AuthClient.tsx<commit_after>import * as React from 'react'
import { ModifiableEntity, EntityPack, is } from '@framework/Signum.Entities';
import { ifError } from '@framework/Globals';
import { ajaxPost, ajaxGet, ajaxGetRaw, saveFile, ServiceError } from '@framework/Services';
import * as Services from '@framework/Services';
import { EntitySettings } from '@framework/Navigator'
import { tasks, LineBase, LineBaseProps } from '@framework/Lines/LineBase'
import * as Navigator from '@framework/Navigator'
import * as Finder from '@framework/Finder'
import * as QuickLinks from '@framework/QuickLinks'
import { EntityOperationSettings } from '@framework/Operations'
import { PropertyRouteEntity } from '@framework/Signum.Entities.Basics'
import { PseudoType, getTypeInfo, OperationInfo, getQueryInfo, GraphExplorer, PropertyRoute } from '@framework/Reflection'
import * as Operations from '@framework/Operations'
import { UserEntity, RoleEntity, UserOperation, PermissionSymbol, PropertyAllowed, TypeAllowedBasic, AuthAdminMessage, BasicPermission } from './Signum.Entities.Authorization'
import { PermissionRulePack, TypeRulePack, OperationRulePack, PropertyRulePack, QueryRulePack, QueryAllowed } from './Signum.Entities.Authorization'
import * as OmniboxClient from '../Omnibox/OmniboxClient'
import { ImportRoute } from "@framework/AsyncImport";

Services.AuthTokenFilter.addAuthToken = addAuthToken;

export function registerUserTicketAuthenticator() {
  authenticators.push(loginFromCookie);
}

/* Install and enable Windows authentication in IIS https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-2.2&tabs=visual-studio */
export function registerWindowsAuthenticator() {
  authenticators.push(loginWindowsAuthentication);
}

export function startPublic(options: { routes: JSX.Element[], userTicket: boolean, windowsAuthentication: boolean, resetPassword: boolean, notifyLogout: boolean }) {
  Options.userTicket = options.userTicket;
  Options.windowsAuthentication = options.windowsAuthentication;
  Options.resetPassword = <PASSWORD>.<PASSWORD>Password;

  if (Options.userTicket) {
    if (!authenticators.contains(loginFromCookie))
      throw new Error("call AuthClient.registerUserTicketAuthenticator in Main.tsx before AuthClient.autoLogin");
  }

  if (Options.windowsAuthentication) {
    if (!authenticators.contains(loginWindowsAuthentication))
      throw new Error("call AuthClient.registerWindowsAuthenticator in Main.tsx before AuthClient.autoLogin");
  }

  options.routes.push(<ImportRoute path="~/auth/login" onImportModule={() => import("./Login/Login")} />);
  options.routes.push(<ImportRoute path="~/auth/changePassword" onImportModule={() => import("./Login/ChangePassword")} />);


  if (options.notifyLogout) {
    notifyLogout = options.notifyLogout;

    window.addEventListener("storage", se => {
      if (se.key == 'requestLogout' + Services.SessionSharing.getAppName()) {
{'fraction_non_alphanumeric': 0.11492890995260663, 'fraction_numerical': 0.0006770480704129993, 'mean_word_length': 6.432704402515723, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '130724', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1586, 'n_words': 367}