# Authenticating Users

Before we can do any sort of matchmaking, we need to login with the **Online Subsystem** first. Kronos features an **automated user authentication** process, so we do not need to do anything. Authentication is entirely handled by the `KronosUserManager` class.

## Starting Authentication

By default authentication will start automatically when the "Game Default Map" - set in your Project Settings - is opened.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FYH1RDosXtuOtVRPYZob6%2FGettingStarted_GameDefaultMap.jpg?alt=media&#x26;token=838f990e-2e10-4a65-9363-e3c25eb7b47b" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You can override which map is considered as the game default map from the plugin's settings. This is useful if you want to have a dedicated "login" map.
{% endhint %}

The user will be authenticated every time when loading the game default map, even if authentication was completed before. We do this to confirm that the user didn't lose his login status while he was away (e.g. playing in a match).

## Overriding Login Parameters

During authentication the user will be logged in with the **Online Subsystem**. Different Online Subsystems require different inputs when logging in.

{% tabs %}
{% tab title="Null Subsystem" %}
The **Null Online Subsystem** requires a login id. By default the plugin will use the local users' id so you do not have to do anything. Works out of the box.
{% endtab %}

{% tab title="Steam Subsystem" %}
The **Steam Online Subsystem** doesn't require any inputs. Works out of the box.
{% endtab %}

{% tab title="EOS Subsystem" %}
The **EOS Online Subsystem** requires a login type. By default the `AccountPortal` login type is used. With this method, a browser window will open and the user will be asked to input their Epic account information. For more information about the different login types, please refer to the **Login section** of the EOS documentation: [Online Subsystem EOS Plugin in Unreal Engine](https://docs.unrealengine.com/5.3/en-US/online-subsystem-eos-plugin-in-unreal-engine/).
{% endtab %}
{% endtabs %}

To change the default login parameters, create a new blueprint from the `KronosUserManager` class and override the `GetLoginCredentials` function.

<figure><img src="https://3833329260-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfIkwZ5xO6YLccFyQBEgv%2Fuploads%2FATIpqgBz9Mq9iWSOqq6E%2FAuth_OverrideLoginCredentials.jpg?alt=media&#x26;token=4ab6fed9-ea80-43f8-a0db-fce748f089e8" alt=""><figcaption></figcaption></figure>

Now go to **Project Settings -> Kronos Matchmaking** and set the "User Manager Class" to your custom blueprint that you just created.

## Authentication Widget

While authentication is in progress, a widget will be displayed showing the current auth state. During this time the user should be unable to interact with the game.

In case user authentication fails, the authentication widget will switch over to a failure screen displaying the error message to the user. From there the user can either retry authentication or quit the game.

Please refer to the [**Customizing The Auth Widget**](customizing-the-auth-widget) documentation page for more information about auth widget customization.

## Entering The Game

When **authentication is complete**, the `OnEnterGame` event of the `KronosOnlineSession` will be called. Think about this as passing the "login screen" of the game. You can display the main menu widget from here, add popups to the screen, or travel to a new map if needed.

## Disable Automatic Authentication

You may want to have your authentication set up in a way that initially when the game loads, the user would have to press a key to enter the game. This is the "Press any key to continue" screen you've probably seen in a lot of games.

You can disable automatic user authentication in the plugin's settings. When disabled, the game has to call the `AuthenticateUser` function of the `KronosUserManager` manually.

The `KronosOnlineSession` class has a convenient `OnGameDefaultMapLoaded` event which you can use to handle user authentication. When the event is called, check if the user is currently authenticated and decide what to do. If the user is already authenticated, then he is returning from a match so you should authenticate to confirm his login status. If the user is not authenticated, then its the users first time loading the game which means you can wait for an input.

## Passthrough Authentication

In case you want to allow a third party program or plugin to handle authentication instead of Kronos, go to **Project Settings -> Kronos Matchmaking** and enable "Authentication Is Passthrough". If this option is enabled, the user will not be logged in with the Online Subsystem during user authentication.

{% hint style="info" %}
The plugin internally tracks whether the user was authenticated or not. This means that even if authentication is not handled by Kronos you will still have to call `AuthenticateUser` to ensure that everything work correctly.
{% endhint %}
