Skip to content

Commit 48d15d0

Browse files
authored
Support post routes for redirect (#7)
1 parent 8fb4930 commit 48d15d0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/Facades/Identity.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ public static function routes()
5757

5858
$namespace = '\\'.rtrim(self::$appNamespace, '\\');
5959

60-
$router->get('login-via/{provider}', "$namespace\Http\Controllers\Identities\Auth\LoginController@redirect")
60+
$router->match(['get', 'post'], 'login-via/{provider}', "$namespace\Http\Controllers\Identities\Auth\LoginController@redirect")
6161
->name("oneofftech::login.provider");
6262
$router->get('login-via/{provider}/callback', "$namespace\Http\Controllers\Identities\Auth\LoginController@login")
6363
->name("oneofftech::login.callback");
6464

65-
$router->get('register-via/{provider}', "$namespace\Http\Controllers\Identities\Auth\RegisterController@redirect")
65+
$router->match(['get', 'post'], 'register-via/{provider}', "$namespace\Http\Controllers\Identities\Auth\RegisterController@redirect")
6666
->name("oneofftech::register.provider");
6767
$router->get('register-via/{provider}/callback', "$namespace\Http\Controllers\Identities\Auth\RegisterController@register")
6868
->name("oneofftech::register.callback");
6969

70-
$router->get('connect-via/{provider}', "$namespace\Http\Controllers\Identities\Auth\ConnectController@redirect")
70+
$router->match(['get', 'post'], 'connect-via/{provider}', "$namespace\Http\Controllers\Identities\Auth\ConnectController@redirect")
7171
->name("oneofftech::connect.provider");
7272
$router->get('connect-via/{provider}/callback', "$namespace\Http\Controllers\Identities\Auth\ConnectController@connect")
7373
->name("oneofftech::connect.callback");

tests/Unit/IdentityServiceProviderTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ public function test_routes_are_registered()
8989
$this->assertTrue($router->has('oneofftech::connect.callback'));
9090

9191
$routes = collect($router->getRoutes()->getRoutes())->map(function ($r) {
92-
return $r->getActionName();
92+
return implode(',', $r->methods()).':'.$r->getActionName();
9393
});
9494

95-
$this->assertContains('\App\Http\Controllers\Identities\Auth\LoginController@redirect', $routes);
96-
$this->assertContains('\App\Http\Controllers\Identities\Auth\LoginController@login', $routes);
97-
$this->assertContains('\App\Http\Controllers\Identities\Auth\RegisterController@redirect', $routes);
98-
$this->assertContains('\App\Http\Controllers\Identities\Auth\RegisterController@register', $routes);
99-
$this->assertContains('\App\Http\Controllers\Identities\Auth\ConnectController@redirect', $routes);
100-
$this->assertContains('\App\Http\Controllers\Identities\Auth\ConnectController@connect', $routes);
95+
$this->assertContains('GET,POST,HEAD:\App\Http\Controllers\Identities\Auth\LoginController@redirect', $routes);
96+
$this->assertContains('GET,HEAD:\App\Http\Controllers\Identities\Auth\LoginController@login', $routes);
97+
$this->assertContains('GET,POST,HEAD:\App\Http\Controllers\Identities\Auth\RegisterController@redirect', $routes);
98+
$this->assertContains('GET,HEAD:\App\Http\Controllers\Identities\Auth\RegisterController@register', $routes);
99+
$this->assertContains('GET,POST,HEAD:\App\Http\Controllers\Identities\Auth\ConnectController@redirect', $routes);
100+
$this->assertContains('GET,HEAD:\App\Http\Controllers\Identities\Auth\ConnectController@connect', $routes);
101101
}
102102

103103
public function test_events_are_registered()

0 commit comments

Comments
 (0)