Skip to content

Instantly share code, notes, and snippets.

@alancasagrande
Created November 16, 2020 13:25
Show Gist options
  • Save alancasagrande/fad6835758fd5c625e0c43b0daa80d13 to your computer and use it in GitHub Desktop.
Save alancasagrande/fad6835758fd5c625e0c43b0daa80d13 to your computer and use it in GitHub Desktop.
import React from 'react';
import Login from './Login';
import OneTimePassword from './OneTimePassword';
export default function App({ user, requireMfa }) {
// User enabled MFA but did not verify code, show OTP form
if (requireMfa) {
return <OneTimePassword enabled={true} />;
}
// User not logged in, show login form
if (!user) {
return <Login />;
}
// User is authenticated
return (
<div>
<p>
Hello, {user.username}. <a href="/logout">Logout</a>
</p>
{user.mfaEnabled ? (
<p>Confratulations, multi factor authentication is enabled.</p>
) : (
<OneTimePassword enabled={false} />
)}
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment