Skip to content

Commit

Permalink
added validation monicahq#7359
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyashrpawar committed Oct 10, 2024
1 parent b1802b4 commit 08f9a8c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/Actions/AttemptToAuthenticateSocialite.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ private function getUserOrCreate(SocialiteUser $socialite): User
private function createUser(SocialiteUser $socialite): User
{
$names = Str::of($socialite->getName())->split('/ /', 2);
$names = Str::of($socialite->getName())->split('/ /', 2);

$firstName = addslashes($names[0]);
$lastName = addslashes($names[1] ?? $names[0]);
$data = [
'email' => $socialite->getEmail(),
'first_name' => $names[0],
'last_name' => $names[1] ?? $names[0],
'first_name' => $firstName,
'last_name' => $lastName,
'terms' => true,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ public function create(Request $request, string $vaultId, string $contactId)

public function store(Request $request, string $vaultId, string $contactId)
{

$request->validate([
'first_name' => 'required|string|max:255',
'last_name' => 'nullable|string|max:255',
'middle_name' => 'nullable|string|max:255',
'nickname' => 'nullable|string|max:255',
'maiden_name' => 'nullable|string|max:255',
'gender_id' => 'nullable|integer|exists:genders,id', // Assuming gender_id refers to a foreign key
'pronoun_id' => 'nullable|integer|exists:pronouns,id', // Assuming pronoun_id refers to a foreign key
'relationship_type_id' => 'required|integer|exists:relationship_types,id', // Assuming relationship_type_id refers to a foreign key
'create_contact_entry' => 'nullable|boolean',
'base_contact_id' => 'required|integer|exists:contacts,id',
'other_contact_id' => 'nullable|array', // Assuming multiple contacts might be selected
'other_contact_id.*' => 'integer|exists:contacts,id', // Validating each contact ID
]);
// This is a complex controller method, sorry about that, future reader
// It's complex because the form is really complex and can lead to
// many different scenarios
Expand Down

0 comments on commit 08f9a8c

Please sign in to comment.