Commit 59011c849ecd91a89b40f6273eb41558946150d0
1 parent
cb01abeff1
Exists in
master
bug fixes sso callback
Showing 1 changed file with 17 additions and 3 deletions Side-by-side Diff
app/SsoClientLibrary.php
| ... | ... | @@ -45,13 +45,17 @@ |
| 45 | 45 | ]); |
| 46 | 46 | |
| 47 | 47 | $_url = $this->targetUri ."oauth/authorize?" . $query; |
| 48 | - echo '<pre>';print_r($_url); | |
| 48 | + // echo '<pre>';print_r($_url); | |
| 49 | 49 | header("Location: " . $_url); |
| 50 | 50 | die(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public function ssoCallback() { |
| 54 | - if (isset($_GET['code']) && !empty(($_GET['code']))) { | |
| 54 | + $url = parse_url($this->redirectUri); | |
| 55 | + $code = str_replace($url['path'] . '?code=','',$_SERVER['REQUEST_URI']); | |
| 56 | + $code = explode('&',$code); | |
| 57 | + $code = $code[0] ?? ''; | |
| 58 | + if ($code != '') { | |
| 55 | 59 | $_access_token = ''; |
| 56 | 60 | $_errors = ''; |
| 57 | 61 | |
| ... | ... | @@ -60,7 +64,7 @@ |
| 60 | 64 | 'client_id' => $this->clientId, |
| 61 | 65 | 'client_secret' => $this->clientSecret, |
| 62 | 66 | 'redirect_uri' => $this->redirectUri, |
| 63 | - 'code' => $_GET['code'], | |
| 67 | + 'code' => $code, | |
| 64 | 68 | ]; |
| 65 | 69 | $arr_token = $this->__runCurl('POST', $this->targetUri."oauth/token", $_posts); |
| 66 | 70 | return $arr_token; |
| ... | ... | @@ -123,6 +127,16 @@ |
| 123 | 127 | return $error; |
| 124 | 128 | } |
| 125 | 129 | die('Something went wrong, please trace back your action!'); |
| 130 | + } | |
| 131 | + | |
| 132 | + public function ssoLogout($url_back = '') { | |
| 133 | + $query = http_build_query([ | |
| 134 | + 'url_back' => $url_back, | |
| 135 | + ]); | |
| 136 | + | |
| 137 | + $_url = $this->targetUri ."sso/logout?" . $query; | |
| 138 | + header("Location: " . $_url); | |
| 139 | + die(); | |
| 126 | 140 | } |
| 127 | 141 | |
| 128 | 142 | } |