Compare commits

...
9 Commits
Author SHA1 Message Date
Jonas Lochmann 4183ea615a Update dependencies 2023-05-08 02:00:00 +02:00
Jonas Lochmann e46f5bea3f Add account deletion API 2023-04-09 14:30:26 +02:00
Jonas Lochmann 05fac79849 Refactor signInByMailCode 2023-04-03 02:00:00 +02:00
Jonas Lochmann 1e5da1b95e Improve logging of mails during development mode 2023-04-03 02:00:00 +02:00
Jonas Lochmann dc5e2baebd Add deleting session durations when deleting families
For the automatic deletion, they were always already deleted.
However, for manual deletion, this is required.
2023-04-03 02:00:00 +02:00
Jonas Lochmann 73465ebe6e Update sequelize 2023-02-27 01:00:00 +01:00
Jonas Lochmann 98ee0fe94e Fix ReferenceError instead of ParseYesNoException 2022-12-12 01:00:00 +01:00
Jonas Lochmann d9a032823e Update dependencies 2022-12-12 01:00:00 +01:00
Jonas Lochmann ae044c19d6 Send ClientDataStatus after registering new device 2022-11-28 01:00:00 +01:00
39 changed files with 1579 additions and 375 deletions
+1 -2
View File
@@ -16,8 +16,7 @@ On a invalid request body: HTTP status code 400 Bad request
On a invalid add device token: HTTP status code 401 Unauthorized On a invalid add device token: HTTP status code 401 Unauthorized
On success: a JSON object with the properties ``deviceAuthToken`` and ``ownDeviceId``, On success: object with ``deviceAuthToken`` (string), ``ownDeviceId`` (string) and ``data`` (like a ``/sync/pull-status`` response)
both of the type string
## POST /child/update-primary-device ## POST /child/update-primary-device
+26 -2
View File
@@ -44,7 +44,7 @@ If the mail auth token is invalid/ expired: HTTP status code 401 Unauthorized
If there is already a user with the mail address of the mail auth token: HTTP status code 409 Conflict If there is already a user with the mail address of the mail auth token: HTTP status code 409 Conflict
On success: object with ``deviceAuthToken`` (string) and ``ownDeviceId`` (string) On success: object with ``deviceAuthToken`` (string), ``ownDeviceId`` (string) and ``data`` (like a ``/sync/pull-status`` response)
## POST /parent/sign-in-into-family ## POST /parent/sign-in-into-family
@@ -60,7 +60,7 @@ On a invalid request body: HTTP status code 400 Bad Request
If there is no user with the mail address of the mail auth token: HTTP status code 409 Conflict If there is no user with the mail address of the mail auth token: HTTP status code 409 Conflict
On success: object with ``deviceAuthToken`` (string) and ``ownDeviceId`` (string) On success: object with ``deviceAuthToken`` (string), ``ownDeviceId`` (string) and ``data`` (like a ``/sync/pull-status`` response)
## POST /parent/can-recover-password ## POST /parent/can-recover-password
@@ -194,3 +194,27 @@ If the ``secondPasswordHash`` is invalid: HTTP status code 401 Unauthorized
If the server does not support this request: HTTP status code 404 If the server does not support this request: HTTP status code 404
On success: ``{"token": "some string"}``; you should not make any assumptions about the token string On success: ``{"token": "some string"}``; you should not make any assumptions about the token string
## POST /parent/delete-account
Use this to delete an account. This includes the complete family registration
with users and devices. Due to that, all parents with a linked mail address
have to authenticate this action.
## request
see [this JSON schema](../schema/deleteaccountpayload.md)
## response
On success: HTTP status code 200
On a invalid request body: HTTP status code 400 Bad Request
On unknown device auth token: HTTP status code 401 Unauthorized
On missing parent authentication: HTTP status code 401 Unauthorized
On unrelated parent authentication: HTTP status code 401 Unauthorized
If a newer endpoint must be used/the client is too old: HTTP status code 410 Gone
@@ -18,6 +18,9 @@
}, },
"parentName": { "parentName": {
"type": "string" "type": "string"
},
"clientLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -0,0 +1,23 @@
{
"type": "object",
"properties": {
"deviceAuthToken": {
"type": "string"
},
"mailAuthTokens": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false,
"required": [
"deviceAuthToken",
"mailAuthTokens"
],
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "DeleteAccountPayload",
"$id": "https://timelimit.io/DeleteAccountPayload"
}
+4
View File
@@ -14,6 +14,8 @@
* [CreateRegisterDeviceTokenRequest](./createregisterdevicetokenrequest.md) `https://timelimit.io/CreateRegisterDeviceTokenRequest` * [CreateRegisterDeviceTokenRequest](./createregisterdevicetokenrequest.md) `https://timelimit.io/CreateRegisterDeviceTokenRequest`
* [DeleteAccountPayload](./deleteaccountpayload.md) `https://timelimit.io/DeleteAccountPayload`
* [FinishPurchaseByGooglePlayRequest](./finishpurchasebygoogleplayrequest.md) `https://timelimit.io/FinishPurchaseByGooglePlayRequest` * [FinishPurchaseByGooglePlayRequest](./finishpurchasebygoogleplayrequest.md) `https://timelimit.io/FinishPurchaseByGooglePlayRequest`
* [IdentityTokenPayload](./identitytokenpayload.md) `https://timelimit.io/IdentityTokenPayload` * [IdentityTokenPayload](./identitytokenpayload.md) `https://timelimit.io/IdentityTokenPayload`
@@ -282,6 +284,8 @@
* [Untitled array in ClientPushChangesRequest](./clientpushchangesrequest-properties-actions.md) `https://timelimit.io/ClientPushChangesRequest#/properties/actions` * [Untitled array in ClientPushChangesRequest](./clientpushchangesrequest-properties-actions.md) `https://timelimit.io/ClientPushChangesRequest#/properties/actions`
* [Untitled array in DeleteAccountPayload](./deleteaccountpayload-properties-mailauthtokens.md) `https://timelimit.io/DeleteAccountPayload#/properties/mailAuthTokens`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddinstalledappsaction-properties-apps.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddInstalledAppsAction/properties/apps` * [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddinstalledappsaction-properties-apps.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddInstalledAppsAction/properties/apps`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i` * [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i`
@@ -9,6 +9,9 @@
}, },
"deviceName": { "deviceName": {
"type": "string" "type": "string"
},
"clientLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -9,6 +9,9 @@
}, },
"deviceName": { "deviceName": {
"type": "string" "type": "string"
},
"clientLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -0,0 +1,15 @@
# Untitled number in CreateFamilyByMailTokenRequest Schema
```txt
https://timelimit.io/CreateFamilyByMailTokenRequest#/properties/clientLevel
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :---------------------------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [CreateFamilyByMailTokenRequest.schema.json\*](CreateFamilyByMailTokenRequest.schema.json "open original schema") |
## clientLevel Type
`number`
@@ -24,6 +24,7 @@ https://timelimit.io/CreateFamilyByMailTokenRequest
| [deviceName](#devicename) | `string` | Required | cannot be null | [CreateFamilyByMailTokenRequest](createfamilybymailtokenrequest-properties-devicename.md "https://timelimit.io/CreateFamilyByMailTokenRequest#/properties/deviceName") | | [deviceName](#devicename) | `string` | Required | cannot be null | [CreateFamilyByMailTokenRequest](createfamilybymailtokenrequest-properties-devicename.md "https://timelimit.io/CreateFamilyByMailTokenRequest#/properties/deviceName") |
| [timeZone](#timezone) | `string` | Required | cannot be null | [CreateFamilyByMailTokenRequest](createfamilybymailtokenrequest-properties-timezone.md "https://timelimit.io/CreateFamilyByMailTokenRequest#/properties/timeZone") | | [timeZone](#timezone) | `string` | Required | cannot be null | [CreateFamilyByMailTokenRequest](createfamilybymailtokenrequest-properties-timezone.md "https://timelimit.io/CreateFamilyByMailTokenRequest#/properties/timeZone") |
| [parentName](#parentname) | `string` | Required | cannot be null | [CreateFamilyByMailTokenRequest](createfamilybymailtokenrequest-properties-parentname.md "https://timelimit.io/CreateFamilyByMailTokenRequest#/properties/parentName") | | [parentName](#parentname) | `string` | Required | cannot be null | [CreateFamilyByMailTokenRequest](createfamilybymailtokenrequest-properties-parentname.md "https://timelimit.io/CreateFamilyByMailTokenRequest#/properties/parentName") |
| [clientLevel](#clientlevel) | `number` | Optional | cannot be null | [CreateFamilyByMailTokenRequest](createfamilybymailtokenrequest-properties-clientlevel.md "https://timelimit.io/CreateFamilyByMailTokenRequest#/properties/clientLevel") |
## mailAuthToken ## mailAuthToken
@@ -133,6 +134,24 @@ https://timelimit.io/CreateFamilyByMailTokenRequest
`string` `string`
## clientLevel
`clientLevel`
* is optional
* Type: `number`
* cannot be null
* defined in: [CreateFamilyByMailTokenRequest](createfamilybymailtokenrequest-properties-clientlevel.md "https://timelimit.io/CreateFamilyByMailTokenRequest#/properties/clientLevel")
### clientLevel Type
`number`
# CreateFamilyByMailTokenRequest Definitions # CreateFamilyByMailTokenRequest Definitions
## Definitions group PlaintextParentPassword ## Definitions group PlaintextParentPassword
@@ -0,0 +1,15 @@
# Untitled undefined type in DeleteAccountPayload Schema
```txt
https://timelimit.io/DeleteAccountPayload#/definitions
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :-------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [DeleteAccountPayload.schema.json\*](DeleteAccountPayload.schema.json "open original schema") |
## definitions Type
unknown
@@ -0,0 +1,15 @@
# Untitled string in DeleteAccountPayload Schema
```txt
https://timelimit.io/DeleteAccountPayload#/properties/deviceAuthToken
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :-------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [DeleteAccountPayload.schema.json\*](DeleteAccountPayload.schema.json "open original schema") |
## deviceAuthToken Type
`string`
@@ -0,0 +1,15 @@
# Untitled string in DeleteAccountPayload Schema
```txt
https://timelimit.io/DeleteAccountPayload#/properties/mailAuthTokens/items
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :-------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [DeleteAccountPayload.schema.json\*](DeleteAccountPayload.schema.json "open original schema") |
## items Type
`string`
@@ -0,0 +1,15 @@
# Untitled array in DeleteAccountPayload Schema
```txt
https://timelimit.io/DeleteAccountPayload#/properties/mailAuthTokens
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :-------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [DeleteAccountPayload.schema.json\*](DeleteAccountPayload.schema.json "open original schema") |
## mailAuthTokens Type
`string[]`
+60
View File
@@ -0,0 +1,60 @@
# DeleteAccountPayload Schema
```txt
https://timelimit.io/DeleteAccountPayload
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :----------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------ |
| Can be instantiated | Yes | Unknown status | No | Forbidden | Forbidden | none | [DeleteAccountPayload.schema.json](DeleteAccountPayload.schema.json "open original schema") |
## DeleteAccountPayload Type
`object` ([DeleteAccountPayload](deleteaccountpayload.md))
# DeleteAccountPayload Properties
| Property | Type | Required | Nullable | Defined by |
| :---------------------------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
| [deviceAuthToken](#deviceauthtoken) | `string` | Required | cannot be null | [DeleteAccountPayload](deleteaccountpayload-properties-deviceauthtoken.md "https://timelimit.io/DeleteAccountPayload#/properties/deviceAuthToken") |
| [mailAuthTokens](#mailauthtokens) | `array` | Required | cannot be null | [DeleteAccountPayload](deleteaccountpayload-properties-mailauthtokens.md "https://timelimit.io/DeleteAccountPayload#/properties/mailAuthTokens") |
## deviceAuthToken
`deviceAuthToken`
* is required
* Type: `string`
* cannot be null
* defined in: [DeleteAccountPayload](deleteaccountpayload-properties-deviceauthtoken.md "https://timelimit.io/DeleteAccountPayload#/properties/deviceAuthToken")
### deviceAuthToken Type
`string`
## mailAuthTokens
`mailAuthTokens`
* is required
* Type: `string[]`
* cannot be null
* defined in: [DeleteAccountPayload](deleteaccountpayload-properties-mailauthtokens.md "https://timelimit.io/DeleteAccountPayload#/properties/mailAuthTokens")
### mailAuthTokens Type
`string[]`
# DeleteAccountPayload Definitions
@@ -0,0 +1,15 @@
# Untitled number in RegisterChildDeviceRequest Schema
```txt
https://timelimit.io/RegisterChildDeviceRequest#/properties/clientLevel
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :-------------------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [RegisterChildDeviceRequest.schema.json\*](RegisterChildDeviceRequest.schema.json "open original schema") |
## clientLevel Type
`number`
+19
View File
@@ -21,6 +21,7 @@ https://timelimit.io/RegisterChildDeviceRequest
| [registerToken](#registertoken) | `string` | Required | cannot be null | [RegisterChildDeviceRequest](registerchilddevicerequest-properties-registertoken.md "https://timelimit.io/RegisterChildDeviceRequest#/properties/registerToken") | | [registerToken](#registertoken) | `string` | Required | cannot be null | [RegisterChildDeviceRequest](registerchilddevicerequest-properties-registertoken.md "https://timelimit.io/RegisterChildDeviceRequest#/properties/registerToken") |
| [childDevice](#childdevice) | `object` | Required | cannot be null | [RegisterChildDeviceRequest](registerchilddevicerequest-definitions-newdeviceinfo.md "https://timelimit.io/RegisterChildDeviceRequest#/properties/childDevice") | | [childDevice](#childdevice) | `object` | Required | cannot be null | [RegisterChildDeviceRequest](registerchilddevicerequest-definitions-newdeviceinfo.md "https://timelimit.io/RegisterChildDeviceRequest#/properties/childDevice") |
| [deviceName](#devicename) | `string` | Required | cannot be null | [RegisterChildDeviceRequest](registerchilddevicerequest-properties-devicename.md "https://timelimit.io/RegisterChildDeviceRequest#/properties/deviceName") | | [deviceName](#devicename) | `string` | Required | cannot be null | [RegisterChildDeviceRequest](registerchilddevicerequest-properties-devicename.md "https://timelimit.io/RegisterChildDeviceRequest#/properties/deviceName") |
| [clientLevel](#clientlevel) | `number` | Optional | cannot be null | [RegisterChildDeviceRequest](registerchilddevicerequest-properties-clientlevel.md "https://timelimit.io/RegisterChildDeviceRequest#/properties/clientLevel") |
## registerToken ## registerToken
@@ -76,6 +77,24 @@ https://timelimit.io/RegisterChildDeviceRequest
`string` `string`
## clientLevel
`clientLevel`
* is optional
* Type: `number`
* cannot be null
* defined in: [RegisterChildDeviceRequest](registerchilddevicerequest-properties-clientlevel.md "https://timelimit.io/RegisterChildDeviceRequest#/properties/clientLevel")
### clientLevel Type
`number`
# RegisterChildDeviceRequest Definitions # RegisterChildDeviceRequest Definitions
## Definitions group NewDeviceInfo ## Definitions group NewDeviceInfo
@@ -0,0 +1,15 @@
# Untitled number in SignIntoFamilyRequest Schema
```txt
https://timelimit.io/SignIntoFamilyRequest#/properties/clientLevel
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :---------------------------------------------------------------------------------------------- |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [SignIntoFamilyRequest.schema.json\*](SignIntoFamilyRequest.schema.json "open original schema") |
## clientLevel Type
`number`
+19
View File
@@ -21,6 +21,7 @@ https://timelimit.io/SignIntoFamilyRequest
| [mailAuthToken](#mailauthtoken) | `string` | Required | cannot be null | [SignIntoFamilyRequest](signintofamilyrequest-properties-mailauthtoken.md "https://timelimit.io/SignIntoFamilyRequest#/properties/mailAuthToken") | | [mailAuthToken](#mailauthtoken) | `string` | Required | cannot be null | [SignIntoFamilyRequest](signintofamilyrequest-properties-mailauthtoken.md "https://timelimit.io/SignIntoFamilyRequest#/properties/mailAuthToken") |
| [parentDevice](#parentdevice) | `object` | Required | cannot be null | [SignIntoFamilyRequest](signintofamilyrequest-definitions-newdeviceinfo.md "https://timelimit.io/SignIntoFamilyRequest#/properties/parentDevice") | | [parentDevice](#parentdevice) | `object` | Required | cannot be null | [SignIntoFamilyRequest](signintofamilyrequest-definitions-newdeviceinfo.md "https://timelimit.io/SignIntoFamilyRequest#/properties/parentDevice") |
| [deviceName](#devicename) | `string` | Required | cannot be null | [SignIntoFamilyRequest](signintofamilyrequest-properties-devicename.md "https://timelimit.io/SignIntoFamilyRequest#/properties/deviceName") | | [deviceName](#devicename) | `string` | Required | cannot be null | [SignIntoFamilyRequest](signintofamilyrequest-properties-devicename.md "https://timelimit.io/SignIntoFamilyRequest#/properties/deviceName") |
| [clientLevel](#clientlevel) | `number` | Optional | cannot be null | [SignIntoFamilyRequest](signintofamilyrequest-properties-clientlevel.md "https://timelimit.io/SignIntoFamilyRequest#/properties/clientLevel") |
## mailAuthToken ## mailAuthToken
@@ -76,6 +77,24 @@ https://timelimit.io/SignIntoFamilyRequest
`string` `string`
## clientLevel
`clientLevel`
* is optional
* Type: `number`
* cannot be null
* defined in: [SignIntoFamilyRequest](signintofamilyrequest-properties-clientlevel.md "https://timelimit.io/SignIntoFamilyRequest#/properties/clientLevel")
### clientLevel Type
`number`
# SignIntoFamilyRequest Definitions # SignIntoFamilyRequest Definitions
## Definitions group NewDeviceInfo ## Definitions group NewDeviceInfo
+192
View File
@@ -0,0 +1,192 @@
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>
</title>
<!--[if !mso]><!-->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--<![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
#outlook a {
padding: 0;
}
body {
margin: 0;
padding: 0;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
table,
td {
border-collapse: collapse;
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
}
img {
border: 0;
height: auto;
line-height: 100%;
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
}
p {
display: block;
margin: 13px 0;
}
</style>
<!--[if mso]>
<noscript>
<xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml>
</noscript>
<![endif]-->
<!--[if lte mso 11]>
<style type="text/css">
.mj-outlook-group-fix { width:100% !important; }
</style>
<![endif]-->
<!--[if !mso]><!-->
<!--<![endif]-->
<style type="text/css">
@media only screen and (min-width:480px) {
.mj-column-per-100 {
width: 100% !important;
max-width: 100%;
}
}
</style>
<style media="screen and (min-width:480px)">
.moz-text-html .mj-column-per-100 {
width: 100% !important;
max-width: 100%;
}
</style>
<style type="text/css">
</style>
</head>
<body style="word-spacing:normal;">
<div style="">
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" bgcolor="#009688" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div style="background:#009688;background-color:#009688;margin:0px auto;max-width:600px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#009688;background-color:#009688;width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]-->
<div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:20px;line-height:1;text-align:left;color:#ffffff;">TimeLimit</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div style="margin:0px auto;max-width:600px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]-->
<div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">
<p> Sie haben eine Löschung Ihres Benutzerkontos angefordert. Diese wurde soeben durchgeführt. </p>
<p> You requested the deletion of your account. This deletion is finished now. </p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div style="margin:0px auto;max-width:600px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]-->
<div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<p style="border-top:dashed 1px lightgrey;font-size:1px;margin:0px auto;width:100%;">
</p>
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:dashed 1px lightgrey;font-size:1px;margin:0px auto;width:550px;" role="presentation" width="550px" ><tr><td style="height:0;line-height:0;"> &nbsp;
</td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div style="margin:0px auto;max-width:600px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:20px 0;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:600px;" ><![endif]-->
<div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">
<p> Sie erhalten diese Nachricht aufgrund Ihrer Anfrage. Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten. </p>
<p> You got this mail due to your request. If you have got any questions, then you can reply to this message. </p>
<p> &copy; <%= mailimprint %> </p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</div>
</body>
</html>
@@ -0,0 +1,44 @@
<mjml>
<mj-body>
<mj-section background-color="#009688">
<mj-column>
<mj-text font-size="20px" color="#ffffff">TimeLimit</mj-text>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-text>
<p>
Sie haben eine Löschung Ihres Benutzerkontos angefordert. Diese wurde soeben durchgeführt.
</p>
<p>
You requested the deletion of your account. This deletion is finished now.
</p>
</mj-text>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-divider border-width="1px" border-style="dashed" border-color="lightgrey" />
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-text>
<p>
Sie erhalten diese Nachricht aufgrund Ihrer Anfrage.
Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten.
</p>
<p>
You got this mail due to your request.
If you have got any questions, then you can reply to this message.
</p>
<p>
&copy; <%= mailimprint %>
</p>
</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
+1
View File
@@ -0,0 +1 @@
Konto gelöscht/Account deleted
+13
View File
@@ -0,0 +1,13 @@
Sie haben eine Löschung Ihres Benutzerkontos angefordert. Diese wurde soeben durchgeführt.
You requested the deletion of your account. This deletion is finished now.
----------------------
Sie erhalten diese Nachricht aufgrund Ihrer Anfrage.
Falls Sie Fragen haben können Sie einfach auf diese E-Mail antworten.
You got this mail due to your request.
If you have got any questions, then you can reply to this message.
<C> <%- mailimprint %>
+616 -222
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2023 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -43,7 +43,8 @@ const types = [
'RequestWithAuthToken', 'RequestWithAuthToken',
'SendMailLoginCodeRequest', 'SendMailLoginCodeRequest',
'SignInByMailCodeRequest', 'SignInByMailCodeRequest',
'IdentityTokenPayload' 'IdentityTokenPayload',
'DeleteAccountPayload',
] ]
const docOnlyTypes = [ const docOnlyTypes = [
+9 -5
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 Jonas Lochmann * Copyright (C) 2019 - 2022 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -24,10 +24,12 @@ import { logoutAtPrimaryDevice } from '../function/child/logout-at-primary-devic
import { setPrimaryDevice } from '../function/child/set-primary-device' import { setPrimaryDevice } from '../function/child/set-primary-device'
import { WebsocketApi } from '../websocket' import { WebsocketApi } from '../websocket'
import { isRegisterChildDeviceRequest, isRequestWithAuthToken, isUpdatePrimaryDeviceRequest } from './validator' import { isRegisterChildDeviceRequest, isRequestWithAuthToken, isUpdatePrimaryDeviceRequest } from './validator'
import { EventHandler } from '../monitoring/eventhandler'
export const createChildRouter = ({ database, websocket }: { export const createChildRouter = ({ database, websocket, eventHandler }: {
database: Database, database: Database
websocket: WebsocketApi websocket: WebsocketApi
eventHandler: EventHandler
}) => { }) => {
const router = Router() const router = Router()
@@ -37,15 +39,17 @@ export const createChildRouter = ({ database, websocket }: {
throw new BadRequest() throw new BadRequest()
} }
const { deviceAuthToken, deviceId } = await addChildDevice({ const { deviceAuthToken, deviceId, data } = await addChildDevice({
request: req.body, request: req.body,
database, database,
eventHandler,
websocket websocket
}) })
res.json({ res.json({
deviceAuthToken, deviceAuthToken,
ownDeviceId: deviceId ownDeviceId: deviceId,
data
}) })
} catch (ex) { } catch (ex) {
next(ex) next(ex)
+3 -3
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann * Copyright (C) 2019 - 2022 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -47,8 +47,8 @@ export const createApi = ({ database, websocket, connectedDevicesManager, eventH
}) })
app.use('/auth', createAuthRouter(database)) app.use('/auth', createAuthRouter(database))
app.use('/child', createChildRouter({ database, websocket })) app.use('/child', createChildRouter({ database, websocket, eventHandler }))
app.use('/parent', createParentRouter({ database, websocket })) app.use('/parent', createParentRouter({ database, websocket, eventHandler }))
app.use('/purchase', createPurchaseRouter({ database, websocket })) app.use('/purchase', createPurchaseRouter({ database, websocket }))
app.use('/sync', createSyncRouter({ database, websocket, connectedDevicesManager, eventHandler })) app.use('/sync', createSyncRouter({ database, websocket, connectedDevicesManager, eventHandler }))
+35 -6
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2023 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -21,6 +21,7 @@ import { Router } from 'express'
import { BadRequest, Forbidden, Unauthorized } from 'http-errors' import { BadRequest, Forbidden, Unauthorized } from 'http-errors'
import { config } from '../config' import { config } from '../config'
import { Database, Transaction } from '../database' import { Database, Transaction } from '../database'
import { deleteAccount } from '../function/cleanup/account-deletion'
import { removeDevice } from '../function/device/remove-device' import { removeDevice } from '../function/device/remove-device'
import { createAddDeviceToken } from '../function/parent/create-add-device-token' import { createAddDeviceToken } from '../function/parent/create-add-device-token'
import { createFamily } from '../function/parent/create-family' import { createFamily } from '../function/parent/create-family'
@@ -31,14 +32,22 @@ import { signInIntoFamily } from '../function/parent/sign-in-into-family'
import { validateU2fIntegrity, U2fValidationError } from '../function/u2f' import { validateU2fIntegrity, U2fValidationError } from '../function/u2f'
import { createIdentityToken, MissingSignSecretException } from '../util/identity-token' import { createIdentityToken, MissingSignSecretException } from '../util/identity-token'
import { WebsocketApi } from '../websocket' import { WebsocketApi } from '../websocket'
import { EventHandler } from '../monitoring/eventhandler'
import { import {
isCreateFamilyByMailTokenRequest, isCreateFamilyByMailTokenRequest,
isCreateRegisterDeviceTokenRequest, isLinkParentMailAddressRequest, isCreateRegisterDeviceTokenRequest, isLinkParentMailAddressRequest,
isMailAuthTokenRequestBody, isRecoverParentPasswordRequest, isMailAuthTokenRequestBody, isRecoverParentPasswordRequest,
isRemoveDeviceRequest, isSignIntoFamilyRequest, isRequestIdentityTokenRequest isRemoveDeviceRequest, isSignIntoFamilyRequest, isRequestIdentityTokenRequest,
isDeleteAccountPayload
} from './validator' } from './validator'
export const createParentRouter = ({ database, websocket }: {database: Database, websocket: WebsocketApi}) => { export const createParentRouter = ({
database, websocket, eventHandler
}: {
database: Database
websocket: WebsocketApi
eventHandler: EventHandler
}) => {
const router = Router() const router = Router()
router.post('/get-status-by-mail-address', json(), async (req, res, next) => { router.post('/get-status-by-mail-address', json(), async (req, res, next) => {
@@ -75,17 +84,20 @@ export const createParentRouter = ({ database, websocket }: {database: Database,
const result = await createFamily({ const result = await createFamily({
database, database,
eventHandler,
firstParentDevice: req.body.parentDevice, firstParentDevice: req.body.parentDevice,
mailAuthToken: req.body.mailAuthToken, mailAuthToken: req.body.mailAuthToken,
password: req.body.parentPassword, password: req.body.parentPassword,
deviceName: req.body.deviceName, deviceName: req.body.deviceName,
parentName: req.body.parentName, parentName: req.body.parentName,
timeZone: req.body.timeZone timeZone: req.body.timeZone,
clientLevel: req.body.clientLevel || null
}) })
res.json({ res.json({
deviceAuthToken: result.deviceAuthToken, deviceAuthToken: result.deviceAuthToken,
ownDeviceId: result.deviceId ownDeviceId: result.deviceId,
data: result.data
}) })
} catch (ex) { } catch (ex) {
next(ex) next(ex)
@@ -100,15 +112,18 @@ export const createParentRouter = ({ database, websocket }: {database: Database,
const result = await signInIntoFamily({ const result = await signInIntoFamily({
database, database,
eventHandler,
newDeviceInfo: req.body.parentDevice, newDeviceInfo: req.body.parentDevice,
mailAuthToken: req.body.mailAuthToken, mailAuthToken: req.body.mailAuthToken,
deviceName: req.body.deviceName, deviceName: req.body.deviceName,
clientLevel: req.body.clientLevel || null,
websocket websocket
}) })
res.json({ res.json({
deviceAuthToken: result.deviceAuthToken, deviceAuthToken: result.deviceAuthToken,
ownDeviceId: result.deviceId ownDeviceId: result.deviceId,
data: result.data
}) })
} catch (ex) { } catch (ex) {
next(ex) next(ex)
@@ -343,5 +358,19 @@ export const createParentRouter = ({ database, websocket }: {database: Database,
} }
}) })
router.post('/delete-account', json(), async (req, res, next) => {
try {
if (!isDeleteAccountPayload(req.body)) {
throw new BadRequest()
}
await deleteAccount({ database, request: req.body, websocket })
res.sendStatus(200)
} catch (ex) {
next(ex)
}
})
return router return router
} }
+9 -1
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2023 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -84,12 +84,14 @@ export interface CreateFamilyByMailTokenRequest {
deviceName: string deviceName: string
timeZone: string timeZone: string
parentName: string parentName: string
clientLevel?: number
} }
export interface SignIntoFamilyRequest { export interface SignIntoFamilyRequest {
mailAuthToken: string mailAuthToken: string
parentDevice: NewDeviceInfo parentDevice: NewDeviceInfo
deviceName: string deviceName: string
clientLevel?: number
} }
export interface RecoverParentPasswordRequest { export interface RecoverParentPasswordRequest {
@@ -101,6 +103,7 @@ export interface RegisterChildDeviceRequest {
registerToken: string registerToken: string
childDevice: NewDeviceInfo childDevice: NewDeviceInfo
deviceName: string deviceName: string
clientLevel?: number
} }
export interface CreateRegisterDeviceTokenRequest { export interface CreateRegisterDeviceTokenRequest {
@@ -173,5 +176,10 @@ export type IdentityTokenPayload = IdentityTokenCreatePayload & {
exp: number exp: number
} }
export interface DeleteAccountPayload {
deviceAuthToken: string
mailAuthTokens: Array<string>
}
export { SerializedParentAction, SerializedChildAction, SerializedAppLogicAction } from '../action/serialization' export { SerializedParentAction, SerializedChildAction, SerializedAppLogicAction } from '../action/serialization'
export { ServerDataStatus } from '../object/serverdatastatus' export { ServerDataStatus } from '../object/serverdatastatus'
+31 -1
View File
@@ -1,5 +1,5 @@
// tslint:disable // tslint:disable
import { ClientPushChangesRequest, ClientPullChangesRequest, MailAuthTokenRequestBody, CreateFamilyByMailTokenRequest, SignIntoFamilyRequest, RecoverParentPasswordRequest, RegisterChildDeviceRequest, SerializedParentAction, SerializedAppLogicAction, SerializedChildAction, CreateRegisterDeviceTokenRequest, CanDoPurchaseRequest, FinishPurchaseByGooglePlayRequest, LinkParentMailAddressRequest, UpdatePrimaryDeviceRequest, RemoveDeviceRequest, RequestIdentityTokenRequest, RequestWithAuthToken, SendMailLoginCodeRequest, SignInByMailCodeRequest, IdentityTokenPayload } from './schema' import { ClientPushChangesRequest, ClientPullChangesRequest, MailAuthTokenRequestBody, CreateFamilyByMailTokenRequest, SignIntoFamilyRequest, RecoverParentPasswordRequest, RegisterChildDeviceRequest, SerializedParentAction, SerializedAppLogicAction, SerializedChildAction, CreateRegisterDeviceTokenRequest, CanDoPurchaseRequest, FinishPurchaseByGooglePlayRequest, LinkParentMailAddressRequest, UpdatePrimaryDeviceRequest, RemoveDeviceRequest, RequestIdentityTokenRequest, RequestWithAuthToken, SendMailLoginCodeRequest, SignInByMailCodeRequest, IdentityTokenPayload, DeleteAccountPayload } from './schema'
import Ajv from 'ajv' import Ajv from 'ajv'
const ajv = new Ajv() const ajv = new Ajv()
@@ -2930,6 +2930,9 @@ export const isCreateFamilyByMailTokenRequest: (value: unknown) => value is Crea
}, },
"parentName": { "parentName": {
"type": "string" "type": "string"
},
"clientLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -2955,6 +2958,9 @@ export const isSignIntoFamilyRequest: (value: unknown) => value is SignIntoFamil
}, },
"deviceName": { "deviceName": {
"type": "string" "type": "string"
},
"clientLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -2995,6 +3001,9 @@ export const isRegisterChildDeviceRequest: (value: unknown) => value is Register
}, },
"deviceName": { "deviceName": {
"type": "string" "type": "string"
},
"clientLevel": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -3484,3 +3493,24 @@ export const isIdentityTokenPayload: (value: unknown) => value is IdentityTokenP
"definitions": definitions, "definitions": definitions,
"$schema": "http://json-schema.org/draft-07/schema#" "$schema": "http://json-schema.org/draft-07/schema#"
}) })
export const isDeleteAccountPayload: (value: unknown) => value is DeleteAccountPayload = ajv.compile({
"type": "object",
"properties": {
"deviceAuthToken": {
"type": "string"
},
"mailAuthTokens": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false,
"required": [
"deviceAuthToken",
"mailAuthTokens"
],
"definitions": definitions,
"$schema": "http://json-schema.org/draft-07/schema#"
})
+2 -2
View File
@@ -34,6 +34,8 @@ function parseYesNo (value: string) {
} }
} }
class ParseYesNoException extends Error {}
export const config: Config = { export const config: Config = {
mailWhitelist: (process.env.MAIL_WHITELIST || '').split(',').map((item) => item.trim()).filter((item) => item.length > 0), mailWhitelist: (process.env.MAIL_WHITELIST || '').split(',').map((item) => item.trim()).filter((item) => item.length > 0),
disableSignup: parseYesNo(process.env.DISABLE_SIGNUP || 'no'), disableSignup: parseYesNo(process.env.DISABLE_SIGNUP || 'no'),
@@ -41,5 +43,3 @@ export const config: Config = {
alwaysPro: process.env.ALWAYS_PRO ? parseYesNo(process.env.ALWAYS_PRO) : false, alwaysPro: process.env.ALWAYS_PRO ? parseYesNo(process.env.ALWAYS_PRO) : false,
signSecret: process.env.SIGN_SECRET || '' signSecret: process.env.SIGN_SECRET || ''
} }
class ParseYesNoException extends Error {}
+7 -5
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2021 Jonas Lochmann * Copyright (C) 2019 - 2023 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -109,7 +109,7 @@ export const signInByMailCode = async ({ mailLoginToken, receivedCode, database
database: Database database: Database
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}): Promise<{ mailAuthToken: string }> => { }): Promise<{ mailAuthToken: string }> => {
return database.transaction(async (transaction) => { const result = await database.transaction(async (transaction) => {
const entry = await database.mailLoginToken.findOne({ const entry = await database.mailLoginToken.findOne({
where: { where: {
mailLoginToken mailLoginToken
@@ -127,9 +127,9 @@ export const signInByMailCode = async ({ mailLoginToken, receivedCode, database
await entry.save({ transaction }) await entry.save({ transaction })
if (entry.remainingAttempts === 0) { if (entry.remainingAttempts === 0) {
throw new Gone() return () => { throw new Gone() }
} else { } else {
throw new Forbidden() return () => { throw new Forbidden() }
} }
} }
@@ -151,6 +151,8 @@ export const signInByMailCode = async ({ mailLoginToken, receivedCode, database
transaction transaction
}) })
return { mailAuthToken } return () => ({ mailAuthToken })
}) })
return result()
} }
+22 -3
View File
@@ -22,13 +22,22 @@ import { generateAuthToken, generateVersionId } from '../../util/token'
import { WebsocketApi } from '../../websocket' import { WebsocketApi } from '../../websocket'
import { prepareDeviceEntry } from '../device/prepare-device-entry' import { prepareDeviceEntry } from '../device/prepare-device-entry'
import { notifyClientsAboutChangesDelayed } from '../websocket' import { notifyClientsAboutChangesDelayed } from '../websocket'
import { generateServerDataStatus } from '../sync/get-server-data-status'
import { EventHandler } from '../../monitoring/eventhandler'
import { ServerDataStatus } from '../../object/serverdatastatus'
import { createEmptyClientDataStatus } from '../../object/clientdatastatus'
export const addChildDevice = async ({ database, websocket, request }: { export const addChildDevice = async ({ database, eventHandler, websocket, request }: {
database: Database database: Database
eventHandler: EventHandler
websocket: WebsocketApi websocket: WebsocketApi
request: RegisterChildDeviceRequest request: RegisterChildDeviceRequest
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}) => { }): Promise<{
deviceId: string
deviceAuthToken: string
data: ServerDataStatus
}> => {
return database.transaction(async (transaction) => { return database.transaction(async (transaction) => {
const entry = await database.addDeviceToken.findOne({ const entry = await database.addDeviceToken.findOne({
where: { where: {
@@ -75,9 +84,19 @@ export const addChildDevice = async ({ database, websocket, request }: {
transaction transaction
}) })
const data = await generateServerDataStatus({
database,
clientStatus: createEmptyClientDataStatus({ clientLevel: request.clientLevel || null }),
familyId: entry.familyId,
deviceId,
transaction,
eventHandler
})
return { return {
deviceId, deviceId,
deviceAuthToken deviceAuthToken,
data
} }
}) })
} }
+107
View File
@@ -0,0 +1,107 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2023 Jonas Lochmann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Unauthorized } from 'http-errors'
import { DeleteAccountPayload } from '../../api/schema'
import { Database } from '../../database'
import { sendAccountDeletedMail } from '../../util/mail'
import { WebsocketApi } from '../../websocket'
import { requireMailAndLocaleByAuthToken } from '../authentication'
import { deleteFamilies } from './delete-families'
export async function deleteAccount({ request, database, websocket }: {
request: DeleteAccountPayload
database: Database
websocket: WebsocketApi
}) {
await database.transaction(async (transaction) => {
const deviceEntryUnsafe = await database.device.findOne({
where: { deviceAuthToken: request.deviceAuthToken },
attributes: ['familyId'],
transaction
})
if (!deviceEntryUnsafe) {
throw new Unauthorized()
}
const deviceEntry = {
familyId: deviceEntryUnsafe.familyId
}
const userEntries = (await database.user.findAll({
where: {
familyId: deviceEntry.familyId,
type: 'parent'
},
attributes: ['mail'],
transaction
})).map((item) => ({ mail: item.mail }))
const registeredMailAddresses = new Set<string>()
userEntries.forEach((item) => {
if (item.mail !== '') registeredMailAddresses.add(item.mail)
})
const authenticatedMailAddresses = new Set<string>()
for (const mailAuthToken of request.mailAuthTokens) {
const info = await requireMailAndLocaleByAuthToken({
mailAuthToken,
database,
transaction,
invalidate: true
})
if (!registeredMailAddresses.has(info.mail)) throw new Unauthorized()
authenticatedMailAddresses.add(info.mail)
}
if (registeredMailAddresses.size !== authenticatedMailAddresses.size) throw new Unauthorized()
registeredMailAddresses.forEach((mail) => {
if (!authenticatedMailAddresses.has(mail)) throw new Unauthorized()
})
const deviceEntries = (await database.device.findAll({
where: {
familyId: deviceEntry.familyId
},
transaction,
attributes: ['deviceAuthToken']
})).map((item) => ({ deviceAuthToken: item.deviceAuthToken }))
await deleteFamilies({ database, transaction, familiyIds: [deviceEntry.familyId] })
transaction.afterCommit(() => {
for (const device of deviceEntries) {
websocket.triggerSyncByDeviceAuthToken({
deviceAuthToken: device.deviceAuthToken,
isImportant: true
})
}
registeredMailAddresses.forEach((receiver) => {
sendAccountDeletedMail({ receiver }).catch((ex) => {
console.warn('failure while sending account deletion confirmation', ex)
})
})
})
})
}
+110 -101
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2023 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -17,10 +17,11 @@
import { difference } from 'lodash' import { difference } from 'lodash'
import * as Sequelize from 'sequelize' import * as Sequelize from 'sequelize'
import { Database } from '../../database' import { Database, Transaction } from '../../database'
export async function deleteFamilies ({ database, familiyIds }: { export async function deleteFamilies ({ database, transaction, familiyIds }: {
database: Database database: Database
transaction: Transaction
familiyIds: Array<string> familiyIds: Array<string>
// no transaction here because this should run isolated // no transaction here because this should run isolated
}) { }) {
@@ -28,118 +29,126 @@ export async function deleteFamilies ({ database, familiyIds }: {
return return
} }
await database.transaction(async (transaction) => { // category
// category await database.category.destroy({
await database.category.destroy({ where: {
where: { familyId: {
familyId: { [Sequelize.Op.in]: familiyIds
[Sequelize.Op.in]: familiyIds }
} },
}, transaction
transaction })
})
// categoryapp // categoryapp
await database.categoryApp.destroy({ await database.categoryApp.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction
}) })
// purchase // purchase
await database.purchase.destroy({ await database.purchase.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction
}) })
// timelimitrule // timelimitrule
await database.timelimitRule.destroy({ await database.timelimitRule.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction
}) })
// usedtime // usedtime
await database.usedTime.destroy({ await database.usedTime.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction
}) })
// user // session durations
await database.user.destroy({ await database.sessionDuration.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction
}) })
// device // user
const oldDeviceAuthTokens = (await database.device.findAll({ await database.user.destroy({
where: {
familyId: {
[Sequelize.Op.in]: familiyIds
}
},
transaction
})
// device
const oldDeviceAuthTokens = (await database.device.findAll({
where: {
familyId: {
[Sequelize.Op.in]: familiyIds
}
},
attributes: ['deviceAuthToken'],
transaction
})).map((item) => item.deviceAuthToken)
await database.device.destroy({
where: {
familyId: {
[Sequelize.Op.in]: familiyIds
}
},
transaction
})
// olddevice
if (oldDeviceAuthTokens.length > 0) {
const knownOldDeviceAuthTokens = (await database.oldDevice.findAll({
where: { where: {
familyId: { deviceAuthToken: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: oldDeviceAuthTokens
} }
}, },
attributes: ['deviceAuthToken'],
transaction transaction
})).map((item) => item.deviceAuthToken) })).map((item) => item.deviceAuthToken)
await database.device.destroy({ const oldDeviceAuthTokensToAdd = difference(oldDeviceAuthTokens, knownOldDeviceAuthTokens)
where: {
familyId: {
[Sequelize.Op.in]: familiyIds
}
},
transaction
})
// olddevice if (oldDeviceAuthTokensToAdd.length > 0) {
if (oldDeviceAuthTokens.length > 0) { await database.oldDevice.bulkCreate(
const knownOldDeviceAuthTokens = (await database.oldDevice.findAll({ oldDeviceAuthTokensToAdd.map((item) => ({
where: { deviceAuthToken: item
deviceAuthToken: { })),
[Sequelize.Op.in]: oldDeviceAuthTokens { transaction }
} )
},
transaction
})).map((item) => item.deviceAuthToken)
const oldDeviceAuthTokensToAdd = difference(oldDeviceAuthTokens, knownOldDeviceAuthTokens)
if (oldDeviceAuthTokensToAdd.length > 0) {
await database.oldDevice.bulkCreate(
oldDeviceAuthTokensToAdd.map((item) => ({
deviceAuthToken: item
})),
{ transaction }
)
}
} }
}
// family // family
await database.family.destroy({ await database.family.destroy({
where: { where: {
familyId: { familyId: {
[Sequelize.Op.in]: familiyIds [Sequelize.Op.in]: familiyIds
} }
}, },
transaction transaction
})
}) })
} }
+7 -4
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2020 Jonas Lochmann * Copyright (C) 2019 - 2023 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -26,9 +26,12 @@ export async function deleteOldFamilies (database: Database) {
if (oldFamilyIds.length > 0) { if (oldFamilyIds.length > 0) {
const familyIdsToDelete = oldFamilyIds.slice(0, 256) /* limit to 256 families per execution */ const familyIdsToDelete = oldFamilyIds.slice(0, 256) /* limit to 256 families per execution */
await deleteFamilies({ await database.transaction(async (transaction) => {
database, await deleteFamilies({
familiyIds: familyIdsToDelete database,
transaction,
familiyIds: familyIdsToDelete
})
}) })
} }
} }
+34 -11
View File
@@ -16,25 +16,38 @@
*/ */
import { Conflict } from 'http-errors' import { Conflict } from 'http-errors'
import { generateServerDataStatus } from '../sync/get-server-data-status'
import { NewDeviceInfo, PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema' import { NewDeviceInfo, PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema'
import { Database } from '../../database' import { Database } from '../../database'
import { maxMailNotificationFlags } from '../../database/user' import { maxMailNotificationFlags } from '../../database/user'
import { EventHandler } from '../../monitoring/eventhandler'
import { ServerDataStatus } from '../../object/serverdatastatus'
import { createEmptyClientDataStatus } from '../../object/clientdatastatus'
import { import {
generateAuthToken, generateFamilyId, generateIdWithinFamily, generateVersionId generateAuthToken, generateFamilyId, generateIdWithinFamily, generateVersionId
} from '../../util/token' } from '../../util/token'
import { requireMailAndLocaleByAuthToken } from '../authentication' import { requireMailAndLocaleByAuthToken } from '../authentication'
import { prepareDeviceEntry } from '../device/prepare-device-entry' import { prepareDeviceEntry } from '../device/prepare-device-entry'
export const createFamily = async ({ database, mailAuthToken, firstParentDevice, password, timeZone, parentName, deviceName }: { export async function createFamily ({
database: Database, database, eventHandler, mailAuthToken, firstParentDevice,
mailAuthToken: string, password, timeZone, parentName, deviceName, clientLevel
firstParentDevice: NewDeviceInfo, }: {
password: PlaintextParentPassword, database: Database
timeZone: string, eventHandler: EventHandler
parentName: string, mailAuthToken: string
firstParentDevice: NewDeviceInfo
password: PlaintextParentPassword
timeZone: string
parentName: string
deviceName: string deviceName: string
clientLevel: number | null
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}) => { }): Promise<{
deviceAuthToken: string
deviceId: string
data: ServerDataStatus
}> {
assertPlaintextParentPasswordValid(password) assertPlaintextParentPasswordValid(password)
return database.transaction(async (transaction) => { return database.transaction(async (transaction) => {
@@ -42,14 +55,14 @@ export const createFamily = async ({ database, mailAuthToken, firstParentDevice,
const mailInfo = await requireMailAndLocaleByAuthToken({ database, mailAuthToken, transaction, invalidate: true }) const mailInfo = await requireMailAndLocaleByAuthToken({ database, mailAuthToken, transaction, invalidate: true })
// ensure that no family was created for this mail yet // ensure that no family was created for this mail yet
const exisitngUserEntry = await database.user.findOne({ const existingUserEntry = await database.user.findOne({
where: { where: {
mail: mailInfo.mail mail: mailInfo.mail
}, },
transaction transaction
}) })
if (exisitngUserEntry) { if (existingUserEntry) {
throw new Conflict() throw new Conflict()
} }
@@ -103,9 +116,19 @@ export const createFamily = async ({ database, mailAuthToken, firstParentDevice,
isUserKeptSignedIn: true isUserKeptSignedIn: true
}), { transaction }) }), { transaction })
const data = await generateServerDataStatus({
database,
clientStatus: createEmptyClientDataStatus({ clientLevel }),
familyId,
deviceId,
transaction,
eventHandler
})
return { return {
deviceAuthToken, deviceAuthToken,
deviceId deviceId,
data
} }
}) })
} }
+19 -3
View File
@@ -24,15 +24,21 @@ import { WebsocketApi } from '../../websocket'
import { requireMailAndLocaleByAuthToken } from '../authentication' import { requireMailAndLocaleByAuthToken } from '../authentication'
import { prepareDeviceEntry } from '../device/prepare-device-entry' import { prepareDeviceEntry } from '../device/prepare-device-entry'
import { notifyClientsAboutChangesDelayed } from '../websocket' import { notifyClientsAboutChangesDelayed } from '../websocket'
import { generateServerDataStatus } from '../sync/get-server-data-status'
import { EventHandler } from '../../monitoring/eventhandler'
import { ServerDataStatus } from '../../object/serverdatastatus'
import { createEmptyClientDataStatus } from '../../object/clientdatastatus'
export const signInIntoFamily = async ({ database, mailAuthToken, newDeviceInfo, deviceName, websocket }: { export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken, newDeviceInfo, deviceName, websocket, clientLevel }: {
database: Database database: Database
eventHandler: EventHandler
mailAuthToken: string mailAuthToken: string
newDeviceInfo: NewDeviceInfo newDeviceInfo: NewDeviceInfo
deviceName: string deviceName: string
websocket: WebsocketApi websocket: WebsocketApi
clientLevel: number | null
// no transaction here because this is directly called from an API endpoint // no transaction here because this is directly called from an API endpoint
}): Promise<{ deviceId: string; deviceAuthToken: string }> => { }): Promise<{ deviceId: string; deviceAuthToken: string; data: ServerDataStatus }> => {
return database.transaction(async (transaction) => { return database.transaction(async (transaction) => {
const mailInfo = await requireMailAndLocaleByAuthToken({ database, mailAuthToken, transaction, invalidate: true }) const mailInfo = await requireMailAndLocaleByAuthToken({ database, mailAuthToken, transaction, invalidate: true })
@@ -94,9 +100,19 @@ export const signInIntoFamily = async ({ database, mailAuthToken, newDeviceInfo,
}) })
}) })
const data = await generateServerDataStatus({
database,
clientStatus: createEmptyClientDataStatus({ clientLevel }),
familyId: userEntry.familyId,
deviceId,
transaction,
eventHandler
})
return { return {
deviceId, deviceId,
deviceAuthToken deviceAuthToken,
data
} }
}) })
} }
+12
View File
@@ -28,6 +28,18 @@ export interface ClientDataStatus {
u2f?: string // last u2f list version u2f?: string // last u2f list version
} }
export function createEmptyClientDataStatus({ clientLevel }: {
clientLevel: number | null
}): ClientDataStatus {
return {
devices: '',
apps: {},
categories: {},
users: '',
clientLevel: clientLevel || undefined
}
}
export type ClientDataStatusApps = {[key: string]: string} // installedAppsVersionsByDeviceId export type ClientDataStatusApps = {[key: string]: string} // installedAppsVersionsByDeviceId
export type ClientDataStatusCategories = {[key: string]: CategoryDataStatus} export type ClientDataStatusCategories = {[key: string]: CategoryDataStatus}
export type ClientDataStatusDevicesExtended = {[key: string]: DeviceDataStatus} export type ClientDataStatusDevicesExtended = {[key: string]: DeviceDataStatus}
+18 -2
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 - 2022 Jonas Lochmann * Copyright (C) 2019 - 2023 Jonas Lochmann
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@@ -72,7 +72,10 @@ function createMailTemplateSender (templateName: string) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const data = (info as any).message const data = (info as any).message
console.log(JSON.stringify(JSON.parse(data), null, 2)) console.log(JSON.stringify({
...JSON.parse(data),
params
}, null, 2))
} }
resolve() resolve()
@@ -190,6 +193,19 @@ export const sendPasswordRecoveryUsedMail = async ({ receiver, locale }: {
}) })
} }
const accountDeletedMailSender = createMailTemplateSender('account-deleted')
export const sendAccountDeletedMail = async ({ receiver }: {
receiver: string
}) => {
await accountDeletedMailSender.sendMail({
receiver,
params: {
mailimprint
}
})
}
function getMailSecurityText (locale: string) { function getMailSecurityText (locale: string) {
if (locale === 'de') { if (locale === 'de') {
return 'Achten Sie darauf, dass Ihr Kind/Ihre Kinder keinen Zugang zu der E-Mail-Adresse hat/haben, die Sie bei TimeLimit angegeben haben.' return 'Achten Sie darauf, dass Ihr Kind/Ihre Kinder keinen Zugang zu der E-Mail-Adresse hat/haben, die Sie bei TimeLimit angegeben haben.'