-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
166 additions
and
105 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
src/components/Account/AccountDialog/DeleteAndClearDialog.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/components/Secure/DeleteAndClear/DeleteAndClearAppBar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Menu from '@material-ui/core/Menu'; | ||
import MenuItem from '@material-ui/core/MenuItem'; | ||
import { useState } from 'react'; | ||
import AppBar from '@material-ui/core/AppBar'; | ||
import Toolbar from '@material-ui/core/Toolbar'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Avatar from '@material-ui/core/Avatar'; | ||
import { IconButton } from '@material-ui/core'; | ||
import AutorenewIcon from '@material-ui/icons/Autorenew'; | ||
import fire from '../../../../utils/firebase'; | ||
|
||
export default function DeleteAndClearAppBar() { | ||
const photoURL = fire.auth()?.currentUser?.photoURL; | ||
const name = fire.auth().currentUser!.displayName; | ||
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); | ||
const isMenuOpen = Boolean(anchorEl); | ||
|
||
return ( | ||
<div> | ||
<AppBar position="fixed"> | ||
<Toolbar | ||
style={{ | ||
display: `flex`, | ||
flexDirection: `row`, | ||
justifyContent: `space-between`, | ||
}} | ||
> | ||
<a href="/" className="flex flex-row text-center align-bottom"> | ||
<img className="m-1 p-1 w-9 h-10" alt="Logo" src="/firevault.png" /> | ||
<Typography variant="h6" className="flex flex-col justify-center"> | ||
Firevault | Delete Account and Clear Files | ||
</Typography> | ||
</a> | ||
<div className="flex flex-row justify-center items-center h-full"> | ||
<Avatar src={photoURL as string} /> | ||
</div> | ||
</Toolbar> | ||
</AppBar> | ||
</div> | ||
); | ||
} |
61 changes: 61 additions & 0 deletions
61
src/components/Secure/DeleteAndClear/DeleteAndClearPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import DeleteAndClearAppBar from '@/components/Secure/DeleteAndClear/DeleteAndClearAppBar'; | ||
import Footer from '@/components/Home/Footer'; | ||
import Button from '@material-ui/core/Button'; | ||
import React from 'react'; | ||
import fire from '../../../../utils/firebase'; | ||
|
||
export default function DeleteAndClearPage() { | ||
const deleteAccount = () => { | ||
fire | ||
.auth() | ||
.currentUser?.getIdToken(false) | ||
.then((idToken) => { | ||
fetch(`${process.env.NEXT_PUBLIC_UPLOAD_BASE}/api/clearData`, { | ||
method: `POST`, | ||
headers: { | ||
Authorization: idToken, | ||
}, | ||
}) | ||
.then((res) => res.json()) | ||
.then((json) => { | ||
fire | ||
.auth() | ||
.currentUser?.delete() | ||
.then((r) => { | ||
window.location.replace(`/`); | ||
}); | ||
}); | ||
}); | ||
}; | ||
const goBack = () => { | ||
window.location.replace(`/account`); | ||
}; | ||
return ( | ||
<div> | ||
<DeleteAndClearAppBar /> | ||
<div className="flex flex-col justify-center items-center pt-20"> | ||
<main className="flex flex-col justify-center flex-1 items-center p-5 dark:text-blue-50"> | ||
<p className="text-4xl">Delete Account Clear Data</p> | ||
<p className="text-xl w-80 text-center m-10"> | ||
This will clear all of your files on Firevault and delete your user | ||
account. This action cannot be undone. | ||
</p> | ||
<div className="w-80 flex flex-row justify-center items-center"> | ||
<Button | ||
autoFocus | ||
onClick={goBack} | ||
variant="contained" | ||
color="primary" | ||
> | ||
No | ||
</Button> | ||
<Button onClick={deleteAccount} className="m-3" variant="contained"> | ||
Delete Account and Clear Files | ||
</Button> | ||
</div> | ||
</main> | ||
<Footer /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useEffect, useState } from 'react'; | ||
import Loading from '@/components/Home/Loading'; | ||
import SecureLanding from '@/components/Secure/SecureLanding'; | ||
import HomePage from '@/components/Home/Home'; | ||
import PageHead from '@/components/PageHead'; | ||
import UploadStick from '@/components/UploadStick'; | ||
import DeleteAndClearPage from "@/components/Secure/DeleteAndClear/DeleteAndClearPage"; | ||
import fire from '../../../utils/firebase'; | ||
|
||
export default function Wipe() { | ||
const [isSignedIn, setIsSignedIn] = useState(false); | ||
const [signed, setSigned] = useState(false); | ||
let one = false; | ||
|
||
useEffect(() => { | ||
const unregisterAuthObserver = fire.auth().onAuthStateChanged((user) => { | ||
if (!one && fire.auth().currentUser) { | ||
fire.auth().signOut(); | ||
one = true; | ||
} | ||
setIsSignedIn(!!user); | ||
setSigned(true); | ||
}); | ||
return () => unregisterAuthObserver(); | ||
}, []); | ||
|
||
const returnElement = () => { | ||
if (!isSignedIn && !signed) { | ||
return <Loading />; | ||
} | ||
if (!isSignedIn) { | ||
return <SecureLanding />; | ||
} | ||
return <DeleteAndClearPage />; | ||
}; | ||
|
||
return ( | ||
<div className="h-full min-h-screen bg-white dark:bg-gray-800"> | ||
<PageHead /> | ||
{process.env.NEXT_PUBLIC_BASE_NAME === `HEROKU` ? ( | ||
<UploadStick /> | ||
) : ( | ||
returnElement() | ||
)} | ||
</div> | ||
); | ||
} |
e663788
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: