Skip to content

Commit

Permalink
Merge pull request #27 from SolidCharity/TP-20200520-fix-external-url…
Browse files Browse the repository at this point in the history
…-redirect

fix for redirects after registering or canceling
  • Loading branch information
tpokorra authored May 20, 2020
2 parents ea0fb21 + 87e2a05 commit 1e77228
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions app/Http/Controllers/FrontendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ public function create()
//
}

function redirect_url($uuid, $tenant_id)
{
$url = '/';
if ($tenant_id != 1)
{
$tenant = \DB::table('tenants')->where('uuid', $uuid)->first();
if (!empty($tenant->external_url))
{
$url = $tenant->external_url.'/';
}
else
{
$url .= '?uuid='.$uuid;
}
}

return redirect($url);
}

/**
* Store a newly created resource in storage.
*
Expand Down Expand Up @@ -160,13 +179,7 @@ public function store(Request $request)
// keep the cookie for a week
setcookie ( 'where2ormore_registration', $participant->cookieid, array('expires'=>time()+60*60*24*7, 'samesite'=>'strict', 'httponly'=>true));

$url = '/';
if ($tenant_id != 1)
{
$url .= '?uuid='.$data['uuid'];
}

return redirect($url);
return $this->redirect_url($data['uuid'], $tenant_id);
}

public function cancelregistration(Request $request)
Expand All @@ -188,13 +201,7 @@ public function cancelregistration(Request $request)
)->delete();
}

$url = '/';
if ($tenant_id != 1)
{
$url .= '?uuid='.$data['uuid'];
}

return redirect($url);
return $this->redirect_url($data['uuid'], $tenant_id);
}

/**
Expand Down

0 comments on commit 1e77228

Please sign in to comment.