-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Chadicus\Slim\OAuth2\Routes; | ||
|
||
use Slim\Slim; | ||
|
||
class ReceiveCode | ||
{ | ||
const ROUTE = '/receive-code'; | ||
|
||
private $slim; | ||
private $template; | ||
|
||
public function __construct(Slim $slim, $template = null) | ||
{ | ||
$this->slim = $slim; | ||
$this->template = $template ?: self::getDefaultTemplate(); | ||
} | ||
|
||
public function __invoke() | ||
{ | ||
$this->slim->render($this->template, ['code' => $this->slim->request()->params('code')]); | ||
} | ||
|
||
/** | ||
* Register this route with the given Slim application and OAuth2 server | ||
* | ||
* @param Slim $slim The slim framework application instance. | ||
* | ||
* @return void | ||
*/ | ||
public static function register(Slim $slim) | ||
{ | ||
$slim->map(self::ROUTE, new self($slim))->via('GET', 'POST')->name('receive-code'); | ||
} | ||
|
||
/** | ||
* Helper method to return the default template for the /authorize route | ||
* | ||
* @return string The path to the default template | ||
*/ | ||
private static function getDefaultTemplate() | ||
{ | ||
return __DIR__ . '/../templates/receive-code.phtml'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<form method="post"> | ||
<label>Do You Authorize <?php echo htmlentities($this->data['client_id']); ?>?</label><br /> | ||
<input type="submit" name="authorized" value="yes"> | ||
<input type="submit" name="authorized" value="no"> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h2>The authorization code is <?php echo $this->data['code']; ?></h2> |