Skip to content
Snippets Groups Projects
Select Git revision
  • 3bccb951334d540c084f02abb8463b3b5e4d394e
  • community default
  • renovate/glob-10.x
  • master protected
  • renovate/mini-css-extract-plugin-2.x
  • renovate/css-loader-7.x
  • renovate/css-loader-6.x
  • renovate/purgecss-webpack-plugin-6.x
  • renovate/bootstrap-5.x
  • renovate/docker.io-library-golang-1.x
  • renovate/corejs-typeahead-1.x
  • revision2023
  • bookworm
  • not_privacy_only
  • renovate/golang-1.x
  • renovate/glob-9.x
  • renovate/glob-8.x
  • how-to-archive-emails
  • renovate/glob-7.x
  • webpack-process
  • renovate/popperjs-core-2.x
  • latest-node-from-scratch
22 results

passwd.en.md

Blame
  • OwnPassword.js 1.51 KiB
    import React, { useState } from "react";
    import { Form, Col, Row, Button, Alert } from "react-bootstrap";
    import PasswordForm from "./PasswordForm";
    import Sender from "./Sender";
    
    function OwnPassword() {
      const [old_password, setOldPassword] = useState("");
      const [password, setPassword] = useState("");
      const [isFormValid, setIsFormValid] = useState(false);
      const [passwordChanged, setPasswordChanged] = useState(false);
    
      return (
        <Sender
          url="/api/member/me"
          method="PUT"
          body={{ old_password, password }}
          onSuccess={() => setPasswordChanged(true)}
        >
          <h2>Cambio de contraseña</h2>
    
          {passwordChanged && (
            <Alert variant="success">La contraseña se ha cambiado con éxito.</Alert>
          )}
    
          <Form.Group as={Row}>
            <Form.Label as="legend" column sm={4}>
              Contraseña actual
            </Form.Label>
            <Col sm={8}>
              <Form.Control
                placeholder="Contraseña actual"
                type="password"
                value={old_password}
                onChange={(e) => setOldPassword(e.target.value)}
              />
            </Col>
          </Form.Group>
    
          <PasswordForm
            password={password}
            onChange={setPassword}
            setValid={setIsFormValid}
          />
          <Form.Group as={Row}>
            <Col sm={{ offset: 4, span: 8 }}>
              <Button type="submit" variant="primary" disabled={!isFormValid}>
                Cambiar la contraseña
              </Button>
            </Col>
          </Form.Group>
        </Sender>
      );
    }
    
    export default OwnPassword;