feat: profile_photo en contratos activos, notificaciones bilingues en reportes y foto en panel usuarios
- API contratos activos (cliente y proveedor): agrega campo profile_photo (técnico asignado o supplier, null si no tiene) - Notificaciones push bilingues en comentarios de reporte: "Nueva actividad en tu reporte" / "New activity on your report" - Moderador en web panel notifica a cliente y proveedor al comentar, con prefijo Moderador/Moderator - Panel usuarios: columna de foto de perfil entre ID y Nombre Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,13 +33,14 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse($tokenResult->token->expires_at)->toDateTimeString(),
|
||||
'userid' => $user->id,
|
||||
'role' => $user->role_id,
|
||||
'verified' => $user->phone_verified_at,
|
||||
'reported' => $user->reported,
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse($tokenResult->token->expires_at)->toDateTimeString(),
|
||||
'userid' => $user->id,
|
||||
'role' => $user->role_id,
|
||||
'verified' => $user->phone_verified_at,
|
||||
'reported' => $user->reported,
|
||||
'profile_photo' => $user->profile_photo,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -53,9 +54,10 @@ class AuthController extends Controller
|
||||
return response()->json(['message' => 'Token de Firebase inválido'], 401);
|
||||
}
|
||||
|
||||
$uid = $verifiedToken->claims()->get('sub');
|
||||
$email = $verifiedToken->claims()->get('email');
|
||||
$name = $verifiedToken->claims()->get('name') ?? 'Usuario';
|
||||
$uid = $verifiedToken->claims()->get('sub');
|
||||
$email = $verifiedToken->claims()->get('email');
|
||||
$name = $verifiedToken->claims()->get('name') ?? 'Usuario';
|
||||
$picture = $verifiedToken->claims()->get('picture');
|
||||
|
||||
// Buscar por firebase uid primero, luego por email para hacer merge si ya existía cuenta
|
||||
$user = User::where('social_id', 'firebase|' . $uid)->first();
|
||||
@@ -65,31 +67,38 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
// Vincular uid de Firebase si aún no lo tiene (merge de cuenta existente)
|
||||
$changed = false;
|
||||
if (!$user->social_id) {
|
||||
$user->social_id = 'firebase|' . $uid;
|
||||
$user->save();
|
||||
$changed = true;
|
||||
}
|
||||
if ($picture && $user->profile_photo !== $picture) {
|
||||
$user->profile_photo = $picture;
|
||||
$changed = true;
|
||||
}
|
||||
if ($changed) $user->save();
|
||||
} else {
|
||||
$user = User::create([
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'social_id'=> 'firebase|' . $uid,
|
||||
'role_id' => 1,
|
||||
'password' => null,
|
||||
'name' => $name,
|
||||
'email' => $email,
|
||||
'social_id' => 'firebase|' . $uid,
|
||||
'role_id' => 1,
|
||||
'password' => null,
|
||||
'profile_photo' => $picture,
|
||||
]);
|
||||
}
|
||||
|
||||
$tokenResult = $user->createToken('Firebase Token');
|
||||
|
||||
return response()->json([
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse($tokenResult->token->expires_at)->toDateTimeString(),
|
||||
'userid' => $user->id,
|
||||
'role' => $user->role_id,
|
||||
'verified' => $user->phone_verified_at,
|
||||
'reported' => $user->reported,
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse($tokenResult->token->expires_at)->toDateTimeString(),
|
||||
'userid' => $user->id,
|
||||
'role' => $user->role_id,
|
||||
'verified' => $user->phone_verified_at,
|
||||
'reported' => $user->reported,
|
||||
'profile_photo' => $user->profile_photo,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user