Skip to content

Commit a75b56d

Browse files
committed
feat: redirect on registration if user is already log
Change-Id: I2be026ceca811117c3997dab551320bd6768e071
1 parent 1fd6103 commit a75b56d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Illuminate\Support\Facades\Auth;
1818
use Illuminate\Support\Facades\Config;
1919
use Illuminate\Support\Facades\Log;
20+
use Illuminate\Support\Facades\Redirect;
2021
use Illuminate\Support\Facades\URL;
2122
use Illuminate\Support\Facades\Validator;
2223
use Illuminate\Http\Request as LaravelRequest;
@@ -69,6 +70,27 @@ public function showRegistrationForm(LaravelRequest $request)
6970
{
7071
try {
7172

73+
// if we already logged in ... continue flow
74+
if(Auth::check()){
75+
Log::warning("RegisterController::showRegistrationForm user already logged in, checking if we have a client id");
76+
if ($request->has("redirect_uri") && $request->has("client_id")) {
77+
$redirect_uri = $request->get("redirect_uri");
78+
$client_id = $request->get("client_id");
79+
Log::debug(sprintf("RegisterController::showRegistrationForm redirect_uri %s client_id %s", $redirect_uri, $client_id));
80+
$client = $this->client_repository->getClientById($client_id);
81+
if (is_null($client))
82+
throw new ValidationException("Client does not exists.");
83+
84+
if (!$client->isUriAllowed($redirect_uri))
85+
throw new ValidationException(sprintf("redirect_uri %s is not allowed on associated client.", $redirect_uri));
86+
87+
Log::debug(sprintf("RegisterController::showRegistrationForm redirect_uri %s client_id %s redirecting", $redirect_uri, $client_id));
88+
return Redirect::to($redirect_uri);
89+
}
90+
Log::debug("RegisterController::showRegistrationForm redirecting to home page");
91+
return Redirect::to('/');
92+
}
93+
7294
$params = [
7395
"redirect_uri" => '',
7496
"email" => '',

0 commit comments

Comments
 (0)