From 6b40d7cb1e22b1827480c46ad9bbaf5d03aefc3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofia=20Reh=C3=A1kov=C3=A1?= <125893846+sofiarehakova@users.noreply.github.com> Date: Tue, 4 Nov 2025 15:03:45 +0100 Subject: [PATCH 01/15] vytvorenie subpage company profile --- frontend/app/pages/dashboard/company/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app/pages/dashboard/company/index.vue b/frontend/app/pages/dashboard/company/index.vue index ee77806..56af26a 100644 --- a/frontend/app/pages/dashboard/company/index.vue +++ b/frontend/app/pages/dashboard/company/index.vue @@ -24,7 +24,7 @@ const user = useSanctumUser();
- + Môj profil From dd842be8381713e01243af14969417928e8f15d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofia=20Reh=C3=A1kov=C3=A1?= <125893846+sofiarehakova@users.noreply.github.com> Date: Tue, 4 Nov 2025 15:04:06 +0100 Subject: [PATCH 02/15] =?UTF-8?q?inform=C3=A1cie=20o=20company=20+=20butto?= =?UTF-8?q?n=20na=20zmenu=20hesla?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/dashboard/company/profile/index.vue | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 frontend/app/pages/dashboard/company/profile/index.vue diff --git a/frontend/app/pages/dashboard/company/profile/index.vue b/frontend/app/pages/dashboard/company/profile/index.vue new file mode 100644 index 0000000..d31b09e --- /dev/null +++ b/frontend/app/pages/dashboard/company/profile/index.vue @@ -0,0 +1,128 @@ + + + + + From 63e6dfcc3b3577b84b9a65f89c1e42b5a57c404b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofia=20Reh=C3=A1kov=C3=A1?= <125893846+sofiarehakova@users.noreply.github.com> Date: Tue, 4 Nov 2025 15:17:09 +0100 Subject: [PATCH 03/15] =?UTF-8?q?vytvorenie=20profilu=20=C5=A1tudenta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/app/pages/dashboard/student/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app/pages/dashboard/student/index.vue b/frontend/app/pages/dashboard/student/index.vue index 6536057..61427f3 100644 --- a/frontend/app/pages/dashboard/student/index.vue +++ b/frontend/app/pages/dashboard/student/index.vue @@ -44,7 +44,7 @@ const { data, error } = await useSanctumFetch('/api/internships/my Firmy - + Môj profil From 218fab5f5e351e5c3d4413a2dbff6b93119598b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofia=20Reh=C3=A1kov=C3=A1?= <125893846+sofiarehakova@users.noreply.github.com> Date: Tue, 4 Nov 2025 15:27:29 +0100 Subject: [PATCH 04/15] upravy --- .../pages/dashboard/company/profile/index.vue | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/frontend/app/pages/dashboard/company/profile/index.vue b/frontend/app/pages/dashboard/company/profile/index.vue index d31b09e..8277f17 100644 --- a/frontend/app/pages/dashboard/company/profile/index.vue +++ b/frontend/app/pages/dashboard/company/profile/index.vue @@ -78,7 +78,7 @@ const user = useSanctumUser(); - + Zmeniť heslo @@ -97,12 +97,14 @@ const user = useSanctumUser(); From eb122c41ab1be5514412b53429d1b8f3d365cff6 Mon Sep 17 00:00:00 2001 From: Andrej Date: Tue, 4 Nov 2025 17:26:31 +0100 Subject: [PATCH 07/15] pridanie atributov pouzivatelovi pre aktivaciu uctu --- backend/app/Models/User.php | 6 ++++++ backend/database/factories/UserFactory.php | 2 ++ .../migrations/0001_01_01_000000_create_users_table.php | 3 +++ 3 files changed, 11 insertions(+) diff --git a/backend/app/Models/User.php b/backend/app/Models/User.php index de3bb49..c80bbdc 100644 --- a/backend/app/Models/User.php +++ b/backend/app/Models/User.php @@ -25,6 +25,9 @@ class User extends Authenticatable 'email', 'role', 'password', + 'active', + 'needs_password_change', + 'activation_token', ]; /** @@ -35,6 +38,7 @@ class User extends Authenticatable protected $hidden = [ 'password', 'remember_token', + 'activation_token', ]; /** @@ -47,6 +51,8 @@ class User extends Authenticatable return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', + 'active' => 'boolean', + 'needs_password_change' => 'boolean' ]; } diff --git a/backend/database/factories/UserFactory.php b/backend/database/factories/UserFactory.php index 39a6cef..fdbf6e3 100644 --- a/backend/database/factories/UserFactory.php +++ b/backend/database/factories/UserFactory.php @@ -36,6 +36,8 @@ class UserFactory extends Factory 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), 'remember_token' => Str::random(10), + 'active' => true, + 'needs_password_change' => false, ]; } diff --git a/backend/database/migrations/0001_01_01_000000_create_users_table.php b/backend/database/migrations/0001_01_01_000000_create_users_table.php index 05fb5d9..9004abd 100644 --- a/backend/database/migrations/0001_01_01_000000_create_users_table.php +++ b/backend/database/migrations/0001_01_01_000000_create_users_table.php @@ -17,6 +17,9 @@ return new class extends Migration $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); + $table->boolean('active')->default(false); + $table->boolean('needs_password_change')->default(false); + $table->string('activation_token')->nullable(); $table->rememberToken(); $table->timestamps(); }); From 3f2d2c6438f671601fcaa3fe05b71618128f5048 Mon Sep 17 00:00:00 2001 From: Andrej Date: Tue, 4 Nov 2025 17:27:08 +0100 Subject: [PATCH 08/15] overenie aktivneho uctu pri prihlasovani --- backend/app/Http/Requests/Auth/LoginRequest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/app/Http/Requests/Auth/LoginRequest.php b/backend/app/Http/Requests/Auth/LoginRequest.php index f5692bf..c99dde2 100644 --- a/backend/app/Http/Requests/Auth/LoginRequest.php +++ b/backend/app/Http/Requests/Auth/LoginRequest.php @@ -49,6 +49,15 @@ class LoginRequest extends FormRequest ]); } + // Check if the authenticated user's account is active + if (! Auth::user()->active) { + Auth::logout(); + + throw ValidationException::withMessages([ + 'email' => __('auth.inactive_account'), + ]); + } + RateLimiter::clear($this->throttleKey()); } From 7feba39bc93bac8bc67d39c3b934090d098c53b8 Mon Sep 17 00:00:00 2001 From: Andrej Date: Tue, 4 Nov 2025 17:27:44 +0100 Subject: [PATCH 09/15] emaily na aktivaciu uctu --- backend/app/Mail/UserAccountActivated.php | 58 +++++++++++++++++++ .../app/Mail/UserRegistrationCompleted.php | 8 +-- .../views/mail/activation/completed.blade.php | 8 +++ .../mail/registration/completed.blade.php | 7 ++- 4 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 backend/app/Mail/UserAccountActivated.php create mode 100644 backend/resources/views/mail/activation/completed.blade.php diff --git a/backend/app/Mail/UserAccountActivated.php b/backend/app/Mail/UserAccountActivated.php new file mode 100644 index 0000000..a60ba9c --- /dev/null +++ b/backend/app/Mail/UserAccountActivated.php @@ -0,0 +1,58 @@ +name = $name; + } + + /** + * Get the message envelope. + */ + public function envelope(): Envelope + { + return new Envelope( + subject: 'User Account Activated', + ); + } + + /** + * Get the message content definition. + */ + public function content(): Content + { + return new Content( + view: 'mail.activation.completed', + with: [ + "name" => $this->name, + ] + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} diff --git a/backend/app/Mail/UserRegistrationCompleted.php b/backend/app/Mail/UserRegistrationCompleted.php index f4c6a57..523343d 100644 --- a/backend/app/Mail/UserRegistrationCompleted.php +++ b/backend/app/Mail/UserRegistrationCompleted.php @@ -14,15 +14,15 @@ class UserRegistrationCompleted extends Mailable use Queueable, SerializesModels; private string $name; - private string $password; + private string $activation_token; /** * Create a new message instance. */ - public function __construct(string $name, string $password) + public function __construct(string $name, string $activation_token) { $this->name = $name; - $this->password = $password; + $this->activation_token = $activation_token; } /** @@ -44,7 +44,7 @@ class UserRegistrationCompleted extends Mailable view: 'mail.registration.completed', with: [ "name" => $this->name, - "password" => $this->password + "activation_token" => $this->activation_token ] ); } diff --git a/backend/resources/views/mail/activation/completed.blade.php b/backend/resources/views/mail/activation/completed.blade.php new file mode 100644 index 0000000..d6212b4 --- /dev/null +++ b/backend/resources/views/mail/activation/completed.blade.php @@ -0,0 +1,8 @@ +@include("parts.header") +

Vážená/ý {{ $name }},

+

úspešne ste aktivovali váš účet!

+
+ +

s pozdravom

+

Systém ISOP UKF

+@include("parts.footer") \ No newline at end of file diff --git a/backend/resources/views/mail/registration/completed.blade.php b/backend/resources/views/mail/registration/completed.blade.php index a712bc7..b35e6f6 100644 --- a/backend/resources/views/mail/registration/completed.blade.php +++ b/backend/resources/views/mail/registration/completed.blade.php @@ -3,7 +3,12 @@

vaša registrácia do systému ISOP UKF prebehla úspešne!


-

Vaše heslo je: {{ $password }}

+

Aktivujte účet pomocou nasledujúceho linku:

+
+

+ {{ config('app.frontend_url') }}/account/activation/{{ $activation_token }} +


From fcf5ca373bfe1f419427011edfc1b2273242aa65 Mon Sep 17 00:00:00 2001 From: Andrej Date: Tue, 4 Nov 2025 17:28:27 +0100 Subject: [PATCH 10/15] pridanie API na aktivaciu uctu --- .../Auth/RegisteredUserController.php | 26 ++++++++++++++++++- backend/routes/api.php | 4 +++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/backend/app/Http/Controllers/Auth/RegisteredUserController.php b/backend/app/Http/Controllers/Auth/RegisteredUserController.php index 00d2649..6b5937a 100644 --- a/backend/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/backend/app/Http/Controllers/Auth/RegisteredUserController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Mail\UserAccountActivated; use App\Mail\UserPasswordReset; use App\Mail\UserRegistrationCompleted; use App\Models\Company; @@ -25,6 +26,7 @@ class RegisteredUserController extends Controller public function store(Request $request): Response { $password = bin2hex(random_bytes(16)); + $activation_token = bin2hex(random_bytes(16)); $request->validate([ 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:' . User::class], @@ -58,6 +60,7 @@ class RegisteredUserController extends Controller 'phone' => $request->phone, 'role' => $request->role, 'password' => Hash::make($password), + 'activation_token' => $activation_token ]); if ($user->role === "STUDENT") { @@ -83,12 +86,33 @@ class RegisteredUserController extends Controller throw $e; } - Mail::to($user)->sendNow(new UserRegistrationCompleted($user->name, $password)); + Mail::to($user)->sendNow(new UserRegistrationCompleted($user->name, $activation_token)); event(new Registered($user)); return response()->noContent(); } + public function activate(Request $request) { + $request->validate([ + 'token' => ['required', 'string', 'exists:users,activation_token'], + 'password' => ['required', 'string', 'min:8'], + ]); + + $user = User::where('activation_token', '=', $request->token)->first(); + + if (!$user) { + return response()->json(['message' => 'Invalid activation token'], 400); + } + + $user->active = true; + $user->activation_token = null; + $user->password = Hash::make($request->password); + $user->save(); + + Mail::to($user)->sendNow(new UserAccountActivated($user->name)); + return response()->noContent(); + } + public function reset_password(Request $request): Response { $request->validate([ diff --git a/backend/routes/api.php b/backend/routes/api.php index 3190b4d..ccae435 100644 --- a/backend/routes/api.php +++ b/backend/routes/api.php @@ -22,6 +22,10 @@ Route::middleware(['auth:sanctum'])->get('/user', function (Request $request) { return $user; }); +Route::prefix('/account')->group(function () { + Route::post("/activate", [RegisteredUserController::class, 'activate']); +}); + Route::middleware(['auth:sanctum'])->prefix('/students')->group(function () { Route::get('/', [StudentDataController::class, 'all']); Route::get('/{id}', [StudentDataController::class, 'get']); From 8ffac4975afb1b36501ce47bf947a65733e236cf Mon Sep 17 00:00:00 2001 From: Andrej Date: Tue, 4 Nov 2025 17:28:42 +0100 Subject: [PATCH 11/15] pridanie stranky na aktivaciu uctu --- .../app/pages/account/activation/[token].vue | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 frontend/app/pages/account/activation/[token].vue diff --git a/frontend/app/pages/account/activation/[token].vue b/frontend/app/pages/account/activation/[token].vue new file mode 100644 index 0000000..b7e09c5 --- /dev/null +++ b/frontend/app/pages/account/activation/[token].vue @@ -0,0 +1,138 @@ + + + + + From eeac19799dd906ea5b538dd0e22a870957e4ced2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofia=20Reh=C3=A1kov=C3=A1?= <125893846+sofiarehakova@users.noreply.github.com> Date: Tue, 4 Nov 2025 18:09:48 +0100 Subject: [PATCH 12/15] pridanie tlacitka "moj profil" pre admina --- frontend/app/pages/dashboard/admin/index.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/app/pages/dashboard/admin/index.vue b/frontend/app/pages/dashboard/admin/index.vue index 1fbfcc2..f8019d0 100644 --- a/frontend/app/pages/dashboard/admin/index.vue +++ b/frontend/app/pages/dashboard/admin/index.vue @@ -32,6 +32,9 @@ const user = useSanctumUser(); Praxe + + Môj profil +
From fedbb047280ddf8b82699546f106cff7c598a5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofia=20Reh=C3=A1kov=C3=A1?= <125893846+sofiarehakova@users.noreply.github.com> Date: Tue, 4 Nov 2025 18:10:11 +0100 Subject: [PATCH 13/15] presunutie tlacitka "moj profil" pre firmu --- frontend/app/pages/dashboard/company/index.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/app/pages/dashboard/company/index.vue b/frontend/app/pages/dashboard/company/index.vue index 56af26a..cb064d3 100644 --- a/frontend/app/pages/dashboard/company/index.vue +++ b/frontend/app/pages/dashboard/company/index.vue @@ -24,12 +24,12 @@ const user = useSanctumUser();
- - Môj profil - Praxe + + Môj profil +
From d41df106e4d58b0dd3760a8a60cffe92deecf507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofia=20Reh=C3=A1kov=C3=A1?= <125893846+sofiarehakova@users.noreply.github.com> Date: Tue, 4 Nov 2025 18:10:39 +0100 Subject: [PATCH 14/15] upravenie cesty tlacitka "moj profil" pre studenta --- frontend/app/pages/dashboard/student/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app/pages/dashboard/student/index.vue b/frontend/app/pages/dashboard/student/index.vue index 7388f91..b4f36f9 100644 --- a/frontend/app/pages/dashboard/student/index.vue +++ b/frontend/app/pages/dashboard/student/index.vue @@ -44,7 +44,7 @@ const { data, error } = await useSanctumFetch('/api/internships/my Firmy - + Môj profil From d5ccbd2df9602587bb3ed07e0abc9156e3d272ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sofia=20Reh=C3=A1kov=C3=A1?= <125893846+sofiarehakova@users.noreply.github.com> Date: Tue, 4 Nov 2025 18:10:56 +0100 Subject: [PATCH 15/15] presunutie profilovej stranky --- frontend/app/pages/account/index.vue | 118 +++++++++++++++++ .../pages/dashboard/student/profile/index.vue | 124 ------------------ 2 files changed, 118 insertions(+), 124 deletions(-) create mode 100644 frontend/app/pages/account/index.vue delete mode 100644 frontend/app/pages/dashboard/student/profile/index.vue diff --git a/frontend/app/pages/account/index.vue b/frontend/app/pages/account/index.vue new file mode 100644 index 0000000..1da7911 --- /dev/null +++ b/frontend/app/pages/account/index.vue @@ -0,0 +1,118 @@ + + + + + diff --git a/frontend/app/pages/dashboard/student/profile/index.vue b/frontend/app/pages/dashboard/student/profile/index.vue deleted file mode 100644 index 136a707..0000000 --- a/frontend/app/pages/dashboard/student/profile/index.vue +++ /dev/null @@ -1,124 +0,0 @@ - - - - -