diff --git a/docs/api/auth.md b/docs/api/auth.md index 39fcd09..aa11975 100644 --- a/docs/api/auth.md +++ b/docs/api/auth.md @@ -24,7 +24,8 @@ see [this JSON schema](../schema/sendmaillogincoderequest.md) ``` { "mail": "test@timelimit.io", - "locale": "de" + "locale": "de", + "deviceAuthToken": "1234abcde" } ``` @@ -34,6 +35,8 @@ If the request body is malformed or the mail address is invalid: HTTP status cod If the rate limit was exceeded: HTTP status code 429 Too Many Requests +If a deviceAuthToken was sent which is invalid: HTTP status code 401 Unauthorized + If a whitelist was configured and the mail address is not within it: ``{"mailAddressNotWhitelisted": true}`` If a blacklist was configured and the mail server is within it: ``{"mailServerBlacklisted": true}`` diff --git a/docs/schema/SendMailLoginCodeRequest.schema.json b/docs/schema/SendMailLoginCodeRequest.schema.json index d542005..57d76bc 100644 --- a/docs/schema/SendMailLoginCodeRequest.schema.json +++ b/docs/schema/SendMailLoginCodeRequest.schema.json @@ -6,6 +6,9 @@ }, "locale": { "type": "string" + }, + "deviceAuthToken": { + "type": "string" } }, "additionalProperties": false, diff --git a/docs/schema/sendmaillogincoderequest-properties-deviceauthtoken.md b/docs/schema/sendmaillogincoderequest-properties-deviceauthtoken.md new file mode 100644 index 0000000..4ecd9e7 --- /dev/null +++ b/docs/schema/sendmaillogincoderequest-properties-deviceauthtoken.md @@ -0,0 +1,15 @@ +# Untitled string in SendMailLoginCodeRequest Schema + +```txt +https://timelimit.io/SendMailLoginCodeRequest#/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 | [SendMailLoginCodeRequest.schema.json*](SendMailLoginCodeRequest.schema.json "open original schema") | + +## deviceAuthToken Type + +`string` diff --git a/docs/schema/sendmaillogincoderequest.md b/docs/schema/sendmaillogincoderequest.md index 4365820..ba4ca4b 100644 --- a/docs/schema/sendmaillogincoderequest.md +++ b/docs/schema/sendmaillogincoderequest.md @@ -16,10 +16,11 @@ https://timelimit.io/SendMailLoginCodeRequest # SendMailLoginCodeRequest Properties -| Property | Type | Required | Nullable | Defined by | -| :---------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------- | -| [mail](#mail) | `string` | Required | cannot be null | [SendMailLoginCodeRequest](sendmaillogincoderequest-properties-mail.md "https://timelimit.io/SendMailLoginCodeRequest#/properties/mail") | -| [locale](#locale) | `string` | Required | cannot be null | [SendMailLoginCodeRequest](sendmaillogincoderequest-properties-locale.md "https://timelimit.io/SendMailLoginCodeRequest#/properties/locale") | +| Property | Type | Required | Nullable | Defined by | +| :---------------------------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [mail](#mail) | `string` | Required | cannot be null | [SendMailLoginCodeRequest](sendmaillogincoderequest-properties-mail.md "https://timelimit.io/SendMailLoginCodeRequest#/properties/mail") | +| [locale](#locale) | `string` | Required | cannot be null | [SendMailLoginCodeRequest](sendmaillogincoderequest-properties-locale.md "https://timelimit.io/SendMailLoginCodeRequest#/properties/locale") | +| [deviceAuthToken](#deviceauthtoken) | `string` | Optional | cannot be null | [SendMailLoginCodeRequest](sendmaillogincoderequest-properties-deviceauthtoken.md "https://timelimit.io/SendMailLoginCodeRequest#/properties/deviceAuthToken") | ## mail @@ -57,4 +58,22 @@ https://timelimit.io/SendMailLoginCodeRequest `string` +## deviceAuthToken + + + +`deviceAuthToken` + +* is optional + +* Type: `string` + +* cannot be null + +* defined in: [SendMailLoginCodeRequest](sendmaillogincoderequest-properties-deviceauthtoken.md "https://timelimit.io/SendMailLoginCodeRequest#/properties/deviceAuthToken") + +### deviceAuthToken Type + +`string` + # SendMailLoginCodeRequest Definitions diff --git a/other/mail/login/html.ejs b/other/mail/login/html.ejs index 5c93e3f..1624a87 100644 --- a/other/mail/login/html.ejs +++ b/other/mail/login/html.ejs @@ -2,8 +2,9 @@
-
-
-
+
+
+ |
|
-
-
+
+
+ |
|
-
-
+
+
+ |
|
-
-
+
+
+ |
|
<%= code %>
<%= outrotext %>
+ <% if (deviceName !== null) { -%> +<%= deviceNameIntro %> <%= deviceName %> <%= deviceNameOutro %>
+ <% } -%> diff --git a/other/mail/login/text.ejs b/other/mail/login/text.ejs index 2776794..a0b1cc2 100644 --- a/other/mail/login/text.ejs +++ b/other/mail/login/text.ejs @@ -4,6 +4,10 @@ <%- outrotext %> +<% if (deviceName !== null) { -%> +<%- deviceNameIntro %> <%- deviceName %> <%- deviceNameOutro %> + +<% } -%> ---------------------- You got this mail because your mail address was entered at the TimeLimit App for signing in. diff --git a/src/api/auth.ts b/src/api/auth.ts index 985c598..ae13b7e 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -1,6 +1,6 @@ /* * server component for the TimeLimit App - * Copyright (C) 2019 - 2020 Jonas Lochmann + * Copyright (C) 2019 - 2021 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 @@ -48,6 +48,7 @@ export const createAuthRouter = (database: Database) => { } else { const { mailLoginToken } = await sendLoginCode({ mail, + deviceAuthToken: req.body.deviceAuthToken, locale: req.body.locale, database }) diff --git a/src/api/schema.ts b/src/api/schema.ts index 3f49ac5..7704cf3 100644 --- a/src/api/schema.ts +++ b/src/api/schema.ts @@ -132,6 +132,7 @@ export interface RequestWithAuthToken { export interface SendMailLoginCodeRequest { mail: string locale: string + deviceAuthToken?: string } export interface SignInByMailCodeRequest { diff --git a/src/api/validator.ts b/src/api/validator.ts index 6cfcd8a..b7ed729 100644 --- a/src/api/validator.ts +++ b/src/api/validator.ts @@ -2966,6 +2966,9 @@ export const isSendMailLoginCodeRequest: (value: object) => value is SendMailLog }, "locale": { "type": "string" + }, + "deviceAuthToken": { + "type": "string" } }, "additionalProperties": false, diff --git a/src/function/authentication/login-by-mail.ts b/src/function/authentication/login-by-mail.ts index 5247abb..1d65eac 100644 --- a/src/function/authentication/login-by-mail.ts +++ b/src/function/authentication/login-by-mail.ts @@ -1,6 +1,6 @@ /* * server component for the TimeLimit App - * Copyright (C) 2019 - 2020 Jonas Lochmann + * Copyright (C) 2019 - 2021 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 @@ -15,7 +15,7 @@ * along with this program. If not, see