| @@ -23,9 +23,9 @@ | ||
| 23 | 23 | public function authorize() { |
| 24 | 24 | |
| 25 | 25 | if ( |
| 26 | 26 | \Depicter::cache('base')->get( 'is_client_registered' ) && |
| 27 | - \Depicter::options()->get( 'client_key', false ) | |
| 27 | + \Depicter::auth()->getClientKey() | |
| 28 | 28 | ) { |
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
| @@ -107,22 +107,33 @@ | ||
| 107 | 107 | try { |
| 108 | 108 | $response = \Depicter::remote()->post( 'v1/client/validate/activation' ); |
| 109 | 109 | $info = JSON::decode( $response->getBody(), true); |
| 110 | 110 | |
| 111 | - if ( ! empty( $info['data'] ) ) { | |
| 111 | + if( is_null( $info['success'] ) ){ | |
| 112 | + \Depicter::options()->set('activation_error_message', '' ); | |
| 113 | + | |
| 114 | + } elseif ( ! empty( $info['data'] ) ) { | |
| 112 | 115 | \Depicter::options()->set('subscription_status', $info['data']['status'] ); |
| 113 | 116 | \Depicter::options()->set('subscription_expires_at', $info['data']['expires_at'] ); |
| 114 | 117 | \Depicter::options()->set('user_tier', $info['data']['user_tier'] ); |
| 115 | 118 | \Depicter::options()->set('activation_error_message', '' ); |
| 116 | - } elseif( ! empty( $info['errors'] ) ) { | |
| 117 | - \Depicter::options()->set('activation_error_message', $info['errors'] ); | |
| 119 | + | |
| 120 | + if ( $info['data']['status'] == 'active' ) { | |
| 121 | + return true; | |
| 122 | + } | |
| 123 | + } elseif( $info['success'] == 1 ){ | |
| 124 | + return true; | |
| 118 | 125 | } |
| 126 | + | |
| 119 | 127 | if( ! empty( $info['log'] ) ) { |
| 120 | 128 | \Depicter::options()->set('activation_log_message', $info['log'] ); |
| 121 | 129 | } |
| 130 | + | |
| 122 | 131 | } catch ( GuzzleException $exception ) { |
| 123 | 132 | \Depicter::options()->set('activation_error_message' , $exception->getMessage() ); |
| 124 | 133 | \Depicter::options()->set('connection_error_message' , $exception->getMessage() ); |
| 125 | 134 | } |
| 135 | + | |
| 136 | + return false; | |
| 126 | 137 | } |
| 127 | 138 | |
| 128 | 139 | } |