-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: the account deletion button and other changes are being implem…
…ented
- Loading branch information
Showing
7 changed files
with
77 additions
and
29 deletions.
There are no files selected for viewing
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
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
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,39 @@ | ||
import { | ||
signOut, | ||
reauthenticateWithCredential, | ||
GoogleAuthProvider, | ||
} from 'firebase/auth'; | ||
|
||
import { logIn } from '@services/auth/config'; | ||
import { useAuth } from '@contexts/AuthContext'; | ||
|
||
export function useAccountActions() { | ||
const { currentUser } = useAuth(); | ||
|
||
async function logOut() { | ||
try { | ||
await signOut(logIn); | ||
await window.localStorage.removeItem('app_tk'); | ||
} catch (error) { | ||
console.error('Error al cerrar sesión:', error); | ||
} | ||
} | ||
|
||
async function deleteAccount() { | ||
try { | ||
if (currentUser) { | ||
// const idToken = await currentUser?.; | ||
// const credential = GoogleAuthProvider.credential(idToken); | ||
|
||
// await reauthenticateWithCredential(currentUser, credential); | ||
await currentUser?.delete(); // Elimina la cuenta de Firebase | ||
await signOut(logIn); | ||
await window.localStorage.removeItem('app_tk'); | ||
} | ||
} catch (error) { | ||
console.error('Error al borrar la cuenta:', error); | ||
} | ||
} | ||
|
||
return { logOut, deleteAccount }; | ||
} |
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
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
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
File renamed without changes.