diff --git a/idp/src/user/repo.ts b/idp/src/user/repo.ts index 47d250eb4..fa7bc8470 100644 --- a/idp/src/user/repo.ts +++ b/idp/src/user/repo.ts @@ -243,7 +243,6 @@ class UserRepoImpl { async enoughActiveAdmins() { const { rows } = await client.query( 'SELECT COUNT(*) as count FROM "user" WHERE is_admin IS TRUE AND is_active IS TRUE', - [], ) return rows[0].count > 1 } diff --git a/idp/src/user/service.ts b/idp/src/user/service.ts index 2a0d969d8..c66d8af8d 100644 --- a/idp/src/user/service.ts +++ b/idp/src/user/service.ts @@ -379,7 +379,7 @@ export async function makeAdminUser(id: string, options: UserMakeAdminOptions) { if ( user.isAdmin && !(await userRepo.enoughActiveAdmins()) && - options.makeAdmin + !options.makeAdmin ) { throw newCannotDemoteSoleAdminError() } diff --git a/migrations/Cargo.lock b/migrations/Cargo.lock index 75481f1d4..5ca886e63 100644 --- a/migrations/Cargo.lock +++ b/migrations/Cargo.lock @@ -2087,7 +2087,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "voltaserve-migrations" -version = "0.0.0" +version = "3.0.0" dependencies = [ "async-std", "sea-orm-migration", diff --git a/migrations/Cargo.toml b/migrations/Cargo.toml index 8a451dd15..3fbd9124d 100644 --- a/migrations/Cargo.toml +++ b/migrations/Cargo.toml @@ -10,6 +10,7 @@ [package] name = "voltaserve-migrations" edition = "2021" +version = "3.0.0" publish = false [lib] diff --git a/migrations/src/lib.rs b/migrations/src/lib.rs index 9b4d05ad9..223038ca2 100644 --- a/migrations/src/lib.rs +++ b/migrations/src/lib.rs @@ -28,6 +28,7 @@ mod m20240807_000001_add_segmentation_column; mod m20240905_000001_add_user_active_admin_fields; mod m20240907_000001_add_user_force_change_password_field; mod m20240913_000001_drop_segmentation_column; +mod m20241114_000001_drop_user_force_change_password_column; #[async_trait::async_trait] impl MigratorTrait for Migrator { @@ -48,6 +49,7 @@ impl MigratorTrait for Migrator { Box::new(m20240905_000001_add_user_active_admin_fields::Migration), Box::new(m20240907_000001_add_user_force_change_password_field::Migration), Box::new(m20240913_000001_drop_segmentation_column::Migration), + Box::new(m20241114_000001_drop_user_force_change_password_column::Migration), ] } } diff --git a/migrations/src/m20241114_000001_drop_user_force_change_password_column.rs b/migrations/src/m20241114_000001_drop_user_force_change_password_column.rs new file mode 100644 index 000000000..75f8147f3 --- /dev/null +++ b/migrations/src/m20241114_000001_drop_user_force_change_password_column.rs @@ -0,0 +1,55 @@ +// Copyright 2023 Anass Bouassaba. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the GNU Affero General Public License v3.0 only, included in the file +// licenses/AGPL.txt. +use sea_orm_migration::prelude::*; + +use crate::models::v1::{User}; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up( + &self, + manager: &SchemaManager, + ) -> Result<(), DbErr> { + manager + .alter_table( + Table::alter() + .table(User::Table) + .drop_column(User::ForceChangePassword) + .to_owned(), + ) + .await?; + + Ok(()) + } + + async fn down( + &self, + manager: &SchemaManager, + ) -> Result<(), DbErr> { + manager + .alter_table( + Table::alter() + .table(User::Table) + .add_column( + ColumnDef::new(User::ForceChangePassword) + .boolean() + .not_null() + .default(false), + ) + .to_owned(), + ) + .await?; + + Ok(()) + } +} diff --git a/ui/src/pages/console/console-panel-user.tsx b/ui/src/pages/console/console-panel-user.tsx index 3c4a178b9..373b69e1f 100644 --- a/ui/src/pages/console/console-panel-user.tsx +++ b/ui/src/pages/console/console-panel-user.tsx @@ -16,22 +16,14 @@ import { Grid, GridItem, Heading, - IconButton, - IconButtonProps, Spacer, Table, Text, Th, Thead, - Tooltip, Tr, } from '@chakra-ui/react' import { - Form, - IconClose, - IconEdit, - IconSync, - IconWarning, PagePagination, RelativeDate, SectionError, @@ -44,16 +36,6 @@ import ConsoleAPI from '@/client/console/console' import UserAPI from '@/client/idp/user' import { swrConfig } from '@/client/options' import { getPictureUrlById } from '@/lib/helpers/picture' -import { truncateEnd } from '@/lib/helpers/truncate-end' -import truncateMiddle from '@/lib/helpers/truncate-middle' - -const EditButton = (props: IconButtonProps) => ( - } - className={cx('h-[40px]', 'w-[40px]')} - {...props} - /> -) const ConsolePanelUser = () => { const { id } = useParams() @@ -150,110 +132,9 @@ const ConsolePanelUser = () => { 'dark:border-gray-700', )} /> - {user.picture ? ( - } - variant="solid" - colorScheme="red" - right="5px" - bottom="10px" - position="absolute" - zIndex={1000} - title="Delete picture" - aria-label="Delete picture" - isDisabled={true} - /> - ) : null} - -
- {truncateEnd(user.fullName, 50)} - - - ), - }, - ], - }, - { - title: 'Credentials', - rows: [ - { - label: 'Email', - content: ( - <> - {user.pendingEmail ? ( -
- -
- -
-
- - {truncateMiddle(user.pendingEmail, 50)} - -
- ) : null} - {!user.pendingEmail ? ( - - {truncateMiddle( - user.pendingEmail || user.email, - 50, - )} - - ) : null} - - - ), - }, - { - label: 'Force change password', - content: ( - } - isDisabled={true} - /> - ), - }, - ], - }, - ]} - /> - + {isOrgListLoading ? (