diff --git a/thanasoft-back/app/Models/User.php b/thanasoft-back/app/Models/User.php index 749c7b7..91135d7 100644 --- a/thanasoft-back/app/Models/User.php +++ b/thanasoft-back/app/Models/User.php @@ -6,11 +6,12 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { /** @use HasFactory<\Database\Factories\UserFactory> */ - use HasFactory, Notifiable; + use HasApiTokens, HasFactory, Notifiable; /** * The attributes that are mass assignable. diff --git a/thanasoft-back/bootstrap/app.php b/thanasoft-back/bootstrap/app.php index c183276..c3928c5 100644 --- a/thanasoft-back/bootstrap/app.php +++ b/thanasoft-back/bootstrap/app.php @@ -7,6 +7,7 @@ use Illuminate\Foundation\Configuration\Middleware; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: __DIR__.'/../routes/web.php', + api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) diff --git a/thanasoft-back/composer.json b/thanasoft-back/composer.json index 9089a07..34284d9 100644 --- a/thanasoft-back/composer.json +++ b/thanasoft-back/composer.json @@ -11,6 +11,7 @@ "require": { "php": "^8.2", "laravel/framework": "^12.0", + "laravel/sanctum": "^4.2", "laravel/tinker": "^2.10.1" }, "require-dev": { @@ -75,4 +76,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} diff --git a/thanasoft-back/composer.lock b/thanasoft-back/composer.lock index 89a6721..3089aab 100644 --- a/thanasoft-back/composer.lock +++ b/thanasoft-back/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c514d8f7b9fc5970bdd94287905ef584", + "content-hash": "8f387a0734f3bf879214e4aa2fca6e2f", "packages": [ { "name": "brick/math", @@ -1332,6 +1332,70 @@ }, "time": "2025-09-19T13:47:56+00:00" }, + { + "name": "laravel/sanctum", + "version": "v4.2.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/sanctum.git", + "reference": "fd6df4f79f48a72992e8d29a9c0ee25422a0d677" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/sanctum/zipball/fd6df4f79f48a72992e8d29a9c0ee25422a0d677", + "reference": "fd6df4f79f48a72992e8d29a9c0ee25422a0d677", + "shasum": "" + }, + "require": { + "ext-json": "*", + "illuminate/console": "^11.0|^12.0", + "illuminate/contracts": "^11.0|^12.0", + "illuminate/database": "^11.0|^12.0", + "illuminate/support": "^11.0|^12.0", + "php": "^8.2", + "symfony/console": "^7.0" + }, + "require-dev": { + "mockery/mockery": "^1.6", + "orchestra/testbench": "^9.0|^10.0", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^11.3" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Laravel\\Sanctum\\SanctumServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Sanctum\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.", + "keywords": [ + "auth", + "laravel", + "sanctum" + ], + "support": { + "issues": "https://github.com/laravel/sanctum/issues", + "source": "https://github.com/laravel/sanctum" + }, + "time": "2025-07-09T19:45:24+00:00" + }, { "name": "laravel/serializable-closure", "version": "v2.0.5", diff --git a/thanasoft-back/config/cors.php b/thanasoft-back/config/cors.php new file mode 100644 index 0000000..97f424a --- /dev/null +++ b/thanasoft-back/config/cors.php @@ -0,0 +1,28 @@ + ['api/*', 'sanctum/csrf-cookie'], + + // Allow all HTTP methods for simplicity in dev + 'allowed_methods' => ['*'], + + // IMPORTANT: Do NOT use '*' when sending credentials. List explicit origins. + // Set FRONTEND_URL in .env to override the default if needed. + 'allowed_origins' => [env('FRONTEND_URL', 'http://localhost:8080')], + + // Alternatively, use patterns (kept empty for clarity) + 'allowed_origins_patterns' => [], + + // Headers the client may send + 'allowed_headers' => ['*'], + + // Headers exposed to the browser + 'exposed_headers' => [], + + // Preflight cache duration (in seconds) + 'max_age' => 0, + + // Must be true if the browser sends cookies or Authorization with withCredentials + 'supports_credentials' => true, +]; diff --git a/thanasoft-back/database/migrations/2025_10_06_145345_create_personal_access_tokens_table.php b/thanasoft-back/database/migrations/2025_10_06_145345_create_personal_access_tokens_table.php new file mode 100644 index 0000000..40ff706 --- /dev/null +++ b/thanasoft-back/database/migrations/2025_10_06_145345_create_personal_access_tokens_table.php @@ -0,0 +1,33 @@ +id(); + $table->morphs('tokenable'); + $table->text('name'); + $table->string('token', 64)->unique(); + $table->text('abilities')->nullable(); + $table->timestamp('last_used_at')->nullable(); + $table->timestamp('expires_at')->nullable()->index(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('personal_access_tokens'); + } +}; diff --git a/thanasoft-back/routes/api.php b/thanasoft-back/routes/api.php index 0fe4136..62d4673 100644 --- a/thanasoft-back/routes/api.php +++ b/thanasoft-back/routes/api.php @@ -19,6 +19,8 @@ Route::prefix('auth')->group(function () { Route::middleware('auth:sanctum')->group(function () { Route::get('/me', [AuthController::class, 'me']); + // Alias to support clients calling /api/auth/user + Route::get('/user', [AuthController::class, 'me']); Route::post('/logout', [AuthController::class, 'logout']); Route::post('/logout-all', [AuthController::class, 'logoutAll']); }); diff --git a/thanasoft-front/.env b/thanasoft-front/.env index bc9086d..18d6ec6 100644 --- a/thanasoft-front/.env +++ b/thanasoft-front/.env @@ -1 +1,3 @@ -NODE_ENV= \ No newline at end of file +# API base URL for axios (used by src/services/http.ts) +# For Laravel Sanctum on local dev (default Laravel port): +VUE_APP_API_BASE_URL=http://localhost:8000 diff --git a/thanasoft-front/.eslintignore b/thanasoft-front/.eslintignore deleted file mode 100644 index f2c1f41..0000000 --- a/thanasoft-front/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -dist/ -node_modules/ -public/ diff --git a/thanasoft-front/.eslintrc.js b/thanasoft-front/.eslintrc.js index d9f53ce..1a4cb3a 100644 --- a/thanasoft-front/.eslintrc.js +++ b/thanasoft-front/.eslintrc.js @@ -1,19 +1,47 @@ module.exports = { root: true, + env: { - node: true, browser: true, + node: true, es6: true, }, + extends: [ - 'plugin:vue/vue3-essential', - '@vue/prettier', + "eslint:recommended", + "plugin:vue/vue3-recommended", + "@vue/typescript", + "@vue/prettier", ], + parserOptions: { - parser: 'babel-eslint', + parser: "@typescript-eslint/parser", + ecmaVersion: 2020, + sourceType: "module", }, + rules: { - 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', - 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', + // Relax console/debugger in development + "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", + "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", + }, + + ignorePatterns: [ + "node_modules/", + "dist/", + "public/*.min.js", + "public/**/*.min.js", + ], + + // Disable base no-unused-vars in .vue files to avoid false positives with + diff --git a/thanasoft-front/src/App.vue b/thanasoft-front/src/App.vue index 91db55e..d6f8de6 100644 --- a/thanasoft-front/src/App.vue +++ b/thanasoft-front/src/App.vue @@ -1,26 +1,34 @@ + + + diff --git a/thanasoft-front/src/components/Organism/LoginPresentation.vue b/thanasoft-front/src/components/Organism/LoginPresentation.vue new file mode 100644 index 0000000..81835f7 --- /dev/null +++ b/thanasoft-front/src/components/Organism/LoginPresentation.vue @@ -0,0 +1,15 @@ + + diff --git a/thanasoft-front/src/components/molecules/auth/LoginForm.vue b/thanasoft-front/src/components/molecules/auth/LoginForm.vue new file mode 100644 index 0000000..eb5358e --- /dev/null +++ b/thanasoft-front/src/components/molecules/auth/LoginForm.vue @@ -0,0 +1,115 @@ + + diff --git a/thanasoft-front/src/components/molecules/auth/SocialMedia.buttons.vue b/thanasoft-front/src/components/molecules/auth/SocialMedia.buttons.vue new file mode 100644 index 0000000..946cac9 --- /dev/null +++ b/thanasoft-front/src/components/molecules/auth/SocialMedia.buttons.vue @@ -0,0 +1,67 @@ + diff --git a/thanasoft-front/src/components/templates/LoginTemplate.vue b/thanasoft-front/src/components/templates/LoginTemplate.vue new file mode 100644 index 0000000..4f4b2bb --- /dev/null +++ b/thanasoft-front/src/components/templates/LoginTemplate.vue @@ -0,0 +1,34 @@ + diff --git a/thanasoft-front/src/examples/Navbars/Navbar.vue b/thanasoft-front/src/examples/Navbars/Navbar.vue index ba63587..a1a6e51 100644 --- a/thanasoft-front/src/examples/Navbars/Navbar.vue +++ b/thanasoft-front/src/examples/Navbars/Navbar.vue @@ -55,16 +55,16 @@