Close session done

This commit is contained in:
2021-10-25 20:17:44 -03:00
parent 0cd6e811c8
commit 89074d41e5
2 changed files with 15 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { getAuth, onAuthStateChanged } from "firebase/auth"
import { getAuth, onAuthStateChanged, signOut } from "firebase/auth"
import capitalize from '../../Control Panel/Scripts/Capilazate'
@@ -7,8 +7,9 @@ import bringDataFromFirebase from './Firebase Querys/bringDataFromFirebase'
import HeaderAccount from './HeaderAccount/HeaderAccount'
import hideRefferCode from './Scripts/hideRefferCode'
import Loading from '../../../Loading/Loading'
import { withRouter } from 'react-router'
const AccountInfo = () => {
const AccountInfo = (props) => {
const [name, setName] = useState('')
const [email, setEmail] = useState(false)
@@ -21,6 +22,12 @@ const AccountInfo = () => {
const closeSession = async () => {
const auth = getAuth()
signOut(auth)
.then(() => {
props.history.push('/identify')
})
}
const applyResult = (result) => {
@@ -43,7 +50,6 @@ const AccountInfo = () => {
React.useEffect(() => {
const auth = getAuth()
onAuthStateChanged(auth, (user) => {
@@ -51,13 +57,11 @@ const AccountInfo = () => {
if (user) {
setEmail(user.email)
bringData(user.email)
}
})
} else {
props.history.push('/identify')
}
})
}, [])
@@ -109,4 +113,4 @@ const AccountInfo = () => {
)
}
export default AccountInfo
export default withRouter(AccountInfo)

View File

@@ -40,7 +40,7 @@ const AccountPreview = (props) => {
defineName(user.email)
setLogin(true)
} else {
alert('NO USER')
props.history.push('/identify')
}
})
}