Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
feat(mfa): add password verification during TOTP reset and deactivation
johaven5ed579fd31dc
diff --git a/README.md b/README.mdindex d04bc12c..f163d472 100644--- a/README.md+++ b/README.md@@ -41,6 +41,7 @@ Sync-in fits seamlessly into any environment — from small teams to large enter- 🔒 Security & Data Ownership- Full control over data security and compliance- Designed to protect sensitive documents and prevent unauthorized access+ - **Multi-Factor Authentication (MFA)**: TOTP (authenticator apps), recovery codes, app passwords- 🔑 Advanced User Access Control- **Spaces & Shares**: Organize files with fine-grained access permissions- Role-based permission system ensuring secure file managementdiff --git a/backend/migrations/0002_sleepy_korath.sql b/backend/migrations/0002_sleepy_korath.sqlnew file mode 100644index 00000000..73d85b1f--- /dev/null+++ b/backend/migrations/0002_sleepy_korath.sql@@ -0,0 +1 @@+ALTER TABLE `users` ADD `secrets` json;\ No newline at end of filediff --git a/backend/migrations/meta/0002_snapshot.json b/backend/migrations/meta/0002_snapshot.jsonnew file mode 100644index 00000000..00e5b06e--- /dev/null+++ b/backend/migrations/meta/0002_snapshot.json@@ -0,0 +1,2424 @@+{+ "version": "5",+ "dialect": "mysql",+ "id": "076fc362-3587-4607-8075-e08cb473342e",+ "prevId": "2d75e81b-44bf-4633-b5b4-3774683a2d78",+ "tables": {+ "cache": {+ "name": "cache",+ "columns": {+ "key": {+ "name": "key",+ "type": "varchar(768)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "value": {+ "name": "value",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "expiration": {+ "name": "expiration",+ "type": "int",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": -1+ }+ },+ "indexes": {+ "expiration_idx": {+ "name": "expiration_idx",+ "columns": [+ "expiration"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "cache_key": {+ "name": "cache_key",+ "columns": [+ "key"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "users": {+ "name": "users",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "login": {+ "name": "login",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "firstName": {+ "name": "firstName",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "lastName": {+ "name": "lastName",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "password": {+ "name": "password",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "passwordAttempts": {+ "name": "passwordAttempts",+ "type": "tinyint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "role": {+ "name": "role",+ "type": "tinyint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "isActive": {+ "name": "isActive",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "secrets": {+ "name": "secrets",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "language": {+ "name": "language",+ "type": "char(2)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "permissions": {+ "name": "permissions",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "storageUsage": {+ "name": "storageUsage",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": 0+ },+ "storageQuota": {+ "name": "storageQuota",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "notification": {+ "name": "notification",+ "type": "tinyint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "onlineStatus": {+ "name": "onlineStatus",+ "type": "tinyint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "currentIp": {+ "name": "currentIp",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "lastIp": {+ "name": "lastIp",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "currentAccess": {+ "name": "currentAccess",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "lastAccess": {+ "name": "lastAccess",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "email_idx": {+ "name": "email_idx",+ "columns": [+ "email"+ ],+ "isUnique": true+ },+ "login_idx": {+ "name": "login_idx",+ "columns": [+ "login"+ ],+ "isUnique": true+ },+ "role_idx": {+ "name": "role_idx",+ "columns": [+ "role"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "users_id": {+ "name": "users_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "groups": {+ "name": "groups",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "tinyint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "visibility": {+ "name": "visibility",+ "type": "tinyint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "parentId": {+ "name": "parentId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "permissions": {+ "name": "permissions",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "modifiedAt": {+ "name": "modifiedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "name_idx": {+ "name": "name_idx",+ "columns": [+ "name"+ ],+ "isUnique": true+ },+ "parent_idx": {+ "name": "parent_idx",+ "columns": [+ "parentId"+ ],+ "isUnique": false+ },+ "type_idx": {+ "name": "type_idx",+ "columns": [+ "type"+ ],+ "isUnique": false+ },+ "visibility_idx": {+ "name": "visibility_idx",+ "columns": [+ "visibility"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "groups_parentId_groups_id_fk": {+ "name": "groups_parentId_groups_id_fk",+ "tableFrom": "groups",+ "tableTo": "groups",+ "columnsFrom": [+ "parentId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "groups_id": {+ "name": "groups_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "users_groups": {+ "name": "users_groups",+ "columns": {+ "userId": {+ "name": "userId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "groupId": {+ "name": "groupId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "tinyint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "user_idx": {+ "name": "user_idx",+ "columns": [+ "userId"+ ],+ "isUnique": false+ },+ "group_idx": {+ "name": "group_idx",+ "columns": [+ "groupId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "users_groups_userId_users_id_fk": {+ "name": "users_groups_userId_users_id_fk",+ "tableFrom": "users_groups",+ "tableTo": "users",+ "columnsFrom": [+ "userId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "users_groups_groupId_groups_id_fk": {+ "name": "users_groups_groupId_groups_id_fk",+ "tableFrom": "users_groups",+ "tableTo": "groups",+ "columnsFrom": [+ "groupId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "users_groups_userId_groupId_pk": {+ "name": "users_groups_userId_groupId_pk",+ "columns": [+ "userId",+ "groupId"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "users_guests": {+ "name": "users_guests",+ "columns": {+ "userId": {+ "name": "userId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "guestId": {+ "name": "guestId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "user_idx": {+ "name": "user_idx",+ "columns": [+ "userId"+ ],+ "isUnique": false+ },+ "guest_id": {+ "name": "guest_id",+ "columns": [+ "guestId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "users_guests_userId_users_id_fk": {+ "name": "users_guests_userId_users_id_fk",+ "tableFrom": "users_guests",+ "tableTo": "users",+ "columnsFrom": [+ "userId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "users_guests_guestId_users_id_fk": {+ "name": "users_guests_guestId_users_id_fk",+ "tableFrom": "users_guests",+ "tableTo": "users",+ "columnsFrom": [+ "guestId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "users_guests_userId_guestId_pk": {+ "name": "users_guests_userId_guestId_pk",+ "columns": [+ "userId",+ "guestId"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {+ "user_guest_check": {+ "name": "user_guest_check",+ "value": "`users_guests`.`userId` <> `users_guests`.`guestId`"+ }+ }+ },+ "spaces": {+ "name": "spaces",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "alias": {+ "name": "alias",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "storageUsage": {+ "name": "storageUsage",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "storageQuota": {+ "name": "storageQuota",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "modifiedAt": {+ "name": "modifiedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"+ },+ "disabledAt": {+ "name": "disabledAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "alias_idx": {+ "name": "alias_idx",+ "columns": [+ "alias"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "spaces_id": {+ "name": "spaces_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "spaces_members": {+ "name": "spaces_members",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "spaceId": {+ "name": "spaceId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "groupId": {+ "name": "groupId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "linkId": {+ "name": "linkId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "role": {+ "name": "role",+ "type": "tinyint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "permissions": {+ "name": "permissions",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "modifiedAt": {+ "name": "modifiedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "space_idx": {+ "name": "space_idx",+ "columns": [+ "spaceId"+ ],+ "isUnique": false+ },+ "user_idx": {+ "name": "user_idx",+ "columns": [+ "userId"+ ],+ "isUnique": false+ },+ "group_idx": {+ "name": "group_idx",+ "columns": [+ "groupId"+ ],+ "isUnique": false+ },+ "link_idx": {+ "name": "link_idx",+ "columns": [+ "linkId"+ ],+ "isUnique": false+ },+ "role_idx": {+ "name": "role_idx",+ "columns": [+ "role"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "spaces_members_spaceId_spaces_id_fk": {+ "name": "spaces_members_spaceId_spaces_id_fk",+ "tableFrom": "spaces_members",+ "tableTo": "spaces",+ "columnsFrom": [+ "spaceId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "spaces_members_userId_users_id_fk": {+ "name": "spaces_members_userId_users_id_fk",+ "tableFrom": "spaces_members",+ "tableTo": "users",+ "columnsFrom": [+ "userId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "spaces_members_groupId_groups_id_fk": {+ "name": "spaces_members_groupId_groups_id_fk",+ "tableFrom": "spaces_members",+ "tableTo": "groups",+ "columnsFrom": [+ "groupId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "spaces_members_linkId_links_id_fk": {+ "name": "spaces_members_linkId_links_id_fk",+ "tableFrom": "spaces_members",+ "tableTo": "links",+ "columnsFrom": [+ "linkId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "spaces_members_id": {+ "name": "spaces_members_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "space_user_uniq": {+ "name": "space_user_uniq",+ "columns": [+ "spaceId",+ "userId"+ ]+ },+ "space_group_uniq": {+ "name": "space_group_uniq",+ "columns": [+ "spaceId",+ "groupId"+ ]+ },+ "space_link_uniq": {+ "name": "space_link_uniq",+ "columns": [+ "spaceId",+ "linkId"+ ]+ }+ },+ "checkConstraint": {}+ },+ "spaces_roots": {+ "name": "spaces_roots",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "spaceId": {+ "name": "spaceId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "fileId": {+ "name": "fileId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "alias": {+ "name": "alias",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "externalPath": {+ "name": "externalPath",+ "type": "varchar(4096)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "permissions": {+ "name": "permissions",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "modifiedAt": {+ "name": "modifiedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "alias_idx": {+ "name": "alias_idx",+ "columns": [+ "alias"+ ],+ "isUnique": false+ },+ "space_idx": {+ "name": "space_idx",+ "columns": [+ "spaceId"+ ],+ "isUnique": false+ },+ "file_idx": {+ "name": "file_idx",+ "columns": [+ "fileId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "spaces_roots_spaceId_spaces_id_fk": {+ "name": "spaces_roots_spaceId_spaces_id_fk",+ "tableFrom": "spaces_roots",+ "tableTo": "spaces",+ "columnsFrom": [+ "spaceId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "spaces_roots_fileId_files_id_fk": {+ "name": "spaces_roots_fileId_files_id_fk",+ "tableFrom": "spaces_roots",+ "tableTo": "files",+ "columnsFrom": [+ "fileId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "spaces_roots_id": {+ "name": "spaces_roots_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "space_root_alias_uniq": {+ "name": "space_root_alias_uniq",+ "columns": [+ "id",+ "alias"+ ]+ }+ },+ "checkConstraint": {}+ },+ "shares": {+ "name": "shares",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "ownerId": {+ "name": "ownerId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "parentId": {+ "name": "parentId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "spaceId": {+ "name": "spaceId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "spaceRootId": {+ "name": "spaceRootId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "fileId": {+ "name": "fileId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "externalPath": {+ "name": "externalPath",+ "type": "varchar(4096)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "type": {+ "name": "type",+ "type": "tinyint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "alias": {+ "name": "alias",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "description": {+ "name": "description",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "modifiedAt": {+ "name": "modifiedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"+ },+ "disabledAt": {+ "name": "disabledAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "alias_idx": {+ "name": "alias_idx",+ "columns": [+ "alias"+ ],+ "isUnique": true+ },+ "parent_idx": {+ "name": "parent_idx",+ "columns": [+ "parentId"+ ],+ "isUnique": false+ },+ "owner_idx": {+ "name": "owner_idx",+ "columns": [+ "ownerId"+ ],+ "isUnique": false+ },+ "space_idx": {+ "name": "space_idx",+ "columns": [+ "spaceId"+ ],+ "isUnique": false+ },+ "space_root_idx": {+ "name": "space_root_idx",+ "columns": [+ "spaceRootId"+ ],+ "isUnique": false+ },+ "file_idx": {+ "name": "file_idx",+ "columns": [+ "fileId"+ ],+ "isUnique": false+ },+ "type_idx": {+ "name": "type_idx",+ "columns": [+ "type"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "shares_ownerId_users_id_fk": {+ "name": "shares_ownerId_users_id_fk",+ "tableFrom": "shares",+ "tableTo": "users",+ "columnsFrom": [+ "ownerId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shares_parentId_shares_id_fk": {+ "name": "shares_parentId_shares_id_fk",+ "tableFrom": "shares",+ "tableTo": "shares",+ "columnsFrom": [+ "parentId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shares_spaceId_spaces_id_fk": {+ "name": "shares_spaceId_spaces_id_fk",+ "tableFrom": "shares",+ "tableTo": "spaces",+ "columnsFrom": [+ "spaceId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shares_spaceRootId_spaces_roots_id_fk": {+ "name": "shares_spaceRootId_spaces_roots_id_fk",+ "tableFrom": "shares",+ "tableTo": "spaces_roots",+ "columnsFrom": [+ "spaceRootId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shares_fileId_files_id_fk": {+ "name": "shares_fileId_files_id_fk",+ "tableFrom": "shares",+ "tableTo": "files",+ "columnsFrom": [+ "fileId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "shares_id": {+ "name": "shares_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "shares_members": {+ "name": "shares_members",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "shareId": {+ "name": "shareId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "groupId": {+ "name": "groupId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "linkId": {+ "name": "linkId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "permissions": {+ "name": "permissions",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "''"+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "modifiedAt": {+ "name": "modifiedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "share_idx": {+ "name": "share_idx",+ "columns": [+ "shareId"+ ],+ "isUnique": false+ },+ "user_idx": {+ "name": "user_idx",+ "columns": [+ "userId"+ ],+ "isUnique": false+ },+ "group_idx": {+ "name": "group_idx",+ "columns": [+ "groupId"+ ],+ "isUnique": false+ },+ "link_idx": {+ "name": "link_idx",+ "columns": [+ "linkId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "shares_members_shareId_shares_id_fk": {+ "name": "shares_members_shareId_shares_id_fk",+ "tableFrom": "shares_members",+ "tableTo": "shares",+ "columnsFrom": [+ "shareId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shares_members_userId_users_id_fk": {+ "name": "shares_members_userId_users_id_fk",+ "tableFrom": "shares_members",+ "tableTo": "users",+ "columnsFrom": [+ "userId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shares_members_groupId_groups_id_fk": {+ "name": "shares_members_groupId_groups_id_fk",+ "tableFrom": "shares_members",+ "tableTo": "groups",+ "columnsFrom": [+ "groupId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shares_members_linkId_links_id_fk": {+ "name": "shares_members_linkId_links_id_fk",+ "tableFrom": "shares_members",+ "tableTo": "links",+ "columnsFrom": [+ "linkId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "shares_members_id": {+ "name": "shares_members_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {+ "share_user_uniq": {+ "name": "share_user_uniq",+ "columns": [+ "shareId",+ "userId"+ ]+ },+ "share_group_uniq": {+ "name": "share_group_uniq",+ "columns": [+ "shareId",+ "groupId"+ ]+ },+ "share_link_uniq": {+ "name": "share_link_uniq",+ "columns": [+ "shareId",+ "linkId"+ ]+ }+ },+ "checkConstraint": {}+ },+ "files": {+ "name": "files",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "ownerId": {+ "name": "ownerId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "spaceId": {+ "name": "spaceId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "spaceExternalRootId": {+ "name": "spaceExternalRootId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "shareExternalId": {+ "name": "shareExternalId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "path": {+ "name": "path",+ "type": "varchar(4096)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "isDir": {+ "name": "isDir",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "inTrash": {+ "name": "inTrash",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "mime": {+ "name": "mime",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "size": {+ "name": "size",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": 0+ },+ "mtime": {+ "name": "mtime",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": 0+ },+ "ctime": {+ "name": "ctime",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": 0+ }+ },+ "indexes": {+ "owner_idx": {+ "name": "owner_idx",+ "columns": [+ "ownerId"+ ],+ "isUnique": false+ },+ "space_idx": {+ "name": "space_idx",+ "columns": [+ "spaceId"+ ],+ "isUnique": false+ },+ "space_external_root_idx": {+ "name": "space_external_root_idx",+ "columns": [+ "spaceExternalRootId"+ ],+ "isUnique": false+ },+ "share_external_idx": {+ "name": "share_external_idx",+ "columns": [+ "shareExternalId"+ ],+ "isUnique": false+ },+ "name_idx": {+ "name": "name_idx",+ "columns": [+ "name"+ ],+ "isUnique": false+ },+ "path_idx": {+ "name": "path_idx",+ "columns": [+ "path"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "files_ownerId_users_id_fk": {+ "name": "files_ownerId_users_id_fk",+ "tableFrom": "files",+ "tableTo": "users",+ "columnsFrom": [+ "ownerId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_spaceId_spaces_id_fk": {+ "name": "files_spaceId_spaces_id_fk",+ "tableFrom": "files",+ "tableTo": "spaces",+ "columnsFrom": [+ "spaceId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_spaceExternalRootId_spaces_roots_id_fk": {+ "name": "files_spaceExternalRootId_spaces_roots_id_fk",+ "tableFrom": "files",+ "tableTo": "spaces_roots",+ "columnsFrom": [+ "spaceExternalRootId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_shareExternalId_shares_id_fk": {+ "name": "files_shareExternalId_shares_id_fk",+ "tableFrom": "files",+ "tableTo": "shares",+ "columnsFrom": [+ "shareExternalId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "files_id": {+ "name": "files_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "files_recents": {+ "name": "files_recents",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "spaceId": {+ "name": "spaceId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "shareId": {+ "name": "shareId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "path": {+ "name": "path",+ "type": "varchar(4096)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "mime": {+ "name": "mime",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "mtime": {+ "name": "mtime",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "owner_idx": {+ "name": "owner_idx",+ "columns": [+ "ownerId"+ ],+ "isUnique": false+ },+ "space_idx": {+ "name": "space_idx",+ "columns": [+ "spaceId"+ ],+ "isUnique": false+ },+ "share_idx": {+ "name": "share_idx",+ "columns": [+ "shareId"+ ],+ "isUnique": false+ },+ "mtime_idx": {+ "name": "mtime_idx",+ "columns": [+ "mtime"+ ],+ "isUnique": false+ },+ "path_idx": {+ "name": "path_idx",+ "columns": [+ "path"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "files_recents_ownerId_users_id_fk": {+ "name": "files_recents_ownerId_users_id_fk",+ "tableFrom": "files_recents",+ "tableTo": "users",+ "columnsFrom": [+ "ownerId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_recents_spaceId_spaces_id_fk": {+ "name": "files_recents_spaceId_spaces_id_fk",+ "tableFrom": "files_recents",+ "tableTo": "spaces",+ "columnsFrom": [+ "spaceId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "files_recents_shareId_shares_id_fk": {+ "name": "files_recents_shareId_shares_id_fk",+ "tableFrom": "files_recents",+ "tableTo": "shares",+ "columnsFrom": [+ "shareId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "links": {+ "name": "links",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "uuid": {+ "name": "uuid",+ "type": "varchar(32)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "userId": {+ "name": "userId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "email": {+ "name": "email",+ "type": "varchar(255)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "requireAuth": {+ "name": "requireAuth",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "nbAccess": {+ "name": "nbAccess",+ "type": "int unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "limitAccess": {+ "name": "limitAccess",+ "type": "int unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "expiresAt": {+ "name": "expiresAt",+ "type": "date",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "user_idx": {+ "name": "user_idx",+ "columns": [+ "userId"+ ],+ "isUnique": false+ },+ "uuid_idx": {+ "name": "uuid_idx",+ "columns": [+ "uuid"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "links_userId_users_id_fk": {+ "name": "links_userId_users_id_fk",+ "tableFrom": "links",+ "tableTo": "users",+ "columnsFrom": [+ "userId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "links_id": {+ "name": "links_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "comments": {+ "name": "comments",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "userId": {+ "name": "userId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "fileId": {+ "name": "fileId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "modifiedAt": {+ "name": "modifiedAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "user_idx": {+ "name": "user_idx",+ "columns": [+ "userId"+ ],+ "isUnique": false+ },+ "file_idx": {+ "name": "file_idx",+ "columns": [+ "fileId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "comments_userId_users_id_fk": {+ "name": "comments_userId_users_id_fk",+ "tableFrom": "comments",+ "tableTo": "users",+ "columnsFrom": [+ "userId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "comments_fileId_files_id_fk": {+ "name": "comments_fileId_files_id_fk",+ "tableFrom": "comments",+ "tableTo": "files",+ "columnsFrom": [+ "fileId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "comments_id": {+ "name": "comments_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "notifications": {+ "name": "notifications",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "fromUserId": {+ "name": "fromUserId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "toUserId": {+ "name": "toUserId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "json",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "wasRead": {+ "name": "wasRead",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "from_user_idx": {+ "name": "from_user_idx",+ "columns": [+ "fromUserId"+ ],+ "isUnique": false+ },+ "to_user_idx": {+ "name": "to_user_idx",+ "columns": [+ "toUserId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "notifications_fromUserId_users_id_fk": {+ "name": "notifications_fromUserId_users_id_fk",+ "tableFrom": "notifications",+ "tableTo": "users",+ "columnsFrom": [+ "fromUserId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notifications_toUserId_users_id_fk": {+ "name": "notifications_toUserId_users_id_fk",+ "tableFrom": "notifications",+ "tableTo": "users",+ "columnsFrom": [+ "toUserId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "notifications_id": {+ "name": "notifications_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "sync_clients": {+ "name": "sync_clients",+ "columns": {+ "id": {+ "name": "id",+ "type": "char(36)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "token": {+ "name": "token",+ "type": "char(36)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "tokenExpiration": {+ "name": "tokenExpiration",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "info": {+ "name": "info",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "currentIp": {+ "name": "currentIp",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "lastIp": {+ "name": "lastIp",+ "type": "varchar(45)",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "currentAccess": {+ "name": "currentAccess",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "lastAccess": {+ "name": "lastAccess",+ "type": "datetime",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "owner_idx": {+ "name": "owner_idx",+ "columns": [+ "ownerId"+ ],+ "isUnique": false+ },+ "token_idx": {+ "name": "token_idx",+ "columns": [+ "token"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "sync_clients_ownerId_users_id_fk": {+ "name": "sync_clients_ownerId_users_id_fk",+ "tableFrom": "sync_clients",+ "tableTo": "users",+ "columnsFrom": [+ "ownerId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "sync_clients_id": {+ "name": "sync_clients_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ },+ "sync_paths": {+ "name": "sync_paths",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": true+ },+ "clientId": {+ "name": "clientId",+ "type": "char(36)",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "ownerId": {+ "name": "ownerId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "spaceId": {+ "name": "spaceId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "spaceRootId": {+ "name": "spaceRootId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "shareId": {+ "name": "shareId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "fileId": {+ "name": "fileId",+ "type": "bigint unsigned",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "settings": {+ "name": "settings",+ "type": "json",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "createdAt": {+ "name": "createdAt",+ "type": "datetime",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {+ "client_idx": {+ "name": "client_idx",+ "columns": [+ "clientId"+ ],+ "isUnique": false+ },+ "owner_idx": {+ "name": "owner_idx",+ "columns": [+ "ownerId"+ ],+ "isUnique": false+ },+ "space_idx": {+ "name": "space_idx",+ "columns": [+ "spaceId"+ ],+ "isUnique": false+ },+ "space_root_idx": {+ "name": "space_root_idx",+ "columns": [+ "spaceRootId"+ ],+ "isUnique": false+ },+ "share_idx": {+ "name": "share_idx",+ "columns": [+ "shareId"+ ],+ "isUnique": false+ },+ "file_idx": {+ "name": "file_idx",+ "columns": [+ "fileId"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "sync_paths_clientId_sync_clients_id_fk": {+ "name": "sync_paths_clientId_sync_clients_id_fk",+ "tableFrom": "sync_paths",+ "tableTo": "sync_clients",+ "columnsFrom": [+ "clientId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sync_paths_ownerId_users_id_fk": {+ "name": "sync_paths_ownerId_users_id_fk",+ "tableFrom": "sync_paths",+ "tableTo": "users",+ "columnsFrom": [+ "ownerId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sync_paths_spaceId_spaces_id_fk": {+ "name": "sync_paths_spaceId_spaces_id_fk",+ "tableFrom": "sync_paths",+ "tableTo": "spaces",+ "columnsFrom": [+ "spaceId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sync_paths_spaceRootId_spaces_roots_id_fk": {+ "name": "sync_paths_spaceRootId_spaces_roots_id_fk",+ "tableFrom": "sync_paths",+ "tableTo": "spaces_roots",+ "columnsFrom": [+ "spaceRootId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sync_paths_shareId_shares_id_fk": {+ "name": "sync_paths_shareId_shares_id_fk",+ "tableFrom": "sync_paths",+ "tableTo": "shares",+ "columnsFrom": [+ "shareId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sync_paths_fileId_files_id_fk": {+ "name": "sync_paths_fileId_files_id_fk",+ "tableFrom": "sync_paths",+ "tableTo": "files",+ "columnsFrom": [+ "fileId"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "sync_paths_id": {+ "name": "sync_paths_id",+ "columns": [+ "id"+ ]+ }+ },+ "uniqueConstraints": {},+ "checkConstraint": {}+ }+ },+ "views": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "tables": {},+ "indexes": {}+ }+}\ No newline at end of filediff --git a/backend/migrations/meta/_journal.json b/backend/migrations/meta/_journal.jsonindex fb8f10f9..0c7ec08e 100644--- a/backend/migrations/meta/_journal.json+++ b/backend/migrations/meta/_journal.json@@ -15,6 +15,13 @@"when": 1755785750261,"tag": "0001_square_mauler","breakpoints": true+ },+ {+ "idx": 2,+ "version": "5",+ "when": 1758413556822,+ "tag": "0002_sleepy_korath",+ "breakpoints": true}]}\ No newline at end of filediff --git a/backend/src/applications/sync/dtos/sync-operations.dto.ts b/backend/src/applications/sync/dtos/sync-operations.dto.tsindex 90997b61..2e6cc075 100644--- a/backend/src/applications/sync/dtos/sync-operations.dto.ts+++ b/backend/src/applications/sync/dtos/sync-operations.dto.ts@@ -47,9 +47,8 @@ export class SyncMakeDto extends MakeFileDto {}export class SyncCopyMoveDto {- @IsDefined()- @IsNotEmpty()@IsString()+ @IsNotEmpty()destination: string@IsOptional()diff --git a/backend/src/authentication/auth.controller.ts b/backend/src/authentication/auth.controller.tsindex bd99f843..ec0b0447 100755--- a/backend/src/authentication/auth.controller.ts+++ b/backend/src/authentication/auth.controller.ts@@ -18,7 +18,7 @@ import { AUTH_ROUTE } from './constants/routes'import { AuthTokenSkip } from './decorators/auth-token-skip.decorator'import { LoginResponseDto, LoginVerify2FaDto, TwoFaResponseDto } from './dto/login-response.dto'import { TokenResponseDto } from './dto/token-response.dto'-import { TwoFaVerifyDto } from './dto/two-fa-verify.dto'+import { TwoFaVerifyDto, TwoFaVerifyWithPasswordDto } from './dto/two-fa-verify.dto'import { AuthLocalGuard } from './guards/auth-local.guard'import { AuthTokenRefreshGuard } from './guards/auth-token-refresh.guard'import { AuthTwoFaGuard } from './guards/auth-two-fa-guard'@@ -81,14 +81,14 @@ export class AuthController {@Post(`${AUTH_ROUTE.TWO_FA_BASE}/${AUTH_ROUTE.TWO_FA_ENABLE}`)@UseGuards(UserRolesGuard)@UserHaveRole(USER_ROLE.USER)- twoFaEnable(@Body() body: TwoFaVerifyDto, @Req() req: FastifyAuthenticatedRequest): Promise<TwoFaVerifyResult> {+ twoFaEnable(@Body() body: TwoFaVerifyWithPasswordDto, @Req() req: FastifyAuthenticatedRequest): Promise<TwoFaVerifyResult> {return this.authMethod2FA.enableTwoFactor(body, req)}@Post(`${AUTH_ROUTE.TWO_FA_BASE}/${AUTH_ROUTE.TWO_FA_DISABLE}`)@UseGuards(UserRolesGuard)@UserHaveRole(USER_ROLE.USER)- twoFaDisable(@Body() body: TwoFaVerifyDto, @Req() req: FastifyAuthenticatedRequest): Promise<TwoFaVerifyResult> {+ twoFaDisable(@Body() body: TwoFaVerifyWithPasswordDto, @Req() req: FastifyAuthenticatedRequest): Promise<TwoFaVerifyResult> {return this.authMethod2FA.disableTwoFactor(body, req)}diff --git a/backend/src/authentication/dto/two-fa-verify.dto.ts b/backend/src/authentication/dto/two-fa-verify.dto.tsindex 86e585c3..2e65e45a 100644--- a/backend/src/authentication/dto/two-fa-verify.dto.ts+++ b/backend/src/authentication/dto/two-fa-verify.dto.ts@@ -4,14 +4,20 @@* See the LICENSE file for licensing details*/-import { IsBoolean, IsDefined, IsOptional, IsString } from 'class-validator'+import { IsBoolean, IsNotEmpty, IsOptional, IsString } from 'class-validator'export class TwoFaVerifyDto {- @IsDefined()@IsString()+ @IsNotEmpty()code!: string@IsOptional()@IsBoolean()isRecoveryCode?: boolean}++export class TwoFaVerifyWithPasswordDto extends TwoFaVerifyDto {+ @IsString()+ @IsNotEmpty()+ password!: string+}diff --git a/backend/src/authentication/services/auth-methods/auth-method-two-fa.service.ts b/backend/src/authentication/services/auth-methods/auth-method-two-fa.service.tsindex d81e54d0..f6039010 100644--- a/backend/src/authentication/services/auth-methods/auth-method-two-fa.service.ts+++ b/backend/src/authentication/services/auth-methods/auth-method-two-fa.service.ts@@ -18,7 +18,7 @@ import { qrcodeToDataURL } from '../../../common/qrcode'import { configuration } from '../../../configuration/config.environment'import { Cache } from '../../../infrastructure/cache/services/cache.service'import { TWO_FA_CODE_LENGTH } from '../../constants/auth'-import { TwoFaVerifyDto } from '../../dto/two-fa-verify.dto'+import { TwoFaVerifyDto, TwoFaVerifyWithPasswordDto } from '../../dto/two-fa-verify.dto'import { FastifyAuthenticatedRequest } from '../../interfaces/auth-request.interface'import { TwoFaEnableResult, TwoFaSetup, TwoFaVerifyResult } from '../../interfaces/two-fa-setup.interface'import { decryptSecret, encryptSecret } from '../../utils/crypt-secret'@@ -36,26 +36,28 @@ export class AuthMethod2FA {async initTwoFactor(user: UserModel): Promise<TwoFaSetup> {const { secret, qrDataUrl } = this.generateSecretAndQr(user.email)- // store encrypted secret in cache for 5mn+ // store encrypted secret in cache for 5 minutesawait this.cache.set(this.getCacheKey(user.id), this.encryptSecret(secret), 300)return { secret, qrDataUrl }}- async enableTwoFactor(body: TwoFaVerifyDto, req: FastifyAuthenticatedRequest): Promise<TwoFaEnableResult> {+ async enableTwoFactor(body: TwoFaVerifyWithPasswordDto, req: FastifyAuthenticatedRequest): Promise<TwoFaEnableResult> {// retrieve encrypted secret from cacheconst secret: string = await this.cache.get(this.getCacheKey(req.user.id))if (!secret) {throw new HttpException('The secret has expired', HttpStatus.BAD_REQUEST)}- // verify code with secret- const auth = this.validateTwoFactorCode(body.code, secret)+ // load user+ const [auth, user] = await this.verify(body, req, true, secret)if (!auth.success) {- throw new HttpException(auth.message, HttpStatus.BAD_REQUEST)+ throw new HttpException(auth.message, HttpStatus.FORBIDDEN)}+ // verify user password+ await this.verifyUserPassword(user, body.password, req.ip)// generate recovery codesconst recoveryCodes = this.generateRecoveryCodes()// store and enable TwoFA & recovery codes- await this.usersManager.updateSecrets(req.user.id, {+ await this.usersManager.updateSecrets(user.id, {twoFaSecret: secret,recoveryCodes: recoveryCodes.map((code) => this.encryptSecret(code))})@@ -63,34 +65,33 @@ export class AuthMethod2FA {return { ...auth, recoveryCodes: recoveryCodes }}- async disableTwoFactor(body: TwoFaVerifyDto, req: FastifyAuthenticatedRequest): Promise<TwoFaVerifyResult> {- const auth = await this.verify(body, req)+ async disableTwoFactor(body: TwoFaVerifyWithPasswordDto, req: FastifyAuthenticatedRequest): Promise<TwoFaVerifyResult> {+ // load user+ const [auth, user] = await this.verify(body, req, true)if (!auth.success) {throw new HttpException(auth.message, HttpStatus.FORBIDDEN)}+ // verify user password+ await this.verifyUserPassword(user, body.password, req.ip)// store and disable TwoFA & recovery codes- await this.usersManager.updateSecrets(req.user.id, { twoFaSecret: undefined, recoveryCodes: undefined })+ await this.usersManager.updateSecrets(user.id, { twoFaSecret: undefined, recoveryCodes: undefined })this.sendEmailNotification(req, ACTION.DELETE)return auth}- async verify(body: TwoFaVerifyDto, req: FastifyAuthenticatedRequest, fromLogin?: false): Promise<TwoFaVerifyResult>- async verify(body: TwoFaVerifyDto, req: FastifyAuthenticatedRequest, fromLogin: true): Promise<[TwoFaVerifyResult, UserModel]>+ async verify(verifyDto: TwoFaVerifyDto, req: FastifyAuthenticatedRequest, fromLogin?: false, secret?: string): Promise<TwoFaVerifyResult>+ async verify(verifyDto: TwoFaVerifyDto, req: FastifyAuthenticatedRequest, fromLogin: true, secret?: string): Promise<[TwoFaVerifyResult, UserModel]>async verify(verifyDto: TwoFaVerifyDto,req: FastifyAuthenticatedRequest,- fromLogin = false+ fromLogin = false,+ secret?: string): Promise<TwoFaVerifyResult | [TwoFaVerifyResult, UserModel]> {- const code = verifyDto.code- const user = await this.usersManager.fromUserId(req.user.id)- if (!user) {- this.logger.warn(`User *${user.login}* (${user.id}) not found`)- throw new HttpException(`User not found`, HttpStatus.NOT_FOUND)- }- this.usersManager.validateUserAccess(user, req.ip)+ const user = await this.loadUser(req.user.id, req.ip)+ secret = secret || user.secrets.twoFaSecretconst auth = verifyDto.isRecoveryCode- ? await this.validateRecoveryCode(req.user.id, code, user.secrets.recoveryCodes)- : this.validateTwoFactorCode(code, user.secrets.twoFaSecret)+ ? await this.validateRecoveryCode(req.user.id, verifyDto.code, user.secrets.recoveryCodes)+ : this.validateTwoFactorCode(verifyDto.code, secret)this.usersManager.updateAccesses(user, req.ip, auth.success, true).catch((e: Error) => this.logger.error(`${this.verify.name} - ${e}`))return fromLogin ? [auth, user] : auth}@@ -107,11 +108,32 @@ export class AuthMethod2FA {return auth}+ private async loadUser(userId: number, ip: string) {+ const user: UserModel = await this.usersManager.fromUserId(userId)+ if (!user) {+ this.logger.warn(`User *${user.login}* (${user.id}) not found`)+ throw new HttpException(`User not found`, HttpStatus.NOT_FOUND)+ }+ this.usersManager.validateUserAccess(user, ip)+ return user+ }++ private async verifyUserPassword(user: UserModel, password: string, ip: string) {+ if (!(await this.usersManager.compareUserPassword(user.id, password))) {+ this.usersManager.updateAccesses(user, ip, false, true).catch((e: Error) => this.logger.error(`${this.enableTwoFactor.name} - ${e}`))+ throw new HttpException('Incorrect code or password', HttpStatus.BAD_REQUEST)+ }+ }+private validateTwoFactorCode(code: string, encryptedSecret: string): TwoFaVerifyResult {const auth: TwoFaVerifyResult = { success: false, message: '' }+ if (!encryptedSecret) {+ auth.message = 'Incorrect code or password'+ return auth+ }try {auth.success = Totp.validate({ passcode: code, secret: this.decryptSecret(encryptedSecret), drift: 1 })- if (!auth.success) auth.message = 'Invalid code'+ if (!auth.success) auth.message = 'Incorrect code or password'} catch (e) {this.logger.error(`${this.validateTwoFactorCode.name} - ${e}`)auth.message = e.messagediff --git a/backend/src/configuration/config.validation.ts b/backend/src/configuration/config.validation.tsindex 628cb7cb..edaa86cc 100644--- a/backend/src/configuration/config.validation.ts+++ b/backend/src/configuration/config.validation.ts@@ -5,7 +5,20 @@*/import { Transform, Type } from 'class-transformer'-import { IsBoolean, IsDefined, IsInt, IsIP, IsNotEmptyObject, IsObject, IsOptional, IsString, Max, Min, ValidateNested } from 'class-validator'+import {+ IsBoolean,+ IsDefined,+ IsInt,+ IsIP,+ IsNotEmpty,+ IsNotEmptyObject,+ IsObject,+ IsOptional,+ IsString,+ Max,+ Min,+ ValidateNested+} from 'class-validator'import { cpus } from 'node:os'import type { Level } from 'pino'import { ApplicationsConfig } from '../applications/applications.config'@@ -38,8 +51,8 @@ export class ServerConfig {}export class LoggerConfig {- @IsDefined()@IsString()+ @IsNotEmpty()level: Level = 'info'@IsBoolean()diff --git a/backend/src/infrastructure/database/database.config.ts b/backend/src/infrastructure/database/database.config.tsindex 7b4fc647..81d61b83 100644--- a/backend/src/infrastructure/database/database.config.ts+++ b/backend/src/infrastructure/database/database.config.ts@@ -5,11 +5,10 @@*/import { Transform } from 'class-transformer'-import { IsBoolean, IsDefined, IsNotEmpty, IsString } from 'class-validator'+import { IsBoolean, IsNotEmpty, IsString } from 'class-validator'import { DB_CHARSET } from './constants'export class MySQLConfig {- @IsDefined()@IsString()@IsNotEmpty()@Transform(({ value }) => (value.endsWith(`?charset=${DB_CHARSET}`) ? value : `${value}?charset=${DB_CHARSET}`))diff --git a/environment/environment.dist.min.yaml b/environment/environment.dist.min.yamlindex f7a6d562..d106553f 100644--- a/environment/environment.dist.min.yaml+++ b/environment/environment.dist.min.yaml@@ -1,6 +1,7 @@mysql:url: mysql://user:MySQLRootPassword@localhost:3306/databaseauth:+ encryptionKey: changeEncryptionKeyWithStrongKeytoken:access:secret: changeAccessWithStrongSecretdiff --git a/environment/environment.dist.yaml b/environment/environment.dist.yamlindex 6200f0e7..b5bbde92 100755--- a/environment/environment.dist.yaml+++ b/environment/environment.dist.yaml@@ -73,6 +73,7 @@ auth:method: mysql# key used to encrypt user secret keys in the database# optional, but strongly recommended+ # warning: do not change the encryption key after MFA activation, or the codes will become invalidencryptionKey: changeEncryptionKeyWithStrongKey# multifactor authenticationmfa:diff --git a/frontend/src/app/applications/admin/components/dialogs/admin-impersonate-user-dialog.component.ts b/frontend/src/app/applications/admin/components/dialogs/admin-impersonate-user-dialog.component.tsindex 274df0a5..934cb88f 100644--- a/frontend/src/app/applications/admin/components/dialogs/admin-impersonate-user-dialog.component.ts+++ b/frontend/src/app/applications/admin/components/dialogs/admin-impersonate-user-dialog.component.ts@@ -44,7 +44,7 @@ export class AdminImpersonateUserDialogComponent {this.layout.closeDialog()return}- const totpCode = typeof auth2Fa === 'string' ? auth2Fa : undefined+ const totpCode = auth2Fa === true ? undefined : auth2Fa.totpCodethis.adminService.impersonateUser(this.user.id, { password: this.impersonateUserForm.value.password }, totpCode).subscribe({next: (r: LoginResponseDto) => {this.layout.closeDialog()diff --git a/frontend/src/app/applications/admin/components/dialogs/admin-reset-user-two-fa-dialog.component.ts b/frontend/src/app/applications/admin/components/dialogs/admin-reset-user-two-fa-dialog.component.tsindex 7117517f..cf59beb9 100644--- a/frontend/src/app/applications/admin/components/dialogs/admin-reset-user-two-fa-dialog.component.ts+++ b/frontend/src/app/applications/admin/components/dialogs/admin-reset-user-two-fa-dialog.component.ts@@ -43,7 +43,7 @@ export class AdminResetUserTwoFaDialogComponent {this.layout.closeDialog()return}- const totpCode = typeof auth2Fa === 'string' ? auth2Fa : undefined+ const totpCode = auth2Fa === true ? undefined : auth2Fa.totpCodethis.userService.adminResetUser2Fa(this.user.id, { password: this.adminForm.value.password }, totpCode).subscribe({next: (verify: TwoFaVerifyResult) => {this.wasReset.emit(verify.success)diff --git a/frontend/src/app/applications/admin/components/dialogs/admin-user-delete-dialog.component.ts b/frontend/src/app/applications/admin/components/dialogs/admin-user-delete-dialog.component.tsindex 065b1322..f21f7224 100644--- a/frontend/src/app/applications/admin/components/dialogs/admin-user-delete-dialog.component.ts+++ b/frontend/src/app/applications/admin/components/dialogs/admin-user-delete-dialog.component.ts@@ -49,7 +49,7 @@ export class AdminUserDeleteDialogComponent {this.onClose()return}- const totpCode = typeof auth2Fa === 'string' ? auth2Fa : undefined+ const totpCode = auth2Fa === true ? undefined : auth2Fa.totpCodethis.adminService.deleteUser(this.user.id,diff --git a/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-enable-dialog.component.html b/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-enable-dialog.component.htmlindex 3d68d518..4bb72ee2 100644--- a/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-enable-dialog.component.html+++ b/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-enable-dialog.component.html@@ -47,11 +47,20 @@</div></div><hr>- <div class="text-align-center mb-3" l10nTranslate>Confirm activation with your TOTP code</div><form (ngSubmit)="onSubmit()" [formGroup]="twoFaForm">+ <div class="text-align-center mb-3" l10nTranslate>Enter your password</div>+ <div class="mb-3">+ <app-input-password id="password"+ [password]="twoFaForm.value.password"+ (passwordChange)="twoFaForm.controls.password.setValue($event)"+ [focus]="true"+ [centered]="true"+ placeholder="••••••">+ </app-input-password>+ </div>+ <div class="text-align-center mb-3" l10nTranslate>Valid with your TOTP code</div><div class="mb-3"><input- appAutofocustype="text"[maxlength]=twoFaCodelengthclass="form-control text-center fs-4"diff --git a/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-enable-dialog.component.ts b/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-enable-dialog.component.tsindex a021279e..703f3109 100644--- a/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-enable-dialog.component.ts+++ b/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-enable-dialog.component.ts@@ -12,14 +12,14 @@ import { TWO_FA_CODE_LENGTH } from '@sync-in-server/backend/src/authentication/cimport { TwoFaEnableResult } from '@sync-in-server/backend/src/authentication/interfaces/two-fa-setup.interface'import { L10N_LOCALE, L10nLocale, L10nTranslateDirective } from 'angular-l10n'import { ClipboardService } from 'ngx-clipboard'-import { AutofocusDirective } from '../../../../common/directives/auto-focus.directive'+import { InputPasswordComponent } from '../../../../common/components/input-password.component'import { downloadWithAnchor } from '../../../../common/utils/functions'import { LayoutService } from '../../../../layout/layout.service'import { UserService } from '../../user.service'@Component({selector: 'app-user-auth-2fa-enable-dialog',- imports: [FaIconComponent, L10nTranslateDirective, AutofocusDirective, ReactiveFormsModule],+ imports: [FaIconComponent, L10nTranslateDirective, ReactiveFormsModule, InputPasswordComponent],templateUrl: 'user-auth-2fa-enable-dialog.component.html'})export class UserAuth2faEnableDialogComponent {@@ -38,7 +38,8 @@ export class UserAuth2faEnableDialogComponent {private readonly clipBoardService = inject(ClipboardService)private readonly fb = inject(UntypedFormBuilder)protected twoFaForm: FormGroup = this.fb.group({- totpCode: this.fb.control('', [Validators.required, Validators.pattern(new RegExp(`^\\d{${TWO_FA_CODE_LENGTH}}$`))])+ totpCode: this.fb.control('', [Validators.required, Validators.pattern(new RegExp(`^\\d{${TWO_FA_CODE_LENGTH}}$`))]),+ password: this.fb.control('')})onClose(state = false) {@@ -48,7 +49,7 @@ export class UserAuth2faEnableDialogComponent {onSubmit() {this.submitted = true- this.userService.enable2Fa({ code: this.twoFaForm.value.totpCode }).subscribe({+ this.userService.enable2Fa({ code: this.twoFaForm.value.totpCode, password: this.twoFaForm.value.password }).subscribe({next: (res: TwoFaEnableResult) => {if (res.success) {this.wasEnabled = truediff --git a/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-verify-dialog.component.html b/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-verify-dialog.component.htmlindex 3cd2a893..c3662424 100644--- a/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-verify-dialog.component.html+++ b/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-verify-dialog.component.html@@ -6,7 +6,7 @@<div class="modal-header align-items-center justify-content-center"><h4 class="modal-title"><fa-icon [icon]="icons.faLock" class="me-2"></fa-icon>- <span l10nTranslate>TOTP Verification</span>+ <span l10nTranslate>Two-Factor Authentication</span></h4></div><div class="modal-body modal-auth-verify-2fa">@@ -16,10 +16,26 @@<p class="text-danger d-flex justify-content-center align-items-center mb-3" style="height: 36px" l10nTranslate>{{ hasError }}</p>} @else {<p class="text-muted d-flex justify-content-center align-items-center mb-3" style="height: 36px" l10nTranslate>- Enter the 6-digit code generated by your authenticator app.+ @if (withPassword) {+ Enter your password+ } @else {+ Valid with your TOTP code+ }</p>}<form (ngSubmit)="onSubmit()" [formGroup]="twoFaForm">+ @if (withPassword) {+ <div class="mb-4">+ <app-input-password id="password"+ [password]="twoFaForm.value.password"+ (passwordChange)="twoFaForm.controls.password.setValue($event)"+ [focus]="true"+ [centered]="true"+ placeholder="••••••">+ </app-input-password>+ </div>+ <div class="text-muted text-align-center mb-3" l10nTranslate>Valid with your TOTP code</div>+ }<div class="mb-3"><inputappAutofocusdiff --git a/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-verify-dialog.component.ts b/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-verify-dialog.component.tsindex 5f84b932..e8df6632 100644--- a/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-verify-dialog.component.ts+++ b/frontend/src/app/applications/users/components/dialogs/user-auth-2fa-verify-dialog.component.ts@@ -4,24 +4,27 @@* See the LICENSE file for licensing details*/-import { Component, inject } from '@angular/core'+import { Component, inject, Input } from '@angular/core'import { FormGroup, ReactiveFormsModule, UntypedFormBuilder, Validators } from '@angular/forms'import { FaIconComponent } from '@fortawesome/angular-fontawesome'import { faKey, faLock } from '@fortawesome/free-solid-svg-icons'import { TWO_FA_CODE_LENGTH } from '@sync-in-server/backend/src/authentication/constants/auth'import { TwoFaVerifyResult } from '@sync-in-server/backend/src/authentication/interfaces/two-fa-setup.interface'import { L10N_LOCALE, L10nLocale, L10nTranslateDirective } from 'angular-l10n'+import { InputPasswordComponent } from '../../../../common/components/input-password.component'import { AutofocusDirective } from '../../../../common/directives/auto-focus.directive'import { LayoutService } from '../../../../layout/layout.service'+import { UserTwoFaVerify } from '../../interfaces/user.interface'import { UserService } from '../../user.service'@Component({selector: 'app-user-auth-2fa-verify-dialog',- imports: [FaIconComponent, L10nTranslateDirective, AutofocusDirective, ReactiveFormsModule],+ imports: [FaIconComponent, L10nTranslateDirective, AutofocusDirective, ReactiveFormsModule, InputPasswordComponent],templateUrl: 'user-auth-2fa-verify-dialog.component.html'})export class UserAuth2FaVerifyDialogComponent {- isValid!: (result: false | string) => void // injected callback+ @Input() withPassword = false+ isValid!: (result: false | UserTwoFaVerify) => void // injected callbackprotected submitted = falseprotected hasError: any = nullprotected readonly icons = { faKey, faLock }@@ -30,11 +33,12 @@ export class UserAuth2FaVerifyDialogComponent {private readonly userService = inject(UserService)private readonly fb = inject(UntypedFormBuilder)protected twoFaForm: FormGroup = this.fb.group({- totpCode: this.fb.control('', [Validators.required, Validators.pattern(new RegExp(`^\\d{${TWO_FA_CODE_LENGTH}}$`))])+ totpCode: this.fb.control('', [Validators.required, Validators.pattern(new RegExp(`^\\d{${TWO_FA_CODE_LENGTH}}$`))]),+ password: this.fb.control('')})private readonly layout = inject(LayoutService)- onClose(state: false | string = false) {+ onClose(state: false | UserTwoFaVerify = false) {this.isValid(state)this.layout.closeDialog()}@@ -44,9 +48,9 @@ export class UserAuth2FaVerifyDialogComponent {this.userService.verify2Fa({ code: this.twoFaForm.value.totpCode }).subscribe({next: (res: TwoFaVerifyResult) => {if (res.success) {- this.onClose(this.twoFaForm.value.totpCode)+ this.onClose({ totpCode: this.twoFaForm.value.totpCode, password: this.twoFaForm.value.password })} else {- this.hasError = 'Invalid code'+ this.hasError = 'Incorrect code or password'}setTimeout(() => (this.submitted = false), 1000)},diff --git a/frontend/src/app/applications/users/components/dialogs/user-auth-manage-app-passwords-dialog.component.html b/frontend/src/app/applications/users/components/dialogs/user-auth-manage-app-passwords-dialog.component.htmlindex 0d94e0d8..6873ed55 100644--- a/frontend/src/app/applications/users/components/dialogs/user-auth-manage-app-passwords-dialog.component.html+++ b/frontend/src/app/applications/users/components/dialogs/user-auth-manage-app-passwords-dialog.component.html@@ -98,7 +98,7 @@}}@if (appPasswords.length) {- <table class="table table-striped table-hover align-middle text-center">+ <table class="table table-striped table-hover align-middle text-center no-select"><thead><tr><th scope="col" l10nTranslate>Name</th>diff --git a/frontend/src/app/applications/users/components/user-account.component.ts b/frontend/src/app/applications/users/components/user-account.component.tsindex 42351236..99e5a648 100644--- a/frontend/src/app/applications/users/components/user-account.component.ts+++ b/frontend/src/app/applications/users/components/user-account.component.ts@@ -32,7 +32,7 @@ import { TimeAgoPipe } from '../../../common/pipes/time-ago.pipe'import { TimeDateFormatPipe } from '../../../common/pipes/time-date-format.pipe'import { LayoutService } from '../../../layout/layout.service'import { StoreService } from '../../../store/store.service'-import { UserType } from '../interfaces/user.interface'+import { UserTwoFaVerify, UserType } from '../interfaces/user.interface'import { USER_ICON, USER_LANGUAGE_AUTO, USER_PATH, USER_TITLE } from '../user.constants'import { UserService } from '../user.service'import { UserAuth2faEnableDialogComponent } from './dialogs/user-auth-2fa-enable-dialog.component'@@ -134,7 +134,7 @@ export class UserAccountComponent implements OnDestroy {this.newPassword = ''return}- const totpCode = typeof auth2Fa === 'string' ? auth2Fa : undefined+ const totpCode = auth2Fa === true ? undefined : auth2Fa.totpCodethis.userService.changePassword({ oldPassword: this.oldPassword, newPassword: this.newPassword }, totpCode).subscribe({next: () => {this.oldPassword = ''@@ -186,23 +186,23 @@ export class UserAccountComponent implements OnDestroy {this.store.user.next({ ...this.store.user.getValue(), twoFaEnabled: true })})},- error: (e: HttpErrorResponse) => this.layout.sendNotification('error', 'Configuration', 'Two-Factor Authentication has failed', e)+ error: (e: HttpErrorResponse) => this.layout.sendNotification('error', 'Configuration', 'Two-Factor Authentication', e)})}async disable2Fa() {- const auth2Fa = await this.userService.auth2FaVerifyDialog()- if (auth2Fa === false) {+ const auth2Fa: boolean | UserTwoFaVerify = await this.userService.auth2FaVerifyDialog(true)+ if (typeof auth2Fa === 'boolean') {+ // two-fa must be enabled to be disabledreturn}- const totpCode = typeof auth2Fa === 'string' ? auth2Fa : undefined- this.userService.disable2Fa({ code: totpCode }).subscribe({+ this.userService.disable2Fa({ code: auth2Fa.totpCode, password: auth2Fa.password }).subscribe({next: () => {this.layout.sendNotification('success', 'Configuration', 'Two-Factor Authentication is disabled')this.store.user.next({ ...this.store.user.getValue(), twoFaEnabled: false })},error: (e: HttpErrorResponse) => {- this.layout.sendNotification('error', 'Configuration', 'Two-Factor Authentication has failed', e)+ this.layout.sendNotification('error', 'Configuration', 'Two-Factor Authentication', e)}})}diff --git a/frontend/src/app/applications/users/interfaces/user.interface.ts b/frontend/src/app/applications/users/interfaces/user.interface.tsindex c6baf366..01ca6b12 100644--- a/frontend/src/app/applications/users/interfaces/user.interface.ts+++ b/frontend/src/app/applications/users/interfaces/user.interface.ts@@ -9,3 +9,8 @@ import type { UserModel } from '@sync-in-server/backend/src/applications/users/mexport type UserType = Omit<UserModel, 'permissions' | 'password'>export type UserStatus = keyof Pick<UserType, 'isAdmin' | 'isUser' | 'isGuest' | 'isLink' | 'clientId'>++export interface UserTwoFaVerify {+ totpCode: string+ password: string+}diff --git a/frontend/src/app/applications/users/user.service.ts b/frontend/src/app/applications/users/user.service.tsindex 542db434..357a5fc7 100644--- a/frontend/src/app/applications/users/user.service.ts+++ b/frontend/src/app/applications/users/user.service.ts@@ -55,7 +55,7 @@ import {API_TWO_FA_ENABLE,API_TWO_FA_VERIFY} from '@sync-in-server/backend/src/authentication/constants/routes'-import type { TwoFaVerifyDto } from '@sync-in-server/backend/src/authentication/dto/two-fa-verify.dto'+import type { TwoFaVerifyDto, TwoFaVerifyWithPasswordDto } from '@sync-in-server/backend/src/authentication/dto/two-fa-verify.dto'import type { TwoFaEnableResult, TwoFaSetup, TwoFaVerifyResult } from '@sync-in-server/backend/src/authentication/interfaces/two-fa-setup.interface'import { BsModalRef } from 'ngx-bootstrap/modal'import { Socket } from 'ngx-socket-io'@@ -66,7 +66,7 @@ import { StoreService } from '../../store/store.service'import { NotificationsService } from '../notifications/notifications.service'import { SPACES_TITLE } from '../spaces/spaces.constants'import { UserAuth2FaVerifyDialogComponent } from './components/dialogs/user-auth-2fa-verify-dialog.component'-import { UserType } from './interfaces/user.interface'+import { UserTwoFaVerify, UserType } from './interfaces/user.interface'import { GroupBrowseModel } from './models/group-browse.model'import { GuestUserModel } from './models/guest.model'import { MemberModel } from './models/member.model'@@ -304,11 +304,11 @@ export class UserService {return this.http.get<TwoFaSetup>(API_TWO_FA_ENABLE)}- enable2Fa(twoFaVerifyDto: TwoFaVerifyDto): Observable<TwoFaEnableResult> {- return this.http.post<TwoFaEnableResult>(API_TWO_FA_ENABLE, twoFaVerifyDto)+ enable2Fa(twoFaVerifyWithPasswordDto: TwoFaVerifyWithPasswordDto): Observable<TwoFaEnableResult> {+ return this.http.post<TwoFaEnableResult>(API_TWO_FA_ENABLE, twoFaVerifyWithPasswordDto)}- disable2Fa(twoFaVerifyDto: TwoFaVerifyDto): Observable<TwoFaVerifyResult> {+ disable2Fa(twoFaVerifyDto: TwoFaVerifyWithPasswordDto): Observable<TwoFaVerifyResult> {return this.http.post<TwoFaVerifyResult>(API_TWO_FA_DISABLE, twoFaVerifyDto)}@@ -322,17 +322,17 @@ export class UserService {})}- async auth2FaVerifyDialog(): Promise<boolean | string> {- // returns: true (no check), false (check failed), string (totpCode)+ async auth2FaVerifyDialog(withPassword = false): Promise<boolean | UserTwoFaVerify> {+ // returns: true (no check), false (check failed), `UserTwoFaVerify` (totpCode & password?)if (this.store.server().twoFaEnabled && this.user.twoFaEnabled) {return new Promise((resolve) => {const modalRef: BsModalRef<UserAuth2FaVerifyDialogComponent> = this.layout.openDialog(UserAuth2FaVerifyDialogComponent,'xs',- {},+ { initialState: { withPassword: withPassword } },{ keyboard: false })- modalRef.content.isValid = (result: false | string) => {+ modalRef.content.isValid = (result: false | UserTwoFaVerify) => {resolve(result)}})diff --git a/frontend/src/app/auth/auth.component.html b/frontend/src/app/auth/auth.component.htmlindex 4eb59b8c..d51b86b6 100644--- a/frontend/src/app/auth/auth.component.html+++ b/frontend/src/app/auth/auth.component.html@@ -21,7 +21,7 @@</span><input appAutofocus[placeholder]="'Recovery code' | translate:locale.language"- type="text"+ type="password"class="form-control"formControlName="recoveryCode" />} @else {diff --git a/frontend/src/app/common/components/input-password.component.ts b/frontend/src/app/common/components/input-password.component.tsindex a099d91e..1aab58f0 100644--- a/frontend/src/app/common/components/input-password.component.ts+++ b/frontend/src/app/common/components/input-password.component.ts@@ -28,7 +28,9 @@ import { togglePasswordType } from '../utils/functions'[class.is-invalid]="isRequired && password?.length < passwordMinLength"(keyup)="passwordChange.emit(password)"type="password"- class="form-control form-control-sm"+ class="form-control form-control-sm pe-0"+ [class.text-center]="centered"+ [style.padding-left]="centered ? '2rem' : ''"[placeholder]="placeholder | translate: locale.language"[required]="isRequired"/>@@ -57,6 +59,7 @@ export class InputPasswordComponent implements OnInit {@Input() disabled = false@Input() isRequired = false@Input() focus = false+ @Input() centered = falseprotected readonly locale = inject<L10nLocale>(L10N_LOCALE)protected readonly toggleVisiblePassword = togglePasswordTypeprotected readonly icons = { faEye, faEyeSlash, faDice }diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.jsonindex 9d00a9fd..5fb71e76 100644--- a/frontend/src/i18n/fr.json+++ b/frontend/src/i18n/fr.json@@ -485,6 +485,7 @@"The maximum number of access allowed to the link is exceeded": "Le nombre maximum d'accès autorisé au lien est dépassé","Set a password": "Définir un mot de passe","Enter your password to confirm": "Entrez votre mot de passe pour confirmer",+ "Enter your password": "Entrez votre mot de passe","Permissions": "Permissions","No permissions": "Pas de permissions","Owner": "Propriétaire",@@ -683,6 +684,7 @@"Secret copied": "Secret copié","Recovery codes copied": "Codes de récupération copiés","Invalid code": "Code invalide",+ "Incorrect code or password": "Code ou mot de passe incorrect","Application Passwords": "Mots de passe d'application","Generate a new app password": "Générer un nouveau mot de passe d’application","Generated password": "Mot de passe généré",@@ -693,14 +695,13 @@"Two-Factor Authentication": "Authentification à deux facteurs","Two-Factor Authentication is enabled": "L’authentification à deux facteurs est activée","Two-Factor Authentication is disabled": "L’authentification à deux facteurs est désactivée",- "Two-Factor Authentication has failed": "L’authentification à deux facteurs a échoué","Reset Two-Factor Authentication": "Réinitialiser l’authentification à deux facteurs",- "Enter the 6-digit code generated by your authenticator app.": "Entrez le code à 6 chiffres généré par votre application d’authentification.",- "Scan this QR code using your authenticator app.": " Scannez ce code QR avec votre application d’authentification.",+ "Scan this QR code using your authenticator app.": "Scannez ce code QR avec votre application d’authentification.","(Such as FreeOTP, Proton Authenticator etc.)": "(Par ex. FreeOTP, Proton Authenticator, etc.)","Or enter this secret manually": "Ou entrez ce secret manuellement",- "Confirm activation with your TOTP code": "Validez l’activation avec votre code TOTP",+ "Valid with your TOTP code": "Validez avec votre code TOTP","The secret has expired": "Le secret a expiré",+ "The secret is missing": "Le secret est absent","Keep these codes in a safe place. They will allow you to access your account if you lose access to your two-factor authentication.": "Conservez ces codes en lieu sûr. Ils vous permettront d’accéder à votre compte si vous perdez l’accès à votre authentification à deux facteurs.","These recovery codes are for one-time use only and will only be displayed here once.": "Ces codes de récupération sont à usage unique et ne seront affichés qu’une seule fois ici."}diff --git a/frontend/src/styles/components/_modal.scss b/frontend/src/styles/components/_modal.scssindex 0d5fb658..e0cafe77 100644--- a/frontend/src/styles/components/_modal.scss+++ b/frontend/src/styles/components/_modal.scss@@ -14,6 +14,7 @@.modal-header {line-height: 1;+ @extend .no-select;.modal-title {@extend .text-truncate;