/* * SonarQube * Copyright (C) 2009-2024 SonarSource SA * mailto:info AT sonarsource DOT com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { ButtonPrimary, Card, CenteredLayout, DarkLabel, FlagMessage, FormField, InputField, Link, PageContentFontWrapper, Spinner, SubTitle, Title, } from 'design-system'; import * as React from 'react'; import { Helmet } from 'react-helmet-async'; import { Location } from '../../components/hoc/withRouter'; import { translate } from '../../helpers/l10n'; import { getReturnUrl } from '../../helpers/urls'; import Unauthorized from '../sessions/components/Unauthorized'; import { DEFAULT_ADMIN_PASSWORD } from './constants'; export interface ChangeAdminPasswordAppRendererProps { passwordValue: string; confirmPasswordValue: string; onConfirmPasswordChange: (password: string) => void; onPasswordChange: (password: string) => void; onSubmit: () => void; canAdmin?: boolean; canSubmit?: boolean; submitting: boolean; success: boolean; location: Location; } const PASSWORD_FIELD_ID = 'user-password'; const CONFIRM_PASSWORD_FIELD_ID = 'confirm-user-password'; export default function ChangeAdminPasswordAppRenderer(props: ChangeAdminPasswordAppRendererProps) { const { canAdmin, canSubmit, confirmPasswordValue, passwordValue, location, submitting, success, } = props; if (!canAdmin) { return ; } return ( {success ? (

{translate('users.change_admin_password.form.success')}

{/* We must reload because we need a refresh of the /api/navigation/global call. */} {translate('users.change_admin_password.form.continue_to_app')}
) : ( <> {translate('users.change_admin_password.instance_is_at_risk')} {translate('users.change_admin_password.header')}

{translate('users.change_admin_password.description')}

) => { e.preventDefault(); props.onSubmit(); }} > {translate('users.change_admin_password.form.header')} ) => { props.onPasswordChange(e.currentTarget.value); }} required type="password" value={passwordValue} /> {translate('users.change_admin_password.form.cannot_use_default_password')} ) } > ) => { props.onConfirmPasswordChange(e.currentTarget.value); }} required type="password" value={confirmPasswordValue} /> {translate('update_verb')}
)}
); }