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()
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user