-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from Crudzaso/develop
Develop
- Loading branch information
Showing
28 changed files
with
1,148 additions
and
415 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
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
@endforeach | ||
</tbody> | ||
</table> | ||
<active-raffles></active-raffles> | ||
</div> | ||
</div> | ||
@endsection |
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,102 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Support\Facades\Log; | ||
use Laravel\Socialite\Facades\Socialite; | ||
use App\Models\User; | ||
|
||
class AuthController extends Controller | ||
{ | ||
public function redirectToGitHub() | ||
{ | ||
return Socialite::driver('github')->redirect(); | ||
} | ||
|
||
public function handleGitHubCallback() | ||
{ | ||
try { | ||
$githubUser = Socialite::driver('github')->user(); | ||
|
||
// Verifica los datos recibidos | ||
Log::info('Usuario de GitHub: ', [ | ||
'id' => $githubUser->id, | ||
'nickname' => $githubUser->nickname, | ||
'name' => $githubUser->name, | ||
'email' => $githubUser->email, | ||
'avatar' => $githubUser->avatar, | ||
]); | ||
|
||
// Encuentra o crea un usuario | ||
$user = User::firstOrCreate([ | ||
'email' => $githubUser->email, | ||
], [ | ||
'name' => $githubUser->name ?: 'Nombre por defecto', | ||
'github_id' => $githubUser->id, | ||
'lastname' => 'Apellidos por defecto', | ||
'password' => bcrypt('random_password'), | ||
'phone_number' => 'Número por defecto', | ||
'document' => '00000000', | ||
'document_type' => 'CC', | ||
]); | ||
|
||
// Inicia sesión al usuario | ||
Auth::login($user); | ||
|
||
return redirect('/dashboard'); | ||
} catch (\Exception $e) { | ||
// Registra el error | ||
Log::error('Error en la autenticación de GitHub: ' . $e->getMessage()); | ||
return redirect('/')->with('error', 'No se pudo iniciar sesión con GitHub.'); | ||
} | ||
} | ||
|
||
public function redirectToGoogle() | ||
{ | ||
return Socialite::driver('google')->redirect(); | ||
} | ||
|
||
public function handleGoogleCallback() | ||
{ | ||
try { | ||
Log::info('Entrando en el callback de Google.'); | ||
|
||
// Obtener el usuario de Google | ||
$googleUser = Socialite::driver('google')->user(); | ||
|
||
Log::info('Usuario de Google obtenido', [ | ||
'email' => $googleUser->getEmail(), | ||
'name' => $googleUser->getName(), | ||
]); | ||
|
||
// Buscar o crear un usuario en tu base de datos | ||
$authUser = User::firstOrCreate( | ||
['email' => $googleUser->getEmail()], | ||
[ | ||
'name' => $googleUser->getName(), | ||
'google_id' => $googleUser->getId(), // Guarda el google_id | ||
'lastname' => 'Apellidos por defecto', // Asegúrate de que este campo exista | ||
'password' => 'sadsadasd', // Generar una contraseña aleatoria | ||
'phone_number' => 'Número por defecto', // Asegúrate de que este campo exista | ||
'document' => uniqid(), // O una lógica para generar un documento único | ||
'document_type' => 'CC', // Asegúrate de que este campo exista | ||
] | ||
); | ||
|
||
Log::info('Usuario autenticado o creado', [ | ||
'authUser' => $authUser, | ||
]); | ||
|
||
// Iniciar sesión con el usuario autenticado | ||
Auth::login($authUser, true); | ||
|
||
// Redirigir a la página deseada | ||
return redirect()->route('dashboard'); // Cambia a la ruta que desees | ||
} catch (\Exception $e) { | ||
// Registra el error | ||
Log::error('Error en la autenticación de Google: ' . $e); | ||
return redirect('/')->with('error', 'No se pudo iniciar sesión con Google.'); | ||
} | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,83 @@ | ||
<template> | ||
<section :class="['active-raffles my-8', theme.backgroundClass]"> | ||
<h2 :class="['text-2xl font-bold mb-6 text-center', theme.textPrimary]">Rifas Activas</h2> | ||
|
||
<!-- Mensaje si no hay rifas --> | ||
<div v-if="raffles.data.length === 0" :class="theme.textSecondary"> | ||
No hay rifas activas en este momento. | ||
</div> | ||
|
||
<!-- Grid de Rifas (1 fila con 3 cartas) --> | ||
<div v-else class="container mx-auto w-full grid grid-cols-1 md:grid-cols-3 gap-6"> | ||
<RaffleCard | ||
v-for="raffle in raffles.data.slice(0, 3)" | ||
:key="raffle.id" | ||
:raffle="raffle" | ||
/> | ||
</div> | ||
|
||
<!-- Botón para ver todas las rifas --> | ||
<div class="flex justify-center mt-8"> | ||
<button | ||
@click="redirectToRaffles" | ||
:class="[theme.buttonPrimary]" | ||
class="py-2 px-6 rounded-lg hover:scale-105 transition" | ||
> | ||
¡Ver todas las rifas! | ||
</button> | ||
</div> | ||
</section> | ||
</template> | ||
|
||
<script setup> | ||
import { ref, onMounted, computed } from 'vue'; | ||
import { useDarkMode } from '@/composables/useDarkMode'; | ||
import RaffleCard from './RaffleCard.vue'; | ||
const raffles = ref({ data: [] }); | ||
const { isDarkMode } = useDarkMode(); | ||
const theme = computed(() => ({ | ||
backgroundClass: isDarkMode.value | ||
? 'bg-[#1a1a1c] shadow-lg' // Fondo oscuro para Dark Mode | ||
: 'bg-[#F5F5F7] shadow-sm ', // Fondo blanco suave para Light Mode | ||
textPrimary: isDarkMode.value ? 'text-white' : 'text-gray-900', | ||
textSecondary: isDarkMode.value ? 'text-gray-400' : 'text-gray-600', | ||
buttonPrimary: isDarkMode.value | ||
? 'bg-blue-700 text-white hover:bg-blue-800' | ||
: 'bg-blue-600 text-white hover:bg-blue-700', | ||
})); | ||
const redirectToRaffles = () => { | ||
window.location.href = '/rifas-activas'; | ||
}; | ||
const fetchRaffles = async () => { | ||
try { | ||
const response = await fetch('/raffles-actives'); | ||
if (!response.ok) { | ||
throw new Error('Error al obtener las rifas activas'); | ||
} | ||
raffles.value = await response.json(); | ||
} catch (error) { | ||
console.error('Error fetching raffles:', error); | ||
} | ||
}; | ||
onMounted(() => fetchRaffles()); | ||
</script> | ||
|
||
<style scoped> | ||
.active-raffles { | ||
border-radius: 12px; | ||
padding: 1rem; | ||
} | ||
button { | ||
transition: transform 0.2s; | ||
} | ||
button:hover { | ||
transform: scale(1.05); | ||
} | ||
</style> |
Oops, something went wrong.