Skip to content

Commit

Permalink
Added template code for promter code processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Naapperas committed Oct 20, 2024
1 parent b47fdcb commit ef4dca0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
24 changes: 19 additions & 5 deletions app/Http/Controllers/RegisteredUserController.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php

// TODO: if Fortify releases new versions that are interesting to use, we should update this file accordingly.

namespace App\Http\Controllers;

use Illuminate\Auth\Events\Registered;
use Illuminate\Contracts\Auth\StatefulGuard;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Str;
use Inertia\Inertia;
use Laravel\Fortify\Contracts\CreatesNewUsers;
use Laravel\Fortify\Contracts\RegisterResponse;
use Laravel\Fortify\Contracts\RegisterViewResponse;
Expand Down Expand Up @@ -37,15 +39,27 @@ public function __construct(StatefulGuard $guard)
*/
public function create(Request $request)
{

/**
* @var RegisterViewResponse
*/
$response = app(RegisterViewResponse::class);

$promoter = null;
if ($request->is('register/promoter/*')) {
$promoter = $request->route('promoter');

// TODO: store the code somewhere or do something with the promoter code here
// Since we do not want to allow users to edit this code we don't need to send it to the frontend

// One idea is to store the respective promoter in cache (since we already use that) and provide the cache key to the View
// On submission, that same cache key will be used to associate a given promoter with the newly registered participant.
// Additional measures can be taken to ensure this system does not get exploited.

Cookie::queue('', '', 3);
}

// return app(RegisterViewResponse::class);
return Inertia::render('Auth/Register', [
'promoter' => $promoter,
]);
return $response;
}

/**
Expand Down
17 changes: 1 addition & 16 deletions resources/js/Pages/Auth/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ import TextInput from "@/Components/TextInput.vue";
import CardLayout from "../../Layouts/CardLayout.vue";
import route from "ziggy-js";
interface Props {
promoter?: string;
}
const props = defineProps<Props>();
const form = useForm({
name: "",
email: "",
password: "",
password_confirmation: "",
promoter: props.promoter ?? "",
promoter: "",
terms: false,
});
Expand Down Expand Up @@ -72,15 +66,6 @@ const submit = () => {
:error-message="form.errors.password_confirmation"
/>

<TextInput
id="promoter"
v-model="form.promoter"
label="Código de promotor"
type="text"
:disabled="promoter !== null"
:error-message="form.errors.promoter"
/>

<label
v-if="$page.props.jetstream.hasTermsAndPrivacyPolicyFeature"
class="flex items-center gap-2 self-stretch"
Expand Down
2 changes: 2 additions & 0 deletions routes/fortify.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

// TODO: if Fortify releases new versions that are interesting to use, we should update this file accordingly.

use App\Http\Controllers\RegisteredUserController;
use Illuminate\Support\Facades\Route;
use Laravel\Fortify\Features;
Expand Down
2 changes: 2 additions & 0 deletions routes/jetstream.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

// TODO: if Jetstream releases new versions that are interesting to use, we should update this file accordingly.

use Illuminate\Support\Facades\Route;
use Laravel\Jetstream\Http\Controllers\CurrentTeamController;
use Laravel\Jetstream\Http\Controllers\Inertia\ApiTokenController;
Expand Down

0 comments on commit ef4dca0

Please sign in to comment.