# Nutzer

## Login

<mark style="color:green;">`POST`</mark> `https://vt.jo-dev.net/?action=login`

Führe ein Log-In basierend auf E-Mail und Passwort aus

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| email<mark style="color:red;">\*</mark>    | String |             |
| password<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK" %}
Bei erfolgreichem Login werden die Nutzerdaten zurückgegeben
{% endtab %}

{% tab title="400: Bad Request " %}
Missing information
{% endtab %}

{% tab title="401: Unauthorized " %}
Account not verified
{% endtab %}

{% tab title="401: Unauthorized " %}
Invalid login credentials
{% endtab %}
{% endtabs %}

## Logout

<mark style="color:green;">`POST`</mark> `https://vt.jo-dev.net/?action=logout`

Logge einen Nutzer aus in dem das Token widerrufen wird

#### Headers

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| Auth<mark style="color:red;">\*</mark> | String | Usertoken   |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}

{% tab title="401: Unauthorized" %}
Invalid token
{% endtab %}
{% endtabs %}

## Alle Tokens ungültig machen

<mark style="color:green;">`POST`</mark> `https://vt.jo-dev.net/?action=revokeAllTokens`

Dieser Endpunkt löscht alle bestehenden Tokens des Nutzers, d.h. loggt ihn aus allen bestehenden Sessions aus

#### Headers

| Name                                   | Type   | Description        |
| -------------------------------------- | ------ | ------------------ |
| Auth<mark style="color:red;">\*</mark> | String | A valid user token |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}

{% tab title="401: Unauthorized " %}
Invalid token
{% endtab %}
{% endtabs %}

## Token validieren

<mark style="color:green;">`POST`</mark> `https://vt.jo-dev.net/?action=validateToken`

Überprüfe ob ein Token gültig ist

#### Headers

| Name                                   | Type   | Description                     |
| -------------------------------------- | ------ | ------------------------------- |
| Auth<mark style="color:red;">\*</mark> | String | Token das überprüft werden soll |

{% tabs %}
{% tab title="200: OK " %}
Returned im JSON als "TokenValid" ein boolean
{% endtab %}

{% tab title="401: Unauthorized " %}
Wenn kein zu überprüfendes Token angegeben wurde
{% endtab %}
{% endtabs %}

## Einstellungen ändern

<mark style="color:orange;">`PUT`</mark> `https://vt.jo-dev.net/?action=updatePreferences`

Ändere die Einstellung eines Nutzers (Klasse, Dark-/Whitemode)

#### Headers

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| Auth<mark style="color:red;">\*</mark> | String | Usertoken   |

#### Request Body

| Name  | Type | Description              |
| ----- | ---- | ------------------------ |
| mode  | Int  | Neuer eingestellter Mode |
| class | Int  | Neue Klasse              |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}

{% tab title="401: Unauthorized " %}
Invalid token
{% endtab %}
{% endtabs %}

***

## Einstellungen abrufen

<mark style="color:blue;">`GET`</mark> `https://vt.jo-dev.net/?action=getPreferences`

Rufe die aktuellen Einstellung des Nutzers ab

**Headers**

| Name                                   | Value     |
| -------------------------------------- | --------- |
| Auth<mark style="color:red;">\*</mark> | Usertoken |

**Response**

{% tabs %}
{% tab title="200 OK" %}

```json
{
  "Error": "",
  "modePreference": <userValue>,
  "class": <userValue>
}
```

{% endtab %}

{% tab title="401 Invalid Token" %}

```json
{
  "Error": "Invalid token"
}
```

{% endtab %}
{% endtabs %}

***

## Nutzer erstellen

## Account erstellen

<mark style="color:green;">`POST`</mark> `https://vt.jo-dev.net/?action=createAccount`

Erstellt ein neuen Nutzer und initiiert ein Verifikationsprozess per E-Mail

#### Request Body

| Name                                             | Type    | Description                |
| ------------------------------------------------ | ------- | -------------------------- |
| firstName<mark style="color:red;">\*</mark>      | String  | Vorname des neuen Nutzers  |
| lastName<mark style="color:red;">\*</mark>       | String  | Nachname des neuen Nutzers |
| email<mark style="color:red;">\*</mark>          | String  | E-Mail des neuen Nutzers   |
| password<mark style="color:red;">\*</mark>       | String  | Passwort des neuen Nutzers |
| modePreference<mark style="color:red;">\*</mark> | Integer | Bevorzugtes Design         |
| class<mark style="color:red;">\*</mark>          |         | Klasse des neuen Nutzers   |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}

{% tab title="400: Bad Request " %}
Missing information
{% endtab %}

{% tab title="400: Bad Request " %}
Account with email already exists
{% endtab %}

{% tab title="400: Bad Request" %}
Invalid email
{% endtab %}
{% endtabs %}

## Account verifizieren

<mark style="color:green;">`POST`</mark> `https://vt.jo-dev.net/?action=verifyAccount`

Überprüfe den per E-Mail gesendeten Bestätigungscode

#### Request Body

| Name                                    | Type   | Description              |
| --------------------------------------- | ------ | ------------------------ |
| email<mark style="color:red;">\*</mark> | String |                          |
| code<mark style="color:red;">\*</mark>  | String | Der zu überprüfende Code |

{% tabs %}
{% tab title="200: OK " %}
Gibt ein User Token für weitere Anfragen zurück
{% endtab %}

{% tab title="400: Bad Request " %}
Missing information
{% endtab %}

{% tab title="401: Unauthorized " %}
Code and email not matching
{% endtab %}
{% endtabs %}

## Account löschen

<mark style="color:red;">`DELETE`</mark> `https://vt.jo-dev.net/?action=deleteAccount`

Lösche einen Account

#### Headers

| Name                                   | Type   | Description            |
| -------------------------------------- | ------ | ---------------------- |
| Auth<mark style="color:red;">\*</mark> | String | Ein gültiges Usertoken |

#### Request Body

| Name                                       | Type   | Description              |
| ------------------------------------------ | ------ | ------------------------ |
| password<mark style="color:red;">\*</mark> | String | Das Passwort des Nutzers |

{% tabs %}
{% tab title="200: OK" %}
Account wurde erfolgreich gelöscht
{% endtab %}

{% tab title="400: Bad Request" %}
Missing information
{% endtab %}

{% tab title="401: Unauthorized" %}
Invalid login credentials
{% endtab %}
{% endtabs %}

***

## Passwort zurücksetzen

{% hint style="info" %}
Ein Passwortreset Flow sollte wie folgend aussehen:

1. initiatePasswordReset um dem Nutzer den Code zuzusenden
2. validatePasswordReset um den eingegebenen Code zu checken und daraufhin ein neues Passwort eingeben zu lassen
3. doPasswordReset um das neue eingegebene Passwort festzulegen
   {% endhint %}

## Starten des Passwortresets

<mark style="color:green;">`POST`</mark> `https://vt.jo-dev.net/?action=initiatePasswordReset`

Sendet einen Code zum Zurücksetzen des Passwortes per E-Mail

#### Request Body

| Name                                    | Type   | Description                                                    |
| --------------------------------------- | ------ | -------------------------------------------------------------- |
| email<mark style="color:red;">\*</mark> | String | Die E-Mail des Nutzers welcher sein Passwort zurücksetzen will |

{% tabs %}
{% tab title="200: OK " %}
Can be&#x20;
{% endtab %}

{% tab title="400: Bad Request" %}
Missing information
{% endtab %}
{% endtabs %}

## Validieren des Codes

<mark style="color:green;">`POST`</mark> `https://vt.jo-dev.net/?action=validatePasswordReset`

Überprüfen ob der Nutzer den richtigen Code eingegeben hat

#### Request Body

| Name                                    | Type   | Description                           |
| --------------------------------------- | ------ | ------------------------------------- |
| email<mark style="color:red;">\*</mark> | String | E-Mail an die der Code gesendet wurde |
| code<mark style="color:red;">\*</mark>  |        | Der eingegebene Code                  |

{% tabs %}
{% tab title="200: OK Der Code ist richtig" %}
Der Code ist richtig
{% endtab %}

{% tab title="401: Unauthorized" %}
Der Code stimmt nicht mit dem gesendeten überein
{% endtab %}

{% tab title="400: Bad Request " %}
Missing information
{% endtab %}
{% endtabs %}

## Neues Passwort festlegen

<mark style="color:orange;">`PUT`</mark> `https://vt.jo-dev.net/?action=doPasswordReset`

Endpoint um ein neues Passwort festzulegen, zu validieren mit dem per E-Mail gesendeten Code

#### Request Body

| Name                                          | Type   | Description                   |
| --------------------------------------------- | ------ | ----------------------------- |
| email<mark style="color:red;">\*</mark>       | String | E-Mail des Nutzers            |
| code<mark style="color:red;">\*</mark>        |        | Der per E-Mail gesendete Code |
| newPassword<mark style="color:red;">\*</mark> | String | Das neue Passwort             |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}

{% tab title="400: Bad Request" %}
Missing information
{% endtab %}

{% tab title="401: Unauthorized " %}
Der Code stimmt nicht mit dem per E-Mail gesendet überein
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jo-dev.gitbook.io/vokabeltrainer-api-docs/reference/api-reference/nutzer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
