Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Login fix #80

Merged
merged 2 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Header = ({ userId }) => {
return (
<span>
{userId}{' '}
<Button variant="link" onClick={Virtru.signOut} verySmall light>
<Button variant="link" onClick={() => Virtru.signOut(userId)} verySmall light>
Sign out
</Button>
</span>
Expand Down
15 changes: 14 additions & 1 deletion src/scenes/Document/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function Document({
setEncryptState,
setPolicy,
setPolicyId,
isLoggedIn,
}) {
const [isShareOpen, setShareOpen] = useState(false);
const [isAuthOpen, setAuthOpen] = useState(false);
Expand Down Expand Up @@ -147,6 +148,7 @@ function Document({
encrypt={encrypt}
encryptState={encryptState}
policyChange={policyChange}
isLoggedIn={isLoggedIn}
/>
</div>
</Drop>
Expand Down Expand Up @@ -239,7 +241,18 @@ const mapToProps = ({
policy,
userId,
virtruClient,
}) => ({ policyId, file, policy, userId, appId, virtruClient, encrypted, encryptState });
isLoggedIn,
}) => ({
policyId,
file,
policy,
userId,
appId,
virtruClient,
encrypted,
encryptState,
isLoggedIn,
});

const saveFileToLocalStorage = ({ fileBuffer, fileName, fileType }) => {
const b64 = arrayBufferToBase64(fileBuffer);
Expand Down
4 changes: 2 additions & 2 deletions src/scenes/Document/scenes/Policy/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function Policy({
policyChange,
virtruClient,
policyId,
isLoggedIn,
}) {
const renderButtons = () => {
switch (encryptState) {
Expand All @@ -30,7 +31,7 @@ function Policy({
case ENCRYPT_STATES.PROTECTED_NO_AUTH:
return <Button onClick={openAuthModal}># to Protect</Button>;
default:
if (userId) {
if (isLoggedIn) {
return (
<Button data-testid="encryptFile" onClick={encrypt}>
Protect File
Expand All @@ -47,7 +48,6 @@ function Policy({
</>
);
}

}
};
if (encryptState !== ENCRYPT_STATES.PROTECTED) {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/VirtruWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ function newVirtruDecryptParamsBuilder(opts) {
return new Virtru.DecryptParamsBuilder(opts);
}

function signOut() {
function signOut(userId) {
Virtru.Auth.logout({ email: userId });
localStorage.clear();
window.location = window.location.href.split(/[?#]/)[0];
}
Expand Down