diff --git a/CHANGELOG.md b/CHANGELOG.md index 11d0eb4..c7c355b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,16 @@ The version numbers are explained in "Project status" in the [README](README.md) ## [Unreleased] +### Added + +- `POST /auth/login` and `POST /auth/register` accept an optional `device_name` (up to 60 characters). It is the session `name` in `GET /auth/sessions`, so the app can show each signed-in device. Without it the name stays `mobile-app`. `POST /auth/refresh` keeps the name. + ### Fixed +- Docker: a configuration cache in the build folder (`kinlore-api/bootstrap/cache/config.php`) is no longer copied into the image, and every start removes an old cache before it reads the environment. An old cache could keep an old `APP_URL` through `git pull` and a rebuild. The server prints its public address at start. - Invitation links, the invite page and the setup address no longer use a placeholder `APP_URL`. When `APP_URL` is empty, `localhost`, `127.0.0.1`, `::1`, `0.0.0.0` or a host under `example.com`, `example.org` or `example.net`, the server uses the address of the request. A real `APP_URL` is still used as before. - `POST /v1/invitations` returns `public_url_configured` (bool), so the app can tell the admin to set `APP_URL`. `GET /health/detailed` has a `public_url` check, and `php artisan kinlore:setup-token` prints a warning. +- `openapi.yaml` describes `device_name`, the session `name`, `public_url_configured` in `POST /v1/invitations` and the `public_url` check of `GET /health/detailed`. ## [1.5.1] - 2026-11-26 diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index af5138b..b9d25ce 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -63,7 +63,7 @@ export default defineConfig({ { text: 'Timeline and look-back', link: '/app/timeline-and-look-back' }, { text: 'Family and permissions', link: '/app/family-and-permissions' }, { text: 'Offline use and uploads', link: '/app/offline-and-uploads' }, - { text: 'Several families', link: '/app/multiple-servers' }, + { text: 'Several servers', link: '/app/multiple-servers' }, { text: 'Settings', link: '/app/settings' }, { text: 'Export', link: '/app/export' }, { text: 'Troubleshooting', link: '/app/troubleshooting' }, diff --git a/docs/app/children.md b/docs/app/children.md index 12203e6..3cb03ee 100644 --- a/docs/app/children.md +++ b/docs/app/children.md @@ -2,7 +2,7 @@ This page tells you how to add, edit and delete a child, how to add a baby that is not born yet, and how to choose the child that the timeline shows. -A **child** has a profile with a name, a birth date or a due date, and a color. Each moment belongs to one child. Each child belongs to one family: the family that you add it to. +A **child** has a profile with a name, a birth date or a due date, and a color. Each moment belongs to one child. Each child belongs to one server: the server that you add it to. ## Who may do what @@ -26,12 +26,13 @@ For a born child, the app also adds a "First Meeting" milestone on the birth dat ## Add another child 1. Open the **Settings** tab. -2. In the family section, tap **Children**. The header shows the family name. -3. Tap the **+** button at the top right ("Add child"). -4. The app shows "Add child", with "Adds to" and the family name. Type the **Name**. -5. If the baby is not born yet, turn on **Expecting a baby?** and pick the **Due date**. Else pick the **Birth date**. -6. Under **Color**, tap a color. -7. Tap the check mark at the top right ("Save"). +2. Under **Servers**, tap the server that shows **In use**. The app shows its **Server** screen. +3. Under **Family**, tap **Children**. The header shows the server name. +4. Tap the **+** button at the top right ("Add child"). +5. The app shows "Add child", with "Adds to" and the server name. Type the **Name**. +6. If the baby is not born yet, turn on **Expecting a baby?** and pick the **Due date**. Else pick the **Birth date**. +7. Under **Color**, tap a color. +8. Tap the check mark at the top right ("Save"). ### Check that it worked @@ -47,7 +48,7 @@ You can add a baby before the birth. ### When the baby is born -1. Open **Settings** > **Children** and tap the child. +1. Open **Settings**, tap the server in use, then tap **Children** and tap the child. 2. Turn off **Expecting a baby?**. 3. Pick the **Birth date**. 4. Change the **Name** if necessary. @@ -57,7 +58,7 @@ The app keeps the due date. ## Edit a child -1. Open **Settings** > **Children**. +1. Open **Settings**, tap the server in use, then tap **Children**. 2. Tap the child. The app shows "Edit child". 3. Change the **Name**, the dates or the **Color**. 4. Tap the check mark at the top right ("Save"). @@ -71,7 +72,7 @@ If you may not edit the child, the fields are not active and the screen has no c When you delete a child, the app also deletes all the moments of that child, for all members. You can also delete the last child of the family. The app then shows "Add your first child". -1. Open **Settings** > **Children**. +1. Open **Settings**, tap the server in use, then tap **Children**. 2. Swipe the child to the left and tap the trash button. Or tap the child and tap **Delete child**. 3. The app asks "Delete" with the name of the child and the family. Tap **Delete**. @@ -88,7 +89,7 @@ The **active child** is the child that the timeline shows. The other members of 3. Tap a child. The **Children** screen in **Settings** marks the active child with **Active**. -Each family keeps its own active child. +Each server keeps its own active child. ### Show several children together diff --git a/docs/app/connect.md b/docs/app/connect.md index f9d0134..3acdf12 100644 --- a/docs/app/connect.md +++ b/docs/app/connect.md @@ -1,7 +1,7 @@ # Connect to a server -This page tells you how to connect the app to your family's server, sign in, and join a family with an invitation link. -It also explains the family name, and what to do when the server is not set up yet. +This page tells you how to connect the app to your family's server, sign in, and join a server with an invitation link. +It also explains the server name, and what to do when the server is not set up yet. A **server** is the computer that keeps your family's photos and moments. In Kinlore, one server is one family. Each family has one **admin**: the person who manages the family. @@ -21,7 +21,7 @@ A **server** is the computer that keeps your family's photos and moments. In Kin If you type no `https://` or `http://`, the app tries `https://` first. It tries `http://` only for an address on a home network. -To use a different server, tap **Change server** on the sign-in screen. When the phone has more than one family, the button is **Use another family**. It opens "Choose a family". See [Several families](multiple-servers.md#switch-to-another-family). +To use a different server, tap **Use another server** on the sign-in screen. With one server, it opens the screen where you type a server address. With more than one server, it opens "Choose a server". See [Several servers](multiple-servers.md#switch-to-another-server). ### What you see after the sign-in @@ -33,7 +33,7 @@ To use a different server, tap **Change server** on the sign-in screen. When the ### Check that it worked - The **Timeline** tab shows the moments of a child. -- Open the **Settings** tab. The card at the top shows the family name, the server address, and your name and role. +- Open the **Settings** tab. Under **Servers**, the server shows **In use**, with its name, its address, and your name and role. ## Join with an invitation link @@ -67,15 +67,15 @@ Use these steps when the link does not open the app. The app shows "Loading your family...", then the timeline of the family. -## The family name +## The server name -The **family name** is the name of the server for all its members, for example "Anna Example Family". +The name of a server is its **family name**: the name that all its members see, for example "Anna Example Family". - The server owner can set the family name when they set up the server. - The admin can change the family name in the app. See [Family and permissions](family-and-permissions.md#change-the-family-name). - The app gets the family name from the server with each sync. A **sync** is the exchange of changes between the phone and the server. -- The app shows the family name in place of the server address: in **Settings**, in "Choose a family", on the **Families** screen, and in the header of the family screens, for example **Children** and **Members**. -- A member who is not the admin can give the family a different name on their own phone only. See [Several families](multiple-servers.md#rename-a-family-on-this-phone). +- The app shows the family name as the server name: in **Settings**, on the **Server** screen, in "Choose a server", and in the header of the family screens, for example **Children** and **Members**. The server address shows next to it. +- A member who is not the admin can give the server a different name on their own phone only. See [Several servers](multiple-servers.md#change-the-server-name). ## When the server is not set up yet diff --git a/docs/app/export.md b/docs/app/export.md index cb03c8c..28cc35a 100644 --- a/docs/app/export.md +++ b/docs/app/export.md @@ -7,11 +7,12 @@ An **export** is one ZIP file with all original photos and videos and all moment ## Start an export 1. Open the **Settings** tab. -2. In the family section, tap **Export**. The header shows the family name. -3. Tap **Start export**. -4. The new export shows in the list with the status **Waiting**, then **Building**. -5. Pull the list down to see the newest status. -6. When the status is **Ready**, the list shows the size of the file. +2. Under **Servers**, tap the server that shows **In use**. The app shows its **Server** screen. +3. Under **Family**, tap **Export**. The header shows the server name. +4. Tap **Start export**. +5. The new export shows in the list with the status **Waiting**, then **Building**. +6. Pull the list down to see the newest status. +7. When the status is **Ready**, the list shows the size of the file. The server builds the file. You can close the app while it works. A large library takes time. diff --git a/docs/app/family-and-permissions.md b/docs/app/family-and-permissions.md index b06115d..a52a223 100644 --- a/docs/app/family-and-permissions.md +++ b/docs/app/family-and-permissions.md @@ -33,14 +33,15 @@ A family member may also do these things, without a permission: A family member may not add a child. -You see your own role in **Settings**: on the family card ("You:" with your name and role) and under **Your account**. +You see your own role in **Settings**: under **Servers**, next to your name, and on the **Server** screen under **Your account**. ## Open the member list Only the admin sees these screens. 1. Open the **Settings** tab. -2. In the family section, tap **Members**. The header shows the family name. +2. Under **Servers**, tap the server that shows **In use**. The app shows its **Server** screen. +3. Under **Family**, tap **Members**. The header shows the server name. The **Members** screen has two lists: @@ -49,7 +50,7 @@ The **Members** screen has two lists: ## Invite a person -1. In **Settings**, tap **Invite someone**. Or, on the **Members** screen, tap the button at the top right ("Invite someone to" and the family name). The app shows "Invite to" with the family name and the server address. +1. On the **Members** screen, tap **Invite someone**. The app shows "Invite to" with the family name and the server address. 2. Optional: type an email in **Email (optional)**. With an email, only that address can use the invitation. 3. Under **Role**, tap **Family** or **Partner**. 4. For **Family**, turn the permissions on or off. @@ -104,20 +105,20 @@ You cannot remove yourself. The family name is the name of the server for all members, for example "Anna Example Family". 1. Open the **Settings** tab. -2. Open the details of the active family. With one family: under **Families on this phone**, tap **Server details**. With several families: tap **Families**, then tap the info button of the active family. The app shows "Family details". -3. Tap the pencil button at the top right ("Rename family"). -4. In **Family name**, type the new name. The app shows "This is the family name. All members see it." +2. Under **Servers**, tap the server that shows **In use**. The app shows its **Server** screen. +3. Under **Server**, tap **Rename**. The row shows "Everyone on this server sees the new name". +4. In **Name**, type the new name. The app shows "You are the admin: everyone on this server sees the new name." 5. Tap **Save name**. The name can have up to 60 characters. The other members see the new name after their next sync. ### Check that it worked -The family card at the top of **Settings** shows the new name. +Under **Servers** in **Settings**, the server shows the new name. ## Give the admin role to another member -Each family has one admin. When you give the admin role to another member, you become a partner. +Each server has one admin. When you give the admin role to another member, you become a partner. 1. On the **Members** screen, tap the member. 2. Tap **Make admin**. @@ -127,7 +128,7 @@ After the change, you can no longer manage members, invitations or exports. Only ### Check that it worked -In **Settings**, your role is "Partner". The **Members**, **Invite someone** and **Export** rows are not in **Settings**. +In **Settings**, your role is "Partner". On the **Server** screen, the **Members** and **Export** rows are gone. ## Set a new password for a member diff --git a/docs/app/multiple-servers.md b/docs/app/multiple-servers.md index 4bb4552..9d2d241 100644 --- a/docs/app/multiple-servers.md +++ b/docs/app/multiple-servers.md @@ -1,121 +1,101 @@ -# Several families +# Several servers -This page tells you how to use more than one family in the app: add a family, switch between families, choose a default family, rename a family on your phone, and remove a family from your phone. +This page tells you how to use more than one server in the app: add a server, switch between servers, change the name of a server, and remove a server from your phone. -In Kinlore, one server is one family. You need more than one family when you belong to more than one, for example your own family and the family of your parents. Each family has its own server. +In Kinlore, one server is one family. You need more than one server when you belong to more than one family, for example your own family and the family of your parents. Each family has its own server. -Each family keeps its own sign-in, its own copy of the data on the phone and its own upload queue. Two families never share data on the phone. +Each server keeps its own sign-in, its own copy of the data on the phone and its own upload queue. Two servers never share data on the phone. -## Where the app shows the family +The app opens the server that you used last. -- **Settings** starts with a card that shows the active family: its name, its address, and your name and role there. -- With more than one family, the timeline shows the family name above the name of the child. -- The screens of a family, for example **Children**, **Members**, **Invite** and **Export**, show the family name in their header. +## Where the app shows the server -## Switch to another family +- **Settings** lists all servers on this phone under **Servers**. **In use** marks the server that the app shows now. See [Settings](settings.md#servers). +- With more than one server, the timeline shows the server name above the name of the child. +- The screens of a server, for example **Children**, **Members**, **Invite** and **Export**, show the server name in their header. -The app shows "Choose a family", a list of all families on this phone. Each family shows its name, its address, the email that you use there, and a status, for example **Online** or **Offline**. A check mark shows the active family. +## Switch to another server -You can open "Choose a family" from three places: +You can switch from two places: the **Server** screen in **Settings**, and "Choose a server". -- In **Settings**, tap **Switch family** on the family card. -- On the timeline, tap the family name at the top of the screen. -- On the sign-in screen, tap **Use another family**. +### From Settings -These buttons show only when the phone has more than one family. +1. Open the **Settings** tab. +2. Under **Servers**, tap the server. The app shows its **Server** screen. +3. Tap **Switch to this server**. When you are not signed in there, the button is **Sign in to this server**, and the app then shows the sign-in screen. Sign in. To join this server with an invitation, tap **I have an invitation**. -1. Open "Choose a family". -2. Tap the family. -3. If the phone has no sign-in for that family, the app shows the sign-in screen. Sign in. To join this family with an invitation, tap **I have an invitation**. +### From "Choose a server" -### Check that it worked +"Choose a server" is a list of all servers on this phone. Each server shows its name, its address, the email that you use there ("You:" and an email, or "Not signed in"), and a status, for example **Online** or **Offline**. A check mark shows the server in use. -The family card in **Settings** shows the new family. The timeline shows the children of that family. +You can open "Choose a server" from these places. They show only when the phone has more than one server. -## Add a family +- On the timeline, tap the server name at the top of the screen. +- On the sign-in screen, tap **Use another server**. With one server, this button opens the screen where you type a server address. +- On the "Add your first child" screen, tap **Use another server**. -1. Open the **Settings** tab. -2. Under **Families on this phone**, tap **Add another family**. You can also tap **Add another family** in "Choose a family". The app shows "Add a family". -3. In **Server address**, type the address of the server, for example `photos.example.com`. -4. Tap **Test connection**. The button shows **Connected** when the server answers. -5. Optional: type a **Display name (optional)**. -6. Tap **Add family**. +1. Open "Choose a server". +2. Tap the server. +3. If the phone has no sign-in for that server, the app shows the sign-in screen. Sign in, or tap **I have an invitation**. -The app adds the family and opens it at once. So the next screen is the sign-in screen of the new family. Sign in, or tap **I have an invitation**. -After the first sync, the app shows the family name of the server. +In "Choose a server", **Add a server** opens "Add a server", and **Manage servers** opens **Settings**. ### Check that it worked -The new family is in "Choose a family" and on the **Families** screen. - -## Open the family list +In **Settings**, the server shows **In use**. The timeline shows the children of that server. -The **Families** screen lists all families on this phone. It has more options than "Choose a family". +## Add a server 1. Open the **Settings** tab. -2. Under **Families on this phone**, tap **Families**. This row shows only when the phone has more than one family. You can also tap **Manage families** in "Choose a family". - -Each family shows its name, its address and the account that you use there ("You:" and an email). - -- **In use** and a check mark show the **active** family: the family that the app shows now. -- A star shows the **default** family. -- A status shows if the server answers, for example **Online** or **Offline**. - -Tap a family to switch to it. Tap the active family, or the info button of a family, to open its details. Long-press a family for more options. -Pull the list down to check the status of all families again. To add a family, tap the **+** button at the top right ("Add a family"). - -## Choose the default family - -The **default** family is the family that the app opens when no family was active before. - -1. On the **Families** screen, long-press the family. -2. Tap **Set as default**. - -You can also open the family details and tap **Set as default**. To remove the default, open the family details and tap **Remove as default**. - -## See the family details +2. Under **Servers**, tap **Add a server**. You can also tap **Add a server** in "Choose a server". The app shows "Add a server". +3. In **Server address**, type the address of the server, for example `photos.example.com`. +4. Tap **Test connection**. The button shows **Connected** when the server answers. +5. Optional: type a **Display name (optional)**. +6. Tap **Add server**. -1. With one family: in **Settings**, under **Families on this phone**, tap **Server details**. With several families: on the **Families** screen, tap the info button of the family. -2. The app shows "Family details": the **Address**, the **Status**, the time of the last connection, your account there, and, when the app knows them, the number of children and members. +The app adds the server and opens it at once. So the next screen is the sign-in screen of the new server. Sign in, or tap **I have an invitation**. +After the first sync, the app shows the family name of the server as the server name. -To check the connection again, tap the refresh button next to **Status** ("Test connection"). -For a family that is not active, tap **Switch to this family** to open it. +### Check that it worked -## Rename a family on this phone +The new server is under **Servers** in **Settings**, and in "Choose a server". -You can give a family a name that only you see, on this phone. +## Change the server name -1. Open the family details. -2. Tap the pencil button at the top right ("Rename on this phone"). -3. Type the name. The app shows "This name is only on this phone. Leave it empty to use the family name." +1. Open the **Settings** tab and tap the server. +2. Under **Server**, tap **Rename**. +3. Type the name. 4. Tap **Save name**. -To use the family name again, clear the field and save. +Who sees the new name depends on you and the server: -For the admin, the pencil on the active family changes the family name for all members. See [Family and permissions](family-and-permissions.md#change-the-family-name). +- You are the admin, and the server is in use: the app shows "You are the admin: everyone on this server sees the new name." The name is the family name for all members. See [Family and permissions](family-and-permissions.md#change-the-family-name). +- In all other cases, the app shows "This name is only on this phone. Leave it empty to use the name the server reports." To use the name of the server again, clear the field and save. -## Remove a family from this phone +## Remove a server from this phone -When you remove a family, the app deletes the data of that family on this phone. The data on the server stays. -You cannot remove the active family. Switch to another family first. +When you remove a server, the app deletes the data of that server on this phone. The data on the server stays. +You cannot remove the server in use. Switch to another server first. With only one server, use **Reset this phone** in **Settings**. See [Settings](settings.md#reset-this-phone). -1. On the **Families** screen, long-press the family and tap **Remove**. Or open the family details and tap **Remove from this phone**. -2. The app asks "Remove" with the name of the family. Tap **Remove**. +1. Open the **Settings** tab and tap the server. +2. Tap **Remove from this phone**. +3. The app asks "Remove" with the name of the server. Tap **Remove**. -The app removes the family, its sign-in and its data from the phone. To use the family again, add it again and sign in. +The app removes the server, its sign-in and its data from the phone. To use the server again, add it again and sign in. -Stories, changes or uploads that have not reached that server yet are lost. Before you remove a family, switch to it and let it sync. When the app knows that changes are not sent yet, it shows "Cannot remove this server yet" and removes nothing. +Stories, changes or uploads that have not reached that server yet are lost. Before you remove a server, switch to it and let it sync. When the app knows that changes are not sent yet, it shows "Cannot remove this server yet" and removes nothing. ### Check that it worked -The family is not on the **Families** screen. +The server is not under **Servers** in **Settings**. ## Problems -- **"Server already configured"**: the family is already on this phone. Find it on the **Families** screen. -- **"Test the connection first."**: tap **Test connection** before **Add family**. +- **"Server already configured"**: the server is already on this phone. Find it under **Servers** in **Settings**. +- **"Test the connection first."**: tap **Test connection** before **Add server**. - **"Server not reachable"** or **"Server address not found"**: check the address and the network. See [Troubleshooting](troubleshooting.md). -- **"Could not open"** with the name of the family: the app could not switch. Check the connection and try again. -- **"The family was added, but it did not open. Open it from Families."**: open the **Families** screen and tap the new family. -- **"Cannot remove this family"**: the family is active. Switch to another family first. -- **"Cannot remove this server yet"**: the family has unsent changes on this phone. Switch to it and let the changes sync, then try again. +- **"Could not open"** with the name of the server: the app could not switch. Check the connection and try again. +- **"Could not switch to this server. Check the connection and try again."**: the same problem, on the **Server** screen. +- **"The server was added, but it did not open. Open it from Settings."**: open **Settings**, tap the new server, then tap **Switch to this server** or **Sign in to this server**. +- **"Cannot remove this server"**: the server is in use. Switch to another server first. +- **"Cannot remove this server yet"**: the server has unsent changes on this phone. Switch to it and let the changes sync, then try again. diff --git a/docs/app/offline-and-uploads.md b/docs/app/offline-and-uploads.md index 3aaf216..fdf9208 100644 --- a/docs/app/offline-and-uploads.md +++ b/docs/app/offline-and-uploads.md @@ -4,7 +4,7 @@ This page explains what the app can do without a connection to the server, how t ## The copy on the phone -The app keeps a copy of the family's data on the phone. Each family has its own copy. +The app keeps a copy of the family's data on the phone. Each server has its own copy. The timeline reads from this copy. So you can open the app and see the timeline when the phone is offline. A **sync** is the exchange of changes between the phone and the server: @@ -18,7 +18,7 @@ The app syncs at these times: - When the app starts. - After you sign in. -- When you switch to another family. +- When you switch to another server. - When you pull the timeline down and release it. - After you save a child, a story or a growth record. @@ -38,7 +38,7 @@ The app does not sync by itself when the network comes back. When you are online | Like, comment or delete a comment | No. | | Look-back cards | No. The cards do not show. | | Members, invitations, export, family name, signed-in devices | No. | -| Sign in, join with an invitation, or add a family | No. | +| Sign in, join with an invitation, or add a server | No. | ## The upload queue @@ -51,7 +51,7 @@ The **upload queue** is the list of photos and videos that wait to go to the ser - When the server has an item, the moment takes the place of the preview. Uploaded moments show no icon. - The queue sends one item at a time, and it sends the original file. - When the app starts again, the queue continues with the items that are not sent yet. It starts after the first sync. -- Each family has its own queue. When you switch to another family, the items of the first family wait. They continue when you switch back. +- Each server has its own queue. When you switch to another server, the items of the first server wait. They continue when you switch back. ### Keep the app open for speed @@ -142,8 +142,8 @@ If the item fails again, the server refuses it. See [Troubleshooting](troublesho Changes that did not reach the server yet are only on this phone. These actions would delete them, so the app checks first: -- **Reset and sync** in **Settings** sends the changes first. It stops if some changes cannot be sent. +- **Reset and sync**, on the **Server** screen in **Settings**, sends the changes first. It stops if some changes cannot be sent. - **Reset this phone** in **Settings** warns you with the number of unsent changes. -- **Remove from this phone**, on the details of a family, refuses to remove a family while the app knows that it has unsent changes. +- **Remove from this phone**, on the **Server** screen, refuses to remove a server while the app knows that it has unsent changes. -See [Settings](settings.md) and [Several families](multiple-servers.md). +See [Settings](settings.md) and [Several servers](multiple-servers.md). diff --git a/docs/app/settings.md b/docs/app/settings.md index d19b745..ae7cd44 100644 --- a/docs/app/settings.md +++ b/docs/app/settings.md @@ -1,53 +1,68 @@ # Settings -This page explains every part of the **Settings** tab: the family card, the family screens, your account, your signed-in devices, the families on this phone, storage, uploads, **Reset and sync** and **Reset this phone**. +This page explains every part of the **Settings** tab and of the **Server** screen: the servers on this phone, your account, the family screens, your signed-in devices, the server name, storage, uploads, **Reset and sync**, **Remove from this phone** and **Reset this phone**. To open the screen, tap the **Settings** tab at the bottom of the app. -In Kinlore, one server is one family. The **Settings** tab always shows the family that the app shows now: the **active family**. +In Kinlore, one server is one family. The name of a server is the family name that the server reports, for example "Smith family". The server that the app shows now is the server **in use**. -## The family card +**Settings** has two groups: -The card at the top shows: +- **Servers**: one row for each server on this phone, and **Add a server**. +- **This phone**: settings that are not about one server. -- The family name, for example "Anna Example Family". Until the first sync, the app shows the server address in its place. -- The server address, for example `photos.example.com`. -- Your name and your role in this family, for example "You: Ben, Family". +## Servers -When the phone has more than one family, the card also has the button **Switch family**. It opens "Choose a family". See [Several families](multiple-servers.md#switch-to-another-family). +Each row in **Servers** shows: -## The family section +- The name of the server, for example "Anna Example Family". Until the first sync, the app shows the server address in its place. +- The server address, for example `photos.example.com`. Two servers can have the same name, so the address always shows. +- Your name and your role on that server, for example "Ben, Family", or "Not signed in". +- A status dot: green when the server answers, red when it does not. The server's own screen shows the status in words, for example **Online**. +- **In use** on the server that the app shows now. This server is always first. -The title of this section has the family name, for example "Smith family". Each row works on the active family only. +When **Settings** opens, the app checks the status of every server again. -- **Children**: add, edit and delete children. See [Children](children.md). -- **Members**: only for the admin. Manage members, their roles and their permissions. See [Family and permissions](family-and-permissions.md). -- **Invite someone**: only for the admin. Make an invitation link. See [Invite your family](../tutorials/invite-your-family.md). -- **Export**: only for the admin. Make a ZIP file with all photos, videos and moments. See [Export](export.md). +Tap a row to open the **Server** screen of that server. See [The Server screen](#the-server-screen). + +Tap **Add a server** to connect to another Kinlore server. See [Several servers](multiple-servers.md#add-a-server). + +## The Server screen + +The header shows the name of the server, with its address under it. + +### Status + +The top of the screen shows the status of the server, for example **Online** or **Offline**. To check the connection again, tap the refresh button ("Test connection"). + +- On the server in use, the app shows **In use**. +- On another server, the app shows **Switch to this server** when you are signed in there, or **Sign in to this server** when you are not. See [Several servers](multiple-servers.md#switch-to-another-server). -The screens that open from these rows show the family name in their header. So you always know which family you change. +For a server that is not in use, the app shows "Switch to this server to manage its children, members and account." The groups **Family**, **Signed-in devices** and **Sign out** show only on the server in use. -## Your account +### Your account -- The first row shows your name, your email and your role in this family. You cannot tap this row. -- **Signed-in devices**: see and sign out the phones and tablets that use your account in this family. See [Signed-in devices](#signed-in-devices). -- **Sign out**: sign out of this family on this phone. +This group shows only when you are signed in on this server. -### Sign out +- The first row shows your name, your email and your role on this server. You cannot tap this row. +- **Signed-in devices**: see and sign out the phones and tablets that use your account on this server. See [Signed-in devices](#signed-in-devices). +- **Sign out**: sign out of this server on this phone. + +#### Sign out 1. Tap **Sign out**. -2. The app asks "Sign out of" with the family name. Tap **Sign out**. +2. The app asks "Sign out of" with the server name. Tap **Sign out**. -The app removes only the sign-in of this family. The family stays on the phone, with its data. Your other families stay signed in. +Only this phone signs out of this server. The server and its data stay on this phone. Your other servers stay signed in. To sign in again, type your email and your password on the sign-in screen. -### Signed-in devices +#### Signed-in devices -The **Signed-in devices** screen shows every sign-in of your account in this family. +The **Signed-in devices** screen shows every sign-in of your account on this server. - **This phone**: the phone that you hold, with the date of the sign-in. -- **Other devices**: the other phones and tablets. Each one shows as "Another device", with the date of the sign-in and the time of the last use. +- **Other devices**: the other phones and tablets. Each one shows its device name, for example "iPhone", "iPad" or "Pixel 8", with the date of the sign-in and the time of the last use. A sign-in from an older app, or to an older server, shows as "Another device". When no other device is signed in, the screen shows "Only this phone". Pull the screen down to load the list again. @@ -63,33 +78,33 @@ To sign out all devices: 1. Tap **Sign out everywhere**. 2. The app asks "Sign out everywhere?". Tap **Sign out everywhere**. -Every device signs out of this family, this phone too. The app then shows the sign-in screen. +Every device signs out of this server, this phone too. The app then shows the sign-in screen. -## Families on this phone +### Family -- **Add another family**: connect to a second Kinlore server. See [Several families](multiple-servers.md#add-a-family). -- **Families**: shows only when the phone has more than one family. It opens the list of families. See [Several families](multiple-servers.md). -- **Server details**: shows only when the phone has one family. It opens "Family details". See [Several families](multiple-servers.md#see-the-family-details). +This group shows only on the server in use. Each row works on that server only. -## Storage +- **Children**: add, edit and delete children. The row shows the number of children. See [Children](children.md). +- **Members**: only for the admin. Manage members, their roles and their permissions, and invite people. See [Family and permissions](family-and-permissions.md). +- **Export**: only for the admin. Make a ZIP file with all photos, videos and moments. See [Export](export.md). -**Server storage** shows how much space the family's photos and videos use on the server, and how much free space the server disk has. The bar shows the used part of the server disk, for example "12% used". +The screens that open from these rows show the server name in their header. So you always know which server you change. -The bar changes color above 75% and turns red above 90%. Tell the server owner when the disk is almost full. +### Server -## Data +- **Rename**: tap it to change the name. For the admin on the server in use, the new name is the family name for everyone ("Everyone on this server sees the new name"). For everyone else, the name is only on this phone ("Only on this phone"). See [Change the server name](multiple-servers.md#change-the-server-name). +- **Storage**: only on the server in use. See [Storage](#storage). +- **Reset and sync**: only on the server in use. See [Reset and sync](#reset-and-sync). -### Uploads +#### Storage -The **Uploads** row shows the progress of the upload queue: for example "10 / 400", "Waiting for Wi-Fi", "3 failed" or "Up to date". It changes with every uploaded file. Tap it to open the **Uploads** screen. See [Offline use and uploads](./offline-and-uploads.md#the-upload-queue). - -### Upload over mobile data +**Storage** shows how much space the family's photos and videos use on the server, and how much free space the server disk has. The bar shows the used part of the server disk, for example "12% used". -When this switch is off, photos and videos upload only on Wi-Fi. On mobile data, they wait. The switch is off at first. Turn it on to upload on any connection. See [Mobile data](./offline-and-uploads.md#mobile-data). +The bar changes color above 75% and turns red above 90%. Tell the server owner when the disk is almost full. -### Reset and sync +#### Reset and sync -**Reset and sync** deletes the copy of the data on this phone for the active family, and gets everything again from the server. Use it when the timeline shows wrong data. +**Reset and sync** deletes the copy of the data on this phone for the server in use, and gets everything again from the server. Use it when the timeline shows wrong data. 1. Tap **Reset and sync**. 2. Read the message "Reset local data?". Tap **Reset and sync**. @@ -97,26 +112,40 @@ When this switch is off, photos and videos upload only on Wi-Fi. On mobile data, Before the reset, the app sends the unsent changes of this phone. If it cannot send them all, it stops and deletes nothing. The data on the server does not change. +### Remove from this phone + +**Remove from this phone** deletes this server and its data from this phone. Nothing on the server is deleted. You cannot remove the server in use. See [Remove a server from this phone](multiple-servers.md#remove-a-server-from-this-phone). + +## This phone + +### Uploads + +The **Uploads** row shows the progress of the upload queue: for example "10 / 400", "Waiting for Wi-Fi", "3 failed" or "Up to date". It changes with every uploaded file. Tap it to open the **Uploads** screen. See [Offline use and uploads](./offline-and-uploads.md#the-upload-queue). + +### Upload over mobile data + +When this switch is off, photos and videos upload only on Wi-Fi. On mobile data, they wait. The switch is off at first. Turn it on to upload on any connection. See [Mobile data](./offline-and-uploads.md#mobile-data). + ### Reset this phone -**Reset this phone** removes all Kinlore data from this phone and signs you out. Every member may use it. It does not delete anything on the server. +**Reset this phone** removes every server and sign-in from this phone and signs you out. Every member may use it. It does not delete anything on the server. The reset deletes these things on the phone: -- All families on this phone. +- All servers on this phone. - All sign-ins. -- The copy of the data of every family. -- The upload queue, and the settings of the app, for example the active child and the default family. +- The copy of the data of every server. +- The upload queue, and the settings of the app, for example the active child. -After the reset, the app starts at "Welcome to Kinlore". To get everything back, add the family again and sign in. +After the reset, the app starts at "Welcome to Kinlore". To get everything back, add the server again and sign in. 1. Tap **Reset this phone**. 2. Read the message "Reset this phone?". Tap **Reset phone**. -3. If the active family has unsent changes, the app shows "Unsent changes will be lost" with the number of changes. To keep them, tap **Cancel**, stay online and let them sync. To delete them, tap the button "Reset and lose" with the number. +3. If the server in use has unsent changes, the app shows "Unsent changes will be lost" with the number of changes. To keep them, tap **Cancel**, stay online and let them sync. To delete them, tap the button "Reset and lose" with the number. -The app can count the unsent changes of the active family only. Stories, changes or uploads that have not reached your other families yet are lost. +The app can count the unsent changes of the server in use only. Stories, changes or uploads that have not reached your other servers yet are lost. -### Check that it worked +#### Check that it worked The app shows "Welcome to Kinlore". @@ -129,3 +158,4 @@ The bottom of the screen shows the version of the app, for example "Kinlore 1.2. - **"Not reset"**: the app could not send all unsent changes, or it could not reach the server. So it deleted nothing. Wait until the uploads finish, or retry or remove failed uploads. Then try again. See [Offline use and uploads](offline-and-uploads.md). - **"Could not reset this phone completely. Please try again."**: tap **Reset this phone** again. - **"Could not load your signed-in devices."**: the app could not reach the server. Check the connection, then tap **Try again**. +- **"Name not saved. Check the connection and try again."**: the app could not reach the server. Check the connection and try again. diff --git a/docs/app/timeline-and-look-back.md b/docs/app/timeline-and-look-back.md index 8ab8de4..4185e1b 100644 --- a/docs/app/timeline-and-look-back.md +++ b/docs/app/timeline-and-look-back.md @@ -8,7 +8,7 @@ The **Timeline** tab shows the moments of the active child, newest first, in a g To choose the child, tap the name of the child at the top of the screen. See [Children](children.md#choose-the-active-child). - The top of the screen shows the name and the age of the child. -- When the phone has more than one family, the family name shows above the name of the child. Tap it to switch to another family. See [Several families](multiple-servers.md#switch-to-another-family). +- When the phone has more than one server, the server name shows above the name of the child. Tap it to open "Choose a server". See [Several servers](multiple-servers.md#switch-to-another-server). - When you scroll, a small label shows the age of the child at the date of the moments on the screen. - When the timeline shows several children, each moment has a small badge in the color of its child, with its first letter. - Photos, videos, stories, milestones and growth records each have their own look in the grid. diff --git a/docs/app/troubleshooting.md b/docs/app/troubleshooting.md index 25f3232..825fa4b 100644 --- a/docs/app/troubleshooting.md +++ b/docs/app/troubleshooting.md @@ -33,7 +33,7 @@ When the app shows the sign-in screen without a reason, your sign-in ended. For | "Use at least 8 characters." | Type a longer password. | | "The email has already been taken." | An account with this email exists. Tap **Already have an account? Sign in**. | | "A valid invitation is required to join this instance." | The invitation is not valid, or it is for another email address. Ask the admin for a new invitation. | -| "Invitation for another server" | You are signed in, and the link is for another family. In **Settings**, tap **Add another family** and add the server of the invitation. On its sign-in screen, tap **I have an invitation** and paste the link. See [Several families](multiple-servers.md#add-a-family). | +| "Invitation for another server" | You are signed in, and the link is for another server. In **Settings**, tap **Add a server** and add the server of the invitation. On its sign-in screen, tap **I have an invitation** and paste the link. See [Several servers](multiple-servers.md#add-a-server). | | "The server has no public address" (on the admin's phone, after **Create invitation**) | The links use the address of the admin's phone. People outside your home network may not open them. The server owner sets `APP_URL`. See [APP_URL placeholder](../self-hosting/configuration.md#app-url-placeholder). | ## Children @@ -97,18 +97,19 @@ The server refuses a file in these cases: You can remove failed items with **Remove failed**. The photos and videos stay on the phone. -## Families +## Servers | Message | What to do | | --- | --- | -| "Server already configured" | The family is already on this phone. Find it on the **Families** screen. | -| "Test the connection first." | Tap **Test connection** before **Add family**. | +| "Server already configured" | The server is already on this phone. Find it under **Servers** in **Settings**. | +| "Test the connection first." | Tap **Test connection** before **Add server**. | | "Server not reachable" | The server does not answer. Check the address, the port and the network. | | "Server address not found" | The host name is wrong, or the phone cannot find it. Check the spelling. | -| "Could not open" with the name of a family | The app could not switch to the family. Check the connection and try again. | -| "Cannot remove this family" | You cannot remove the active family. Switch to another family first. | -| "Cannot remove this server yet" | The family has unsent changes on this phone. Switch to it and let them sync first. | -| "Name not saved. Check the connection and try again." | The server did not save the family name. Check the connection and try again. | +| "Could not open" with the name of a server, or "Could not switch to this server." | The app could not switch to the server. Check the connection and try again. | +| "The server was added, but it did not open. Open it from Settings." | In **Settings**, tap the new server, then tap **Switch to this server** or **Sign in to this server**. | +| "Cannot remove this server" | You cannot remove the server in use. Switch to another server first. With one server, use **Reset this phone** in **Settings**. | +| "Cannot remove this server yet" | The server has unsent changes on this phone. Switch to it and let them sync first. | +| "Name not saved. Check the connection and try again." | The server did not save the name. Check the connection and try again. | ## Members, devices and export @@ -137,5 +138,5 @@ You can remove failed items with **Remove failed**. The photos and videos stay o - Pull the timeline down to start a sync. - Close the app and open it again. -- In **Settings**, use **Reset and sync**. See [Settings](settings.md#reset-and-sync). +- In **Settings**, tap the server in use, then tap **Reset and sync**. See [Settings](settings.md#reset-and-sync). - Ask the server owner to check the server. See [Server troubleshooting](../self-hosting/troubleshooting.md). diff --git a/docs/faq.md b/docs/faq.md index f4a9dab..3423e7a 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -10,7 +10,7 @@ See [Install the app](/app/install). ## Can one server hold several families? -No. One server holds one family. A second family runs a second server. The app can hold several families. See [Several families](/app/multiple-servers). +No. One server holds one family. A second family runs a second server. The app can hold several servers. See [Several servers](/app/multiple-servers). ## Do I need a host name and HTTPS? diff --git a/docs/guide/what-is-kinlore.md b/docs/guide/what-is-kinlore.md index 97157c2..6fd256c 100644 --- a/docs/guide/what-is-kinlore.md +++ b/docs/guide/what-is-kinlore.md @@ -16,7 +16,7 @@ One Kinlore server holds one family. - **Shared data.** All members see all children and all moments. - **A family name.** The server has a name, for example "Anna Example Family". Members see it in the app and on invitations. A stranger who finds the server address does not see it. -A family that wants a second, separate space runs a second server. The app can hold several families. See [Several families](/app/multiple-servers). +A family that wants a second, separate space runs a second server. The app can hold several servers. See [Several servers](/app/multiple-servers). ## Roles diff --git a/docs/project/roadmap.md b/docs/project/roadmap.md index 34648f0..3f599ca 100644 --- a/docs/project/roadmap.md +++ b/docs/project/roadmap.md @@ -12,7 +12,7 @@ Kinlore is a self-hosted family photo journal. One Kinlore server holds **one fa - **Roles and permissions.** A partner can add and change everything. A family member can view, and can add moments, like, comment and download when the admin allows it. The full rules are in [API rules, section 1](/reference/api#_1-roles-and-permissions). - **Two ways to run it.** With Docker (PostgreSQL, SeaweedFS, Caddy with optional built-in HTTPS), see [Install with Docker](/self-hosting/docker). Or directly on a Linux host, where SQLite and the local disk are enough, see [Install without Docker](/self-hosting/bare-metal). -A family that wants a second space runs a second server. The app can hold several families, one server each, and switch between them. +A family that wants a second space runs a second server. The app can hold several servers, one family each, and switch between them. ## Planned work diff --git a/docs/reference/api.md b/docs/reference/api.md index b91d2f5..c6f1751 100644 --- a/docs/reference/api.md +++ b/docs/reference/api.md @@ -69,7 +69,10 @@ Returned by login, register and `/auth/me` (`/auth/me` adds the count fields): API: - `GET /auth/setup-status` (public): `{ needs_setup: bool, setup_token_required: bool, instance_name: string, setup_url: string }`. `setup_url` is `{base}/setup` (see the public address rule below). `setup_token_required` is the same as `needs_setup`. The app uses it to tell the user to finish setup in a browser. -- `POST /auth/register`: `name, email, password, password_confirmation, invite_token` (required). It only registers invited users and gives them the role and permissions of the invitation. On an instance with no user it returns `403` with the message "Finish setup in a web browser at {setup_url}". A taken email gives a `422` email error only together with a valid invitation; without one the answer is the invitation error. +- `POST /auth/register`: `name, email, password, password_confirmation, invite_token` (required). `device_name` is optional (see sign-in below). It only registers invited users and gives them the role and permissions of the invitation. On an instance with no user it returns `403` with the message "Finish setup in a web browser at {setup_url}". A taken email gives a `422` email error only together with a valid invitation; without one the answer is the invitation error. +- `POST /auth/login` (public, throttled 5/min): `email, password` (required), `device_name` (optional). Wrong credentials give a `422` email error. Login and register return the user payload, `token` and `token_type: "Bearer"`. +- `device_name`: a string of up to 60 characters of plain text, without control characters. The server trims it. It names the token, so the user can tell devices apart. Without it, or when it is empty, the name is `mobile-app`. Older app versions do not send it. +- `GET /auth/sessions` (signed in): the caller's tokens, each `{ id, name, abilities, last_used_at, created_at, is_current }`. `name` is the `device_name` of the sign-in. `POST /auth/refresh` gives a new token with the same name. `DELETE /auth/sessions/{id}` signs that device out. - `GET /auth/invitations/{token}` (public, throttled 10/min): `200 { valid: true, email: string|null, role, invited_by: { name }, expires_at, instance_name }`, or `404` when unknown, used or expired. - Invitation item (admin endpoints): `{ id, email, role, permissions: {...}, invited_by: { id, name }, expires_at, created_at }`. - `POST /v1/invitations` (admin): `{ email?, role?: partner|family (default family), permissions?: { add_content?, comment?, like?, download? }, expires_in_days?: 1..30 (default 7) }` → `201` invitation item plus `token`, `invite_link`, `invite_url`, `public_url_configured`: diff --git a/docs/self-hosting/configuration.md b/docs/self-hosting/configuration.md index 97e08ab..67823f9 100644 --- a/docs/self-hosting/configuration.md +++ b/docs/self-hosting/configuration.md @@ -48,6 +48,8 @@ The server treats `APP_URL` as a placeholder when it is empty, `localhost`, `127 To see the problem, look at `checks.public_url` in `GET /api/health/detailed`, or at the warning of `php artisan kinlore:setup-token`. The app can also warn the admin when an invitation is made. +With Docker, set `APP_URL` in the `.env` next to `docker-compose.yml`. A variable `APP_URL` in the shell that runs `docker compose` wins over that file, and `kinlore-api/.env` does not set it. The server prints the address it uses when it starts: `docker compose logs api | grep "Public address"`. + To fix it, set `APP_URL` to the public address, then run `docker compose up -d` (host install: `sudo -u www-data php artisan config:cache`). Invitations made before the change keep their old link. Revoke them and make new ones. ## Address and HTTPS diff --git a/docs/self-hosting/troubleshooting.md b/docs/self-hosting/troubleshooting.md index d4dd64d..4e7b3a5 100644 --- a/docs/self-hosting/troubleshooting.md +++ b/docs/self-hosting/troubleshooting.md @@ -28,6 +28,7 @@ More log commands are in [Maintenance](/self-hosting/maintenance#logs). | A log shows `permission denied` for a folder under `DATA_LOCATION` | With `deploy/docker/bind-mounts.yml`, each service writes as its own user into its subfolder. Keep the data folder on a local Linux file system such as ext4. Network shares and disks with FAT or NTFS often do not keep the owner of a file. After a copy, check that you used `cp -a`. See [Data locations](/self-hosting/data-locations). | | The setup page does not accept the token | Print the token again with `php artisan kinlore:setup-token`. If `SETUP_TOKEN` is set, enter that value. See [Create the first admin](/self-hosting/first-admin). | | Invitation links show `photos.example.com` (or `localhost`) | `APP_URL` still has the example value. The server then uses the address of the request, but that can be a local address that other people cannot open. Set `APP_URL` to the public address, run `docker compose up -d`, then make new invitations. See [APP_URL placeholder](/self-hosting/configuration#app-url-placeholder). | +| `APP_URL` is right in a `.env` file, but links still show another address | With Docker, the value comes from the shell that runs `docker compose`, then from the `.env` next to `docker-compose.yml`. `kinlore-api/.env` does not set it. Run `docker compose config \| grep APP_URL` to see the value Compose passes, and `docker compose logs api \| grep "Public address"` to see the value the server uses. Check `echo $APP_URL` in your shell: an exported variable wins over the file. Then run `docker compose up -d --build`. | | A changed variable has no effect | Docker: run `docker compose up -d`; `docker compose restart` is not enough. Host install: run `sudo -u www-data php artisan config:cache`. In Docker, check that the name is passed to the container. See [Where the variables are](/self-hosting/configuration#where-the-variables-are). | ## Web server and HTTPS diff --git a/docs/tutorials/invite-your-family.md b/docs/tutorials/invite-your-family.md index 2ee92f5..d2835f0 100644 --- a/docs/tutorials/invite-your-family.md +++ b/docs/tutorials/invite-your-family.md @@ -12,19 +12,20 @@ In the example, the admin invites Ben to the server of "Anna Example Family" at ## Part 1: The admin makes the invitation -1. Open the **Settings** tab. The card at the top shows the family name. With several families, check that it is the right family, or tap **Switch family**. -2. In the family section, tap **Invite someone**. The app shows "Invite to Anna Example Family", with the server address. -3. In **Email (optional)**, type the email of the person, for example `ben@example.com`. Then only this address can use the invitation. You can also leave the field empty. -4. Under **Role**, tap a role: +1. Open the **Settings** tab. Under **Servers**, tap the server of the family, for example "Anna Example Family". With several servers, check that this server shows **In use**. If not, tap **Switch to this server**. +2. Under **Family**, tap **Members**. +3. Tap **Invite someone**. The app shows "Invite to Anna Example Family", with the server address. +4. In **Email (optional)**, type the email of the person, for example `ben@example.com`. Then only this address can use the invitation. You can also leave the field empty. +5. Under **Role**, tap a role: - **Partner** for a person who manages the children and the moments with you, for example the other parent. - **Family** for all other people, for example grandparents. -5. For **Family**, choose the permissions. All four are on. Turn off what the person may not do: +6. For **Family**, choose the permissions. All four are on. Turn off what the person may not do: - **Add photos and moments** - **Comment** - **Like** - **Download original files** -6. Under **Expires after**, tap the number of days, for example **7 days**. -7. Tap **Create invitation**. +7. Under **Expires after**, tap the number of days, for example **7 days**. +8. Tap **Create invitation**. The app shows "Invitation ready", with a **Web page** link and an **App link**. The links start with the public address of the server, for example `https://photos.example.com/invite/...`. @@ -43,7 +44,7 @@ Send the invitation only to the person that you invite. Anyone with the link can ### Check that it worked -In **Settings**, tap **Members**. The invitation is under **Pending invitations**, with the role, "invited by" with your name, and the date when it expires. +On the **Members** screen, the invitation is under **Pending invitations**, with the role, "invited by" with your name, and the date when it expires. ## Part 3: The invited person joins @@ -73,7 +74,7 @@ If the link does not open the app: ### Check that it worked - On the phone of the person, the timeline shows the children of the family. -- In **Settings**, the card at the top shows the family name, and the person's name and role, for example "You: Ben, Family". +- In **Settings**, under **Servers**, the server shows the family name, and the person's name and role, for example "Ben, Family". - On the admin's phone, open **Members**. The person is in the list of members, and the invitation is no longer under **Pending invitations**. ## Part 4: The first sign-in on another phone @@ -85,7 +86,7 @@ The account now exists. On a second phone, or after a sign-out, the person signs 3. Type the **Email** and the **Password**. 4. Tap **Sign in**. -If the person already uses Kinlore for another family, they add this family in **Settings** with **Add another family**. See [Several families](../app/multiple-servers.md#add-a-family). +If the person already uses Kinlore with another server, they add this server in **Settings** with **Add a server**. See [Several servers](../app/multiple-servers.md#add-a-server). ## Change the rights later diff --git a/kinlore-api/.dockerignore b/kinlore-api/.dockerignore index d4ad339..d48f121 100644 --- a/kinlore-api/.dockerignore +++ b/kinlore-api/.dockerignore @@ -14,3 +14,4 @@ storage/app/public/* storage/framework/views/* storage/framework/testing/* storage/framework/cache/* +bootstrap/cache/*.php diff --git a/kinlore-api/app/Http/Controllers/Api/AuthController.php b/kinlore-api/app/Http/Controllers/Api/AuthController.php index ab09395..28453de 100644 --- a/kinlore-api/app/Http/Controllers/Api/AuthController.php +++ b/kinlore-api/app/Http/Controllers/Api/AuthController.php @@ -66,6 +66,7 @@ public function login(LoginRequest $request): JsonResponse $validated['email'], // The rule is only `required`, so a JSON number must become a string. $request->string('password')->toString(), + $validated['device_name'] ?? null, ); return ApiResponse::success($result, 'Login successful'); diff --git a/kinlore-api/app/Http/Requests/Api/LoginRequest.php b/kinlore-api/app/Http/Requests/Api/LoginRequest.php index 469be64..77fa2df 100644 --- a/kinlore-api/app/Http/Requests/Api/LoginRequest.php +++ b/kinlore-api/app/Http/Requests/Api/LoginRequest.php @@ -19,6 +19,8 @@ public function rules(): array return [ 'email' => 'required|email', 'password' => 'required', + // Shown in the app's list of signed-in devices; empty becomes null (ConvertEmptyStringsToNull). + 'device_name' => ['nullable', 'string', 'max:60', 'not_regex:/[\x00-\x1F\x7F]/'], ]; } diff --git a/kinlore-api/app/Http/Requests/Api/RegisterRequest.php b/kinlore-api/app/Http/Requests/Api/RegisterRequest.php index 9de5912..68fea01 100644 --- a/kinlore-api/app/Http/Requests/Api/RegisterRequest.php +++ b/kinlore-api/app/Http/Requests/Api/RegisterRequest.php @@ -34,6 +34,8 @@ public function rules(): array 'email' => 'required|string|email|max:255', 'password' => 'required|string|min:8|confirmed', 'invite_token' => 'required|string|max:64', + // Shown in the app's list of signed-in devices; empty becomes null (ConvertEmptyStringsToNull). + 'device_name' => ['nullable', 'string', 'max:60', 'not_regex:/[\x00-\x1F\x7F]/'], ]; } diff --git a/kinlore-api/app/Services/AuthService.php b/kinlore-api/app/Services/AuthService.php index e851b2d..4dae3ec 100644 --- a/kinlore-api/app/Services/AuthService.php +++ b/kinlore-api/app/Services/AuthService.php @@ -26,6 +26,9 @@ class AuthService // Under storage/, so the web server never serves it. Relative to storage_path(). public const string SETUP_TOKEN_FILE = 'app/setup-token'; + // Token name when the app sends no device_name (app versions before 1.6). + public const string DEFAULT_TOKEN_NAME = 'mobile-app'; + public function __construct( private readonly FamilyService $family, ) {} @@ -132,7 +135,7 @@ public function forgetSetupToken(): void * Register an invited user with the invitation's role and permissions. * The first admin is created on the web setup page instead (createFirstAdmin). * - * @param array{name: string, email: string, password: string, invite_token: string} $data + * @param array{name: string, email: string, password: string, invite_token: string, device_name?: ?string} $data * @return array{user: array, token: string, token_type: string} * * @throws ValidationException @@ -154,7 +157,7 @@ public function register(#[\SensitiveParameter] array $data): array return $user; })); - $token = $user->createToken('mobile-app', ['*'])->plainTextToken; + $token = $user->createToken($data['device_name'] ?? self::DEFAULT_TOKEN_NAME, ['*'])->plainTextToken; return [ 'user' => $this->userPayload($user->refresh()), @@ -203,7 +206,7 @@ private function claimInvitation(string $token, string $email): Invitation * * @throws ValidationException */ - public function login(string $email, #[\SensitiveParameter] string $password): array + public function login(string $email, #[\SensitiveParameter] string $password, ?string $deviceName = null): array { $user = User::where('email', $email)->first(); $valid = Hash::check($password, $user ? $user->password : self::DUMMY_PASSWORD_HASH); @@ -214,7 +217,7 @@ public function login(string $email, #[\SensitiveParameter] string $password): a ]); } - $token = $user->createToken('mobile-app')->plainTextToken; + $token = $user->createToken($deviceName ?? self::DEFAULT_TOKEN_NAME)->plainTextToken; return [ 'user' => $this->userPayload($user), @@ -233,12 +236,13 @@ public function logoutAll(User $user): void $user->tokens()->delete(); } - // Revoke the current token and return a new one + // Revoke the current token and return a new one with the same device name public function refresh(User $user): string { - $user->currentAccessToken()->delete(); + $current = $user->currentAccessToken(); + $current->delete(); - return $user->createToken('mobile-app')->plainTextToken; + return $user->createToken($current->name)->plainTextToken; } // docs/reference/api.md section 2 diff --git a/kinlore-api/docker/entrypoint.sh b/kinlore-api/docker/entrypoint.sh index 073a5b7..e8ee3e3 100644 --- a/kinlore-api/docker/entrypoint.sh +++ b/kinlore-api/docker/entrypoint.sh @@ -3,6 +3,10 @@ set -e echo "🚀 Starting Kinlore API..." +# A config cache from the build folder or an earlier start holds old settings (an old APP_URL, for example). +# Remove it before the first artisan call, so every start reads the environment of this container. +rm -f bootstrap/cache/config.php + # An empty bind mount (deploy/docker/bind-mounts.yml) has none of the folders Laravel writes to mkdir -p storage/app/private storage/app/public storage/framework/cache storage/framework/sessions storage/framework/views storage/logs @@ -84,6 +88,15 @@ CADDY_TRUSTED_PROXIES="$(echo "${TRUSTED_PROXIES:-private_ranges}" | tr ',' ' ') [ "$CADDY_TRUSTED_PROXIES" = "*" ] && CADDY_TRUSTED_PROXIES="0.0.0.0/0 ::/0" export CADDY_TRUSTED_PROXIES +# The address in invitation and setup links. Compose takes APP_URL from the shell that runs it, then from the .env +# next to docker-compose.yml; kinlore-api/.env does not set it. +php artisan tinker --execute=" +echo '🌐 Public address (APP_URL): ' . config('app.url') . PHP_EOL; +if (! App\\Support\\PublicUrl::isConfigured()) { + echo '⚠️ APP_URL is a placeholder. Links use the address of each request. Set APP_URL in the .env next to docker-compose.yml.' . PHP_EOL; +} +" || true + echo "✅ Initialization complete, starting Caddy + PHP-FPM..." # Artisan above ran as root; PHP-FPM and the queue worker run as www-data and must write here diff --git a/kinlore-api/openapi.yaml b/kinlore-api/openapi.yaml index c8a3753..182d2b4 100644 --- a/kinlore-api/openapi.yaml +++ b/kinlore-api/openapi.yaml @@ -241,6 +241,10 @@ paths: format: email password: type: string + device_name: + type: [string, 'null'] + maxLength: 60 + description: Up to 60 characters of plain text, no control characters. Trimmed. Names the token in `GET /auth/sessions`. Empty or missing gives `mobile-app`. responses: '200': description: Signed in @@ -1922,6 +1926,7 @@ components: type: integer name: type: string + description: The `device_name` sent at login or registration, or `mobile-app` when none was sent. `POST /auth/refresh` keeps it. abilities: type: array items: @@ -1954,6 +1959,10 @@ components: invite_token: type: string maxLength: 64 + device_name: + type: [string, 'null'] + maxLength: 60 + description: Up to 60 characters of plain text, no control characters. Trimmed. Names the token in `GET /auth/sessions`. Empty or missing gives `mobile-app`. SetupStatus: type: object @@ -2033,7 +2042,7 @@ components: allOf: - $ref: '#/components/schemas/Invitation' - type: object - required: [token, invite_link, invite_url] + required: [token, invite_link, invite_url, public_url_configured] properties: token: type: string @@ -2045,6 +2054,9 @@ components: type: string format: uri description: '`{APP_URL}/invite/{token}`, the public HTML page.' + public_url_configured: + type: boolean + description: False when APP_URL is empty or a placeholder. The links then use the address of this request. Member: type: object @@ -2719,6 +2731,20 @@ components: type: object memory: type: object + public_url: + type: object + description: A warning only; it does not change `status`. + required: [status, url] + properties: + status: + type: string + enum: [ok, warning] + url: + type: string + description: The public address the server uses for links. + message: + type: string + description: Only with `warning`. APP_URL is empty or a placeholder. php: type: object diff --git a/kinlore-api/tests/Feature/Auth/DeviceNameTest.php b/kinlore-api/tests/Feature/Auth/DeviceNameTest.php new file mode 100644 index 0000000..f28a471 --- /dev/null +++ b/kinlore-api/tests/Feature/Auth/DeviceNameTest.php @@ -0,0 +1,112 @@ +create(['email' => 'test@kinlore.local', 'password' => bcrypt('password123')]); + + return $this->postJson('/api/auth/login', ['email' => 'test@kinlore.local', 'password' => 'password123'] + $extra); + } + + private function sessionNames(string $token): array + { + return $this->withToken($token)->getJson('/api/auth/sessions')->assertOk()->json('data.*.name'); + } + + public function test_login_with_device_name_names_the_session(): void + { + $token = $this->login(['device_name' => ' Elyess’s iPhone '])->assertOk()->json('data.token'); + + $this->assertSame(['Elyess’s iPhone'], $this->sessionNames($token)); + } + + public function test_login_without_device_name_uses_the_old_name(): void + { + $token = $this->login()->assertOk()->json('data.token'); + + $this->assertSame(['mobile-app'], $this->sessionNames($token)); + } + + public function test_login_with_empty_device_name_uses_the_old_name(): void + { + $token = $this->login(['device_name' => ' '])->assertOk()->json('data.token'); + + $this->assertSame(['mobile-app'], $this->sessionNames($token)); + } + + public function test_refresh_keeps_the_device_name(): void + { + $token = $this->login(['device_name' => 'Pixel 9'])->json('data.token'); + $newToken = $this->withToken($token)->postJson('/api/auth/refresh')->assertOk()->json('data.token'); + $this->app['auth']->forgetGuards(); + + $this->assertSame(['Pixel 9'], $this->sessionNames($newToken)); + } + + /** @return array */ + public static function invalidDeviceNames(): array + { + return [ + 'too long' => [str_repeat('a', 61)], + 'number' => [123], + 'array' => [['iPhone']], + 'control character' => ["iPhone\x07"], + ]; + } + + #[DataProvider('invalidDeviceNames')] + public function test_login_rejects_an_invalid_device_name(mixed $deviceName): void + { + $this->login(['device_name' => $deviceName])->assertStatus(422)->assertJsonValidationErrors('device_name'); + } + + public function test_register_with_device_name_names_the_session(): void + { + $invitation = Invitation::create([ + 'token' => 'tok-device', + 'role' => 'family', + 'invited_by' => User::factory()->admin()->create()->id, + 'expires_at' => now()->addDays(7), + ]); + + $token = $this->postJson('/api/auth/register', [ + 'name' => 'Test User', + 'email' => 'new@kinlore.local', + 'password' => 'password123', + 'password_confirmation' => 'password123', + 'invite_token' => $invitation->token, + 'device_name' => 'iPad', + ])->assertCreated()->json('data.token'); + + $this->assertSame(['iPad'], $this->sessionNames($token)); + } + + public function test_register_rejects_a_too_long_device_name(): void + { + User::factory()->admin()->create(); // registration is closed until setup made the first user + + $this->postJson('/api/auth/register', [ + 'name' => 'Test User', + 'email' => 'new@kinlore.local', + 'password' => 'password123', + 'password_confirmation' => 'password123', + 'invite_token' => 'whatever', + 'device_name' => str_repeat('a', 61), + ])->assertStatus(422)->assertJsonValidationErrors('device_name'); + } +}