Skip to content

Commit

Permalink
Login fix (#80)
Browse files Browse the repository at this point in the history
* login fixes

* fixed logout
  • Loading branch information
biscoe916 authored Aug 2, 2019
1 parent 48d06ed commit ec6e2e1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
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 @@ -165,7 +165,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

0 comments on commit ec6e2e1

Please # to comment.