forked from magonysandormate/PeePal
Kész(?)
This commit is contained in:
@@ -35,7 +35,7 @@ class AuthController extends Controller
|
||||
'nev' => $request->nev,
|
||||
'email' => $request->email,
|
||||
'felh_nev' => $request->felh_nev,
|
||||
'jelszo' => $request->jelszo, // This will be hashed via the mutator
|
||||
'jelszo' => $request->jelszo,
|
||||
'is_admin' => $request->is_admin ?? false
|
||||
]);
|
||||
|
||||
@@ -56,10 +56,9 @@ class AuthController extends Controller
|
||||
return response()->json($validator->errors(), 422);
|
||||
}
|
||||
|
||||
// Since your login fields are custom, you need to specify the fields
|
||||
$credentials = [
|
||||
'felh_nev' => $request->felh_nev,
|
||||
'password' => $request->jelszo // Laravel expects 'password' internally
|
||||
'password' => $request->jelszo
|
||||
];
|
||||
|
||||
if (!$token = auth('api')->attempt($credentials)) {
|
||||
@@ -96,7 +95,7 @@ class AuthController extends Controller
|
||||
return response()->json([
|
||||
'access_token' => $token,
|
||||
'token_type' => 'bearer',
|
||||
'expires_in' => config('jwt.ttl') * 60, // Getting TTL from config
|
||||
'expires_in' => config('jwt.ttl') * 60,
|
||||
'user' => auth('api')->user()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\WcAdatok;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HozzaadasController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validatedData = $request -> validate([
|
||||
'nev' => 'required|string',
|
||||
'kerulet' => 'required|string',
|
||||
'kozeli_megall' => 'required|string',
|
||||
'akadalym' => 'nullable|boolean',
|
||||
'ar' => 'nullable|numeric',
|
||||
'nyitva' => 'nullable|string',
|
||||
'utvonal' => 'required|string',
|
||||
'koordinatak' => 'required|string'
|
||||
]);
|
||||
|
||||
try {
|
||||
$szelesseg = null;
|
||||
$hosszusag = null;
|
||||
|
||||
if (!empty($validatedData['koordinatak'])) {
|
||||
$koordinatak = explode(',', $validatedData['koordinatak']);
|
||||
|
||||
if (count($koordinatak) == 2) {
|
||||
$hosszusag = trim($koordinatak[0]);
|
||||
$szelesseg = trim($koordinatak[1]);
|
||||
|
||||
if (!is_numeric($szelesseg) || !is_numeric($hosszusag)) {
|
||||
return response() -> json([
|
||||
'message' => 'Érvénytelen a koordináták formátuma'
|
||||
], 422);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$mosdo = WcAdatok::create([
|
||||
'nev' => $validatedData['nev'],
|
||||
'kerulet' => $validatedData['kerulet'],
|
||||
'kozeli_megall' => $validatedData['kozeli_megall'],
|
||||
'akadalym' => $validatedData['akadalym'],
|
||||
'ar' => $validatedData['ar'],
|
||||
'nyitva' => $validatedData['nyitva'],
|
||||
'utvonal' => $validatedData['utvonal'],
|
||||
'szel_koord' => $szelesseg,
|
||||
'hossz_koord' => $hosszusag
|
||||
]);
|
||||
|
||||
return response() -> json([
|
||||
'message' => 'Sikeres rögzítés',
|
||||
'data' => $mosdo
|
||||
], 201);
|
||||
} catch (\Exception $e) {
|
||||
return response() -> json([
|
||||
'message' => 'Hiba történt a mentés során',
|
||||
'error' => $e -> getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -8,17 +8,6 @@ use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
@@ -34,7 +23,7 @@ class UserController extends Controller
|
||||
'nev' => $validatedData['nev'],
|
||||
'email' => $validatedData['email'],
|
||||
'felh_nev' => $validatedData['felh_nev'],
|
||||
'jelszo' => $validatedData['jelszo'], // Will be hashed by mutator
|
||||
'jelszo' => $validatedData['jelszo'],
|
||||
'is_admin' => $validatedData['is_admin'] ?? false
|
||||
]);
|
||||
|
||||
@@ -49,28 +38,4 @@ class UserController extends Controller
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,4 @@ class WcController extends Controller
|
||||
return response()->json(['message' => 'Nem található'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ class User extends Authenticatable implements JWTSubject
|
||||
return [];
|
||||
}
|
||||
|
||||
// Change to match your migration
|
||||
protected $table = 'felhasznalok';
|
||||
|
||||
protected $fillable = [
|
||||
@@ -43,13 +42,11 @@ class User extends Authenticatable implements JWTSubject
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
// This method tells Laravel to use jelszo field for passwords
|
||||
public function getAuthPassword()
|
||||
{
|
||||
return $this->jelszo;
|
||||
}
|
||||
|
||||
// Fix this to use 'jelszo' instead of 'password'
|
||||
public function setJelszoAttribute($value)
|
||||
{
|
||||
$this->attributes['jelszo'] = \Illuminate\Support\Facades\Hash::make($value);
|
||||
|
||||
@@ -6,9 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('keruletek', function (Blueprint $t) {
|
||||
@@ -42,11 +39,10 @@ return new class extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
Schema::dropIfExists('keruletek');
|
||||
Schema::dropIfExists('felhasznalok');
|
||||
Schema::dropIfExists('wc_adatok');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,9 +8,6 @@ use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this -> call([
|
||||
|
||||
@@ -14,14 +14,22 @@ class FelhasznaloFeltoltes extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
DB::table('felhasznalok')->insert([
|
||||
'nev' => 'Magony Sándor',
|
||||
'email' => 'magonys2006@gmail.com',
|
||||
DB::table('felhasznalok')->insert([[
|
||||
'nev' => 'Admin',
|
||||
'email' => 'admin@gmail.com',
|
||||
'felh_nev' => 'admin',
|
||||
'jelszo' => Hash::make('admin'),
|
||||
'is_admin' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
]);
|
||||
], [
|
||||
'nev' => 'Felhasználó',
|
||||
'email' => 'felhasznalo@gmail.com',
|
||||
'felh_nev' => 'felhaszalo',
|
||||
'jelszo' => Hash::make('felhasznalo'),
|
||||
'is_admin' => false,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now()
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { useAuth } from './AuthContext'; // Update this path
|
||||
import { useAuth } from './AuthContext';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export default function Regisztracio() {
|
||||
@@ -43,9 +43,8 @@ export default function Regisztracio() {
|
||||
|
||||
const result = await register(formData);
|
||||
if (result.success) {
|
||||
navigate('/bejelentkezes'); // Navigate to login page after successful registration
|
||||
navigate('/bejelentkezes');
|
||||
} else if (result.errors) {
|
||||
// Format Laravel validation errors
|
||||
const serverErrors = {};
|
||||
for (const key in result.errors) {
|
||||
if (Array.isArray(result.errors[key])) {
|
||||
|
||||
@@ -34,7 +34,6 @@ export default function Csempe() {
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
// Sikeres törlés után szűrd ki az adott elemet a state-ből
|
||||
setMosdok(prev => prev.filter(m => m.id !== mosdoId));
|
||||
} else {
|
||||
console.error("Törlés sikertelen");
|
||||
|
||||
@@ -29,7 +29,7 @@ describe('Csempe komponens', () => {
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
fetch.resetMocks?.(); // ha használsz jest-fetch-mock-ot
|
||||
fetch.resetMocks?.();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
@@ -68,9 +68,9 @@ describe('Csempe komponens', () => {
|
||||
|
||||
test('Betöltés alatt megjelenik spinner', async () => {
|
||||
useAuth.mockReturnValue({ user: { is_admin: true } });
|
||||
fetchModule.mosdokFetch.mockImplementation(() => new Promise(() => {})); // never resolves
|
||||
fetchModule.mosdokFetch.mockImplementation(() => new Promise(() => {}));
|
||||
|
||||
render(<Csempe />);
|
||||
expect(screen.getByRole('status')).toBeInTheDocument(); // a spinner div-ben legyen pl. role="status"
|
||||
expect(screen.getByRole('status')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,7 +17,6 @@ export default function HozzaadForm() {
|
||||
const handleSubmit = async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
// Validáció: egyszerű kötelező mező ellenőrzések
|
||||
const newErrors = {};
|
||||
if (!nev.trim()) newErrors.nev = "A név megadása kötelező.";
|
||||
if (!kerulet_id) newErrors.kerulet_id = "Kerület kiválasztása kötelező.";
|
||||
|
||||
@@ -2,11 +2,10 @@ import React, { useState } from 'react';
|
||||
import { TfiWheelchair } from "react-icons/tfi";
|
||||
import { mosdokFetch } from '../../apiFetch';
|
||||
|
||||
// Egyszerű koordináta-alapú távolság (nincs konverzió km-re)
|
||||
const calculateDistance = (lat1, lon1, lat2, lon2) => {
|
||||
const dx = lat1 - lat2;
|
||||
const dy = lon1 - lon2;
|
||||
return dx * dx + dy * dy; // távolság négyzete (nem baj, hogy nincs gyök alatt)
|
||||
return dx * dx + dy * dy;
|
||||
};
|
||||
|
||||
export default function LegkozelebbiMosdo() {
|
||||
|
||||
Reference in New Issue
Block a user