feat: password reset and firebase security

This commit is contained in:
Kyle Gill
2019-04-22 23:23:27 -07:00
parent 8f61da013b
commit e26475730e
5 changed files with 50 additions and 3 deletions

8
.env.sample Normal file
View File

@@ -0,0 +1,8 @@
REACT_APP_FIREBASE_API_KEY=<BUNCHofRandomNumbersAndChars>
REACT_APP_DEV_AUTH_DOMAIN=<name>.firebaseapp.com
REACT_APP_DEV_DATABASE_URL=https://<name>.firebaseio.com
REACT_APP_DEV_PROJECT_ID=<name>
REACT_APP_DEV_STORAGE_BUCKET=<name>.appspot.com
REACT_APP_DEV_MESSAGING_SENDER_ID=############
REACT_APP_CONFIRMATION_EMAIL_REDIRECT=https://<name>.firebaseapp.com

View File

@@ -1,7 +1,7 @@
service cloud.firestore { service cloud.firestore {
match /databases/{database}/documents { match /databases/{database}/documents {
match /{document=**} { match /{document=**} {
allow read, write; allow read, write: if request.auth != null;
} }
} }
} }

View File

@@ -62,6 +62,7 @@ class RegisterFormBase extends Component {
}) })
const { user } = result const { user } = result
console.log(user) console.log(user)
user.sendEmailVerification()
firebase.db firebase.db
.collection("users") .collection("users")
.doc(user.uid) .doc(user.uid)

View File

@@ -122,7 +122,7 @@ class Search extends Component {
`} `}
/> />
</div> </div>
) : ( ) : entries.length > 0 ? (
entries.map((entry, index) => ( entries.map((entry, index) => (
<Link <Link
key={index} key={index}
@@ -150,6 +150,17 @@ class Search extends Component {
</SearchResult> </SearchResult>
</Link> </Link>
)) ))
) : (
<div
css={css`
text-align: center;
font-style: italic;
color: ${theme.colors.tertiary};
margin-top: 5px;
`}
>
No entries to display
</div>
)} )}
</SearchGrid> </SearchGrid>
</SearchLayout> </SearchLayout>

View File

@@ -86,16 +86,43 @@ class User extends React.Component {
} }
render() { render() {
const { authUser, theme } = this.props const { authUser, theme, firebase } = this.props
const { exporting, files } = this.state const { exporting, files } = this.state
return ( return (
<ProfileGrid> <ProfileGrid>
<ProfileSection> <ProfileSection>
<ProfileSectionHeader> <ProfileSectionHeader>
User: <ProfileSectionText>{authUser.email}</ProfileSectionText> User: <ProfileSectionText>{authUser.email}</ProfileSectionText>
<div>
<ProfileSectionText style={{ fontWeight: 400 }}>
{authUser.emailVerified
? "Email has been verified"
: "Email not verified"}
</ProfileSectionText>
</div>
</ProfileSectionHeader> </ProfileSectionHeader>
<SignOut /> <SignOut />
</ProfileSection> </ProfileSection>
<ProfileSection>
<ProfileSectionHeader>
Reset Password{" "}
<div>
<ProfileSectionText style={{ fontWeight: 400 }}>
send an email with reset instructions
</ProfileSectionText>
</div>
</ProfileSectionHeader>
<Button
colors={theme.colors}
onClick={() => {
console.log("reset!")
firebase.doPasswordReset(authUser.email)
}}
>
Send Reset
</Button>
</ProfileSection>
<ProfileSection> <ProfileSection>
<ProfileSectionHeader> <ProfileSectionHeader>
Export Journal Entries{" "} Export Journal Entries{" "}