Skip to content

Commit

Permalink
feat: add 2FA toggle on login form
Browse files Browse the repository at this point in the history
  • Loading branch information
victorgcramos committed Dec 18, 2020
1 parent 39d689d commit ab09084
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/containers/User/Login/Form.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Button, Link as UILink, Text, TextInput, classNames } from "pi-ui";
import {
Button,
Link as UILink,
Text,
TextInput,
classNames,
Toggle
} from "pi-ui";
import PropTypes from "prop-types";
import React, { useCallback, useState } from "react";
import { withRouter } from "react-router-dom";
Expand Down Expand Up @@ -41,6 +48,10 @@ const LoginForm = ({
[onLogin, onLoggedIn]
);

const handleToggleTotp = useCallback(() => setShowTotp(!showTotp), [
showTotp
]);

const [handleOpenModal, handleCloseModal] = useModalContext();

const handleOpenPrivacyPolicyModal = () => {
Expand Down Expand Up @@ -113,6 +124,16 @@ const LoginForm = ({
onBlur={handleBlur}
error={touched.password && errors.password}
/>
<div className={styles.totpToggleWrapper}>
<Toggle
id="totp-toggle"
onToggle={handleToggleTotp}
toggled={showTotp}
/>
<Text className={styles.totpToggleLabel}>
Two-Factor Authentication (2FA)
</Text>
</div>

<VerifyTotp
className={classNames(styles.totp, !showTotp && styles.hide)}
Expand Down
10 changes: 10 additions & 0 deletions src/containers/User/Login/LoginForm.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ span.createAccounTxt {
.totpInput {
margin-top: 0;
}

.totpToggleWrapper {
display: flex;
padding: 1rem 0 2rem;
}

.totpToggleLabel {
padding: 0.2rem 1rem 0;
color: var(--text-input-color) !important;
}

0 comments on commit ab09084

Please sign in to comment.