Skip to content

Commit

Permalink
User invites
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1DEA committed Sep 8, 2023
1 parent 91870d0 commit b0db29e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app/Http/Controllers/System/Auth/RegisteredUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public function __construct(StatefulGuard $guard)
*/
public function create(): Response
{
return Inertia::render('Auth/Register');
return Inertia::render('Auth/Register', [
'invite' => request('invite')
]);
}

/**
Expand All @@ -65,6 +67,7 @@ public function store(Request $request): JsonResponse|RedirectResponse
'name' => ['required', 'string', 'min:3', 'max:32', 'unique:users', 'regex:/^[a-zA-Z0-9_]*$/'],
'password' => Yggdrasil::passwordRules(),
'terms' => ['required', 'accepted'],
'agecheck' => ['required', 'accepted'],
],
[
'name.regex' => 'Usernames must be alphanumeric (no spaces or symbols except underscores)',
Expand All @@ -74,10 +77,11 @@ public function store(Request $request): JsonResponse|RedirectResponse
'email' => request('email'),
'name' => request('name'),
'password' => Hash::make(request('password')),
'referrer_id' => request('invite'),
]);

$banned_ids = [
42, 69, 420, 666, 777, 1312, 1488, 1337, 2865,
42, 44, 50, 69, 314, 420, 666, 777, 1312, 1488, 1337, 2865,
];

while (in_array($user->id, $banned_ids, false)) {
Expand Down
4 changes: 4 additions & 0 deletions app/Models/System/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class User extends Authenticatable
'name',
'email',
'password',
'referrer_id',
];

/**
Expand All @@ -45,6 +46,9 @@ class User extends Authenticatable
'password',
'remember_token',
'email',
'referrer_id',
'location',
'birthday',
];

/**
Expand Down
7 changes: 6 additions & 1 deletion resources/js/Pages/Auth/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import JetLabel from '@/Jetstream/Label.vue';
import JetValidationErrors from '@/Jetstream/ValidationErrors.vue';
import route from 'ziggy-js'
const props = defineProps({
invite: String
})
const form = useForm({
name: '',
email: '',
password: '',
password_confirmation: '',
invite: props.invite ?? null,
terms: false,
agecheck: false,
});
Expand All @@ -36,7 +41,7 @@ const submit = () => {
</template>

<JetValidationErrors class="mb-4" />

{{form}}
<form @submit.prevent="submit">
<div>
<JetLabel for="name" value="Username" />
Expand Down

0 comments on commit b0db29e

Please sign in to comment.