UNPKG

matrix-react-sdk

Version:
67 lines (66 loc) 2.3 kB
import React from "react"; import { AccessibleButtonKind } from "../elements/AccessibleButton"; declare const FIELD_OLD_PASSWORD = "field_old_password"; declare const FIELD_NEW_PASSWORD = "field_new_password"; declare const FIELD_NEW_PASSWORD_CONFIRM = "field_new_password_confirm"; type FieldType = typeof FIELD_OLD_PASSWORD | typeof FIELD_NEW_PASSWORD | typeof FIELD_NEW_PASSWORD_CONFIRM; declare enum Phase { Edit = "edit", Uploading = "uploading", Error = "error" } interface IProps { onFinished: (outcome: { didSetEmail?: boolean; }) => void; onError: (error: Error) => void; rowClassName?: string; buttonClassName?: string; buttonKind?: AccessibleButtonKind; buttonLabel?: string; confirm?: boolean; autoFocusNewPasswordInput?: boolean; className?: string; shouldAskForEmail?: boolean; } interface IState { fieldValid: Partial<Record<FieldType, boolean>>; phase: Phase; oldPassword: string; newPassword: string; newPasswordConfirm: string; } export default class ChangePassword extends React.Component<IProps, IState> { private [FIELD_OLD_PASSWORD]; private [FIELD_NEW_PASSWORD]; private [FIELD_NEW_PASSWORD_CONFIRM]; static defaultProps: Partial<IProps>; constructor(props: IProps); private onChangePassword; private changePassword; /** * Checks the `newPass` and throws an error if it is unacceptable. * @param oldPass The old password * @param newPass The new password that the user is trying to be set * @param confirmPass The confirmation password where the user types the `newPass` * again for confirmation and should match the `newPass` before we accept their new * password. */ private checkPassword; private optionallySetEmail; private markFieldValid; private onChangeOldPassword; private onOldPasswordValidate; private validateOldPasswordRules; private onChangeNewPassword; private onNewPasswordValidate; private onChangeNewPasswordConfirm; private onNewPasswordConfirmValidate; private validatePasswordConfirmRules; private onClickChange; private verifyFieldsBeforeSubmit; private allFieldsValid; private findFirstInvalidField; render(): React.ReactNode; } export {};