Encontrar el Uid del firebase/autentication para eliminar

W

Whiplash

hola buenas a todos/as quisiera que me ayudasen a encontrar una solucion o una variante a la problematica que tengo. el problema es el siguiente: tengo un proyecto en angular ionic, la cual quiero realizar un gestor de usuarios y actualmente tengo lo que seria el registro de ususarios y listado de estos, pero al momento de realizar el eliminar usuario del firebase, no me deja eliminar porque en la consola me dice que no se a encontrado el usuario por el UID de este, pero he estado analizando el codigo que segun yo esta bien y no se me ocurre otra solucion aqui le dejo la informacion de los codigos

authService (servicio para gestion de las cuentas):

Code:
**import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import { Empleado, Usuario } from './modelUser';
import { Router } from '@angular/router';
@Injectable({
  providedIn: 'root'
})
export class AuthService {
  constructor(
    private afAuth: AngularFireAuth,
    private firestore: AngularFirestore,
    private router: Router
  ) { }
  async registrar(usuario: Usuario) {
    try {
      const credential = await this.afAuth.createUserWithEmailAndPassword(usuario.correo, usuario.password);
      const uid = credential.user?.uid;
      if (uid) {
        await this.firestore.collection('Usuarios').doc(uid).set(usuario);
      } else {
        throw new Error('No se pudo obtener el UID del usuario.');
      }
    } catch (error: any) {
      throw new Error('Error al registrar usuario: ' + error.message);
    }
  }
  async registrarByAdmin(empleado: Empleado) {
    try {
      const credential = await this.afAuth.createUserWithEmailAndPassword(empleado.correo, empleado.password);
      const uid = credential.user?.uid;
      if (uid) {
        await this.firestore.collection('Empleados').doc(uid).set(empleado);
      } else {
        throw new Error('No se pudo obtener el UID del empleado.');
      }
    } catch (error: any) {
      throw new Error('Error al registrar empleado: ' + error.message);
    }
  }
  async getEmpleados(): Promise<Empleado[]> {
    try {
      const snapshot = await this.firestore.collection('Empleados').get().toPromise();
      if (snapshot) {
        return snapshot.docs.map(doc => doc.data() as Empleado);
      } else {
        throw new Error('No se encontraron documentos en la colección Empleados.');
      }
    } catch (error: any) {
      throw new Error('Error al obtener la lista de empleados: ' + error.message);
    }
  }
  async ingresar(email: string, password: string) {
    try {
      await this.afAuth.signInWithEmailAndPassword(email, password);
      this.router.navigate(['/perfil']);
    } catch (error: any) {
      console.error('Error al iniciar sesión:', error);
      throw new Error('Error al iniciar sesión: ' + error.message);
    }
  }
  async cerrarSesion() {
    try {
      await this.afAuth.signOut();
      this.router.navigate(['/']);
    } catch (error: any) {
      console.error('Error al cerrar sesión:', error);
      throw new Error('Error al cerrar sesión: ' + error.message);
    }
  }
  
  modificarUsuario() {
  }
  async eliminarUsuario(uid: string): Promise<void> {
    try {
      const user = await this.afAuth.currentUser;
      if (user) {
        await user.delete();
      } else {
        throw new Error('No se encontró el usuario para eliminar.');
      }
      await this.firestore.collection('Usuarios').doc(uid).delete();
      this.router.navigate(['/']);
    } catch (error: any) {
      console.error('Error al eliminar usuario:', error);
      throw new Error('Error al eliminar usuario: ' + error.message);
    }
  }
  
  
  async getUid(){
    const user = await this.afAuth.currentUser;
    if (user === null){
      return null;
    } else {
      return user?.uid;
    }
  }
  getCurrentUser() {
    return this.afAuth.currentUser.then(user => {
      if (user !== null) {
        return user;
      } else {
        return null;
      }
    }).catch(error => {
      console.error('Error al obtener el usuario actual:', error);
      throw new Error('Error al obtener el usuario actual: ' + error.message);
    });
  }
  // selecciona al usuario unico
  async getUsuarioID(uid: string): Promise<Usuario> {
    try {
      const docRef = this.firestore.collection('Usuarios').doc(uid);
      const doc = await docRef.get().toPromise();
      if (doc && doc.exists) {
        return doc.data() as Usuario;
      } else {
        throw new Error('No se encontró la información del usuario.');
      }
    } catch (error: any) {
      throw new Error('Error al obtener la información del usuario: ' + error.message);
    }
  }
  // muestra a todos los usuarios en una lista
  async getUsuarios(): Promise<Usuario[]> {
    try {
      const snapshot = await this.firestore.collection('Usuarios').get().toPromise();
      if (snapshot) {
        return snapshot.docs.map(doc => doc.data() as Usuario);
      } else {
        throw new Error('No se encontraron documentos en la colección Usuarios.');
      }
    } catch (error: any) {
      throw new Error('Error al obtener la lista de usuarios: ' + error.message);
    }
  }
  
  stateAuth(){
    return this.afAuth.authState;
  } 
}**

codigo del gestor de usuario y funcion de listado y eliminacion del usuario:

**

Code:
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ToastController } from '@ionic/angular';
import { AuthService } from 'src/app/models-srvcs/auth.service';
import { CacheService } from 'src/app/models-srvcs/cache.service';
import { Usuario } from 'src/app/models-srvcs/modelUser';
@Component({
  selector: 'app-gestioncli',
  templateUrl: './gestioncli.component.html',
  styleUrls: ['./gestioncli.component.scss'],
})
export class GestioncliComponent implements OnInit {
  usuarios: Usuario[] = [];
  constructor(
    private authService: AuthService,
    private toastController: ToastController,
    private router: Router,
    private cacheService: CacheService
  ) {}
  ngOnInit() {
    this.getUsuarios();
  }
  navigateToPage(page: string) {
    this.router.navigate([page]);
  }
  async getUsuarios() {
    try {
      this.usuarios = this.cacheService.getUsuarios();
      if (this.usuarios.length === 0) {
        this.usuarios = await this.authService.getUsuarios();
        this.cacheService.setUsuarios(this.usuarios);
      }
    } catch (error) {
      console.error('Error al obtener usuarios:', error);
    }
  }
  async eliminarCli(uid: string) {
    try {
      await this.authService.eliminarUsuario(uid);
      await this.mostrarMensaje('Cliente eliminado exitosamente.');
      await this.getUsuarios();
    } catch (error) {
      console.error('Error al eliminar cliente:', error);
      await this.mostrarMensaje('Error al eliminar cliente.');
    }
  }
  modificarCli(){
    
  }
  async mostrarMensaje(mensaje: string) {
    const toast = await this.toastController.create({
      message: mensaje,
      duration: 2000,
      position: 'top',
    });
    toast.present();
  }
}

**

aquí les dejo la información de la acción de eliminar: no se encontró usuario para eliminar

mas cerca
 

Unreplied Threads

When an algebra isomorphism preserves positive involution

Let $A$ be a $K$-algebra where $K$ is a field with a unique ordering. We say a $K$-linear involution $*$ is positive if the map $A \to K$ via $a \mapsto tr(a^*a)$ is positive definite with respect to the ordering. Here, $tr(a)$ is the trace of the left multiplication map $a:x \mapsto ax$.

Suppose there is a $K$-algebra isomorphism $$\varphi: A \to B.$$

If there is a unique (up to isomorphism) positive involution in $A$ and $B$, can we say the involution must be preserved by the isomorphism $\varphi$: $$\varphi: (A, *_A) \to (B, *_B)?$$

Motivation:​


My question is motivated from representation theory. When $W$ is a real irreducible representation (irrep) of a finite group $G$, then $D:=End_G(W)$ is a division algebra by Schur's lemma. Additionally, Frobenius theorem on real associative division algebras implies that $D$ is isomorphic to either the reals $\mathbb{R}$, complexes $\mathbb{C}$, or quaternions $\mathbb{H}$. Let's call this isomorphism $\varphi$.

Suppose $W$ is endowed with an $G$-invariant inner product (i.e. $\langle g\cdot u, g\cdot v \rangle=\langle u , v \rangle$ for all $u,v \in W$ and $g \in G$). So, $W$ is an orthogonal irrep, and $D$ has the involution that acts as the adjoint corresponding to the $G$-invariant inner product. We know that $\mathbb{R}$, $\mathbb{C}$, and $\mathbb{H}$ all have involution. Furthermore, they are normed division algebras. The involution is the trivial map in $\mathbb{R}$, complex conjugate in $\mathbb{C}$, and the standard involution in $\mathbb{H}$ $\left((a+ib+jc+dk)^*=a-ib-jc-dk\right).$ We even do not need to define the involution in $\mathbb{R}$, $\mathbb{C}$, and $\mathbb{H}$ because the involution must be positive when we want to correspond involution to adjoint and there is a unique positive involution up to isomorphism in real central division algebras. My original question is how to prove that $\varphi$ preserves involution. Is this even true?

problem with armature after mirroring part of object

first of all, I'm totally new to blender, but couldn't find my answer after searching a lot. here is my problem in blender 4.2: in object edit mode, I've duplicated left shoulder top armor, mirrored, moved over right shoulder.

copied image

now the problem is; in pose mode if i rotate or modify left shoulder bone, that right mirrored armor part is moving too as in image:

bone rotate

I've tried to separate all object parts, then clear all parents from it, re-assign right shoulder bone as parent. but still it move with left shoulder bone as well as right shoulder bone.

any help appreciated.

blender file:

ps: is there anyway to select a bone and see which objects assigned to that bone? I know about weights and vertex groups, but in this object, non assigned to mirrored object.

What the garlic is that pt.2? (Plant identification help needed)

  • Derptastic
  • Social
  • Replies: 0
I have sown some garlic cloves in a pot (I only have a balcony, don't judge). And... something came out of the pot, but it's not garlic, and I'm very curious what it might be: Mystery plant Mystery plant, image two

I even mistook it for garlic initially, but it's completely inedible, and in fact, can barely be chewed through in any manner - the leaves are pretty tough. As far as I could tell by rummaging in the ground, there are no cloves to this beastie, and the roots seem to go quite far down. Google Lens identifies that as Chives, but I can guarantee you it's not (I actually do have chives, in a pot beside this one). In this case, you can see some actual garlic that caught on, chilling in the background, wondering what kind of neighbor is that. It definitely feels like a weed, but I still wanted to find out what it could be before it goes out.

Any educated guesses?

What would happen if you use warm base on a compressor ice cream machine?

  • Lenny Markus
  • Social
  • Replies: 0
Note: This question is for an ice cream machine WITH a compressor

Pretty much all recipes for ice cream/gelato call for completely chilling the mixture before starting to churn.

I get that for "passively" cooled machines (compressorless) it's important, so that you don't loose any of the pre-cooling you've done to the hardware.

Does it actually matter for a compressor-based machine? The machine can certainly cool it down without a hitch, but would it impact the final texture?

Attempting to simplify Fiege-Fiat-Shamir Identification

  • deeplyconfused
  • Technology
  • Replies: 0
My understanding of the Fiege-Fiat-Shamir protocol, sourced from "RSA and Public-Key Cryptography" by Richard A. Mollin is as below:

  1. A third party chooses two large primes $p$ and $q$, sharing $n = pq$.
  2. Alice has a secret value $s_a$ and shares a number $t_a = s_a^2 \mod n$.
  3. Alice picks a random $m \in \mathbb{N}$ and sends $w = m^2 \mod n$ to Bob.
  4. Bob picks a challenge $c \in \{0, 1\}$ and sends that to Alice.
  5. Alice computes $r = ms_a^c \mod m$ and sends that to Bob.
  6. Bob computes $r^2 = m^2s_a^{2c}$, and he can compare that to the publicly known $wt_a^2$, which should be identical if Alice does indeed know $s_a$. The security of this protocol is based on the fact that it is difficult to solve quadratic modular congruences with unfactored moduli.

My text elaborates that there is a method that an attacker can use to impersonate Alice with a 50% success rate, so this is done $a$ times and the probability that this works becomes $2^{-a}$.



If my understanding of this is correct, then one could use a similar protocol, but without the 50% chance of failure:

  1. As before, a third party selects $p$ and $q$, sharing $n = pq$.
  2. Alice picks a random $m$ and sends $w = m^2 \mod n$ to Bob.
  3. Alice sends $r = ms_a \mod n$ to Bob.
  4. Bob computes $r^2 \mod n$ and confirms that it's equal to $mt_a$.

Again, because neither $w$ nor $t_a$ are easy to compute, this seems secure.

I assume that this doesn't work. Why not? Why does Fiege-Fiat-Shamir require that Bob send a challenge?

Zencash uses your passphrase to identify AND unlock a wallet - how is this secure?

When looking into Zencash I stumbled into myzenwallet.io (by the Zencash creators), which gives you the option to enter a passphrase to generate a wallet (seems normal), but then after creating your wallet you can come back later and open your wallet by simply re-entering your passphrase again... this was unexpected and had me not only wondering about how it worked, but also wondering whether whatever means were used to achieve this would remain secure in the future.

Given that I don't need to identify the resource I'm unlocking, but rather just hand over the passphrase, I'm left to assume that their system generates a token by hashing my passphrase a number of times to generate my "master address" or "account ID" (I just made those terms up, because Zencash gives you many addresses, so I also assume you have some sort of master address / account ID), and then also using that same passphrase to lock / authenticate (not to encrypt though, right?) the wallet.

What common proverb does this string refer to?

  • matt_rule
  • Technology
  • Replies: 0
What common proverb is referenced by this three-character string?

ᚷᛖᚨ
Top