|
17 | 17 | use Illuminate\Support\Facades\Auth; |
18 | 18 | use Illuminate\Support\Facades\Config; |
19 | 19 | use Illuminate\Support\Facades\Log; |
| 20 | +use Illuminate\Support\Facades\Redirect; |
20 | 21 | use Illuminate\Support\Facades\URL; |
21 | 22 | use Illuminate\Support\Facades\Validator; |
22 | 23 | use Illuminate\Http\Request as LaravelRequest; |
@@ -69,6 +70,27 @@ public function showRegistrationForm(LaravelRequest $request) |
69 | 70 | { |
70 | 71 | try { |
71 | 72 |
|
| 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 | + |
72 | 94 | $params = [ |
73 | 95 | "redirect_uri" => '', |
74 | 96 | "email" => '', |
|
0 commit comments