| 1: | <?php |
| 2: | /* |
| 3: | * SimpleID |
| 4: | * |
| 5: | * Copyright (C) Kelvin Mo 2024-2025 |
| 6: | * |
| 7: | * This program is free software; you can redistribute it and/or |
| 8: | * modify it under the terms of the GNU General Public |
| 9: | * License as published by the Free Software Foundation; either |
| 10: | * version 2 of the License, or (at your option) any later version. |
| 11: | * |
| 12: | * This program is distributed in the hope that it will be useful, |
| 13: | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14: | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15: | * General Public License for more details. |
| 16: | * |
| 17: | * You should have received a copy of the GNU General Public |
| 18: | * License along with this program; if not, write to the Free |
| 19: | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20: | */ |
| 21: | |
| 22: | namespace SimpleID\Protocols; |
| 23: | |
| 24: | use \Base; |
| 25: | use SimpleID\Util\UI\Template; |
| 26: | |
| 27: | /** |
| 28: | * A class representing a response redirecting to a custom URL scheme, |
| 29: | * typically used by native apps. |
| 30: | * |
| 31: | * This response is rendered with an HTML page to provide instructions |
| 32: | * in relation to a browser prompt. |
| 33: | */ |
| 34: | class CustomRedirectResponse { |
| 35: | /** @var string $url */ |
| 36: | protected $url; |
| 37: | |
| 38: | /** |
| 39: | * Creates a custom redirect response. |
| 40: | * |
| 41: | * @param string $url the redirect rul |
| 42: | */ |
| 43: | public function __construct($url) { |
| 44: | $this->url = $url; |
| 45: | } |
| 46: | |
| 47: | /** |
| 48: | * Renders the response. |
| 49: | * |
| 50: | * @return void |
| 51: | */ |
| 52: | public function render() { |
| 53: | $f3 = Base::instance(); |
| 54: | $tpl = Template::instance(); |
| 55: | |
| 56: | $f3->set('page_class', 'is-dialog-page is-loading'); |
| 57: | $f3->set('title', $f3->get('intl.common.launching_native_app')); |
| 58: | $f3->set('layout', 'redirect_native.html'); |
| 59: | $f3->set('url', $this->url); |
| 60: | |
| 61: | header('X-Frame-Options: DENY'); |
| 62: | print $tpl->render('page.html'); |
| 63: | } |
| 64: | } |
| 65: | |
| 66: | ?> |