PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 2.2.6
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v2.2.6
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/API/Login.php +8 -53 3.6.42.2.6 View file →
@@ -17,12 +17,8 @@
17 17 if ( '/templately/v1/pricing' === $_route ) {
18 18 return true;
19 19 }
20 20
21 - if ( '/templately/v1/google-auth-url' === $_route ) {
22 - return true;
23 - }
24 -
25 21 return parent::permission_check( $request );
26 22 }
27 23
28 24 public function register_routes() {
@@ -29,25 +25,10 @@
29 25 $this->post( 'login', [$this, 'login'] );
30 26 $this->post( 'logout', [$this, 'logout'] );
31 27 $this->get( 'is-signed', [$this, 'is_signed'] );
32 28 $this->get( 'pricing', [$this, 'pricing'] );
33 - $this->get( 'google-auth-url', [$this, 'google_auth_url'] );
34 29 }
35 30
36 - public function google_auth_url() {
37 - // Get redirect_to parameter from request if provided
38 - $redirect_to = $this->get_param( 'redirect-to', '' );
39 -
40 - // Use client-provided current_url instead of HTTP_REFERER for reliability
41 - $current_url = $this->get_param( 'current_url', '' );
42 -
43 - $url = $this->http()->google_auth_url( $redirect_to, $current_url );
44 - return [
45 - 'status' => 'success',
46 - 'url' => $url
47 - ];
48 - }
49 -
50 31 public function pricing(){
51 32 $data = get_transient( "templately_subscriptions" );
52 33
53 34 if( is_array( $data ) && ! empty( $data ) ) {
@@ -53,9 +34,9 @@
53 34 if( is_array( $data ) && ! empty( $data ) ) {
54 35 return $data;
55 36 }
56 37
57 - $query = 'id, price, name, discounted_price, type, sites, coupon';
38 + $query = 'id, price, name, discounted_price, type, sites';
58 39 $response = $this->http()->query(
59 40 'subscriptionPlans',
60 41 $query
61 42 )->post();
@@ -79,10 +60,8 @@
79 60 'ip' => $_ip,
80 61 'site_url' => $_site_url
81 62 ];
82 63
83 - $postArgs = [];
84 -
85 64 if ( $viaAPI ) {
86 65 $api_key = $this->get_param( 'api_key' );
87 66 $funcArgs['api_key'] = $api_key;
88 67
@@ -105,24 +84,20 @@
105 84 if ( ! empty( $errors ) ) {
106 85 return $this->error( 'login_error', $errors, 'login', 400 );
107 86 }
108 87
109 - $query = 'status, message, user{ id, name, first_name, last_name, display_name, email, profile_photo, joined, is_verified, is_company_user, api_key, plan, plan_expire_at, my_cloud{ limit, usages, last_pushed }, favourites{ id, type }, show_notice, reviews{ type, type_id, rating }, subscription { id, name, sites } }';
88 + $query = 'status, message, user{ id, name, first_name, last_name, display_name, email, profile_photo, joined, is_verified, api_key, plan, plan_expire_at, my_cloud{ limit, usages, last_pushed }, favourites{ id, type }, show_notice }';
110 89
111 90 $response = $this->http()->mutation(
112 91 $viaAPI ? 'connectWithApiKey' : 'connect',
113 92 $query,
114 93 $funcArgs
115 - )->post($postArgs);
94 + )->post();
116 95
117 96 if ( is_wp_error( $response ) ) {
118 97 return $response;
119 98 }
120 99
121 - if ( empty( $response['user']['api_key'] ) ) {
122 - return $this->error( 'login_error', $response['message'] ?? __('Invalid API key.', 'templately'), 'login', 400 );
123 - }
124 -
125 100 if ( $global_signin && ! Login::is_globally_signed() ) {
126 101 Options::set_global_login();
127 102 }
128 103
@@ -150,25 +125,8 @@
150 125 unset( $response['user']['favourites'] );
151 126 $meta['favourites'] = $_favourites;
152 127 }
153 128
154 - if ( ! empty( $response['user']['reviews'] ) ) {
155 - $_reviews = $this->utils( 'helper' )->normalizeReviews( $response['user']['reviews'] );
156 - $this->utils( 'options' )->set( 'reviews', $_reviews );
157 -
158 - unset( $response['user']['reviews'] );
159 - $meta['reviews'] = $_reviews;
160 - }
161 -
162 - if(Helper::is_dev_api()){
163 - $response['user']['is_dev_api'] = true;
164 - }
165 -
166 - if(! empty( $response['user'] ) && is_array($response['user'])){
167 - $response['user']['ip'] = $_ip;
168 - $response['user']['site_url'] = base64_encode( $_site_url );
169 - }
170 -
171 129 $this->utils( 'options' )->set( 'user', $response['user'] );
172 130 $response['user']['meta'] = $this->user_meta( $meta );
173 131
174 132 return $response;
@@ -210,16 +168,14 @@
210 168 public function delete(){
211 169 $this->utils( 'options' )
212 170 ->remove( 'user' )
213 171 ->remove( 'favourites' )
214 - ->remove( 'reviews' )
215 172 ->remove( 'cloud_activity' )
216 173 ->remove( 'api_key' )
217 174 ->remove( 'global_login' )
218 - ->remove( 'total_download_counts' )
219 175 ->remove( 'templates_in_clouds' );
220 176
221 - if ( $this->utils( 'options' )->who_am_i() === 'global' ) {
177 + if ( $this->utils( 'options' )->whoami() === 'global' ) {
222 178 $this->utils( 'options' )->remove_global_login();
223 179 }
224 180
225 181 $global_user_id = $this->utils( 'options' )->is_global();
@@ -235,9 +191,9 @@
235 191
236 192 return $global_user;
237 193 }
238 194
239 - public static function is_signed(): array {
195 + public static function is_signed() {
240 196 $_response = [
241 197 'status' => 'success'
242 198 ];
243 199
@@ -255,9 +211,9 @@
255 211
256 212 return $_response;
257 213 }
258 214
259 - public function user_meta( $meta = [] ): array {
215 + public function user_meta( $meta = [] ) {
260 216 $_meta = [
261 217 'link_account' => self::utils( 'options' )->link_account(),
262 218 'unlink_account' => self::utils( 'options' )->unlink_account(),
263 219 'is_globally_signed' => Login::is_globally_signed(),
@@ -262,9 +218,8 @@
262 218 'unlink_account' => self::utils( 'options' )->unlink_account(),
263 219 'is_globally_signed' => Login::is_globally_signed(),
264 220 'signed_as_global' => Login::signed_as_global(),
265 221 'starred' => self::utils( 'options' )->get( 'favourites' ),
266 - 'reviews' => self::utils( 'options' )->get( 'reviews' ),
267 222 'cloud_activity' => self::utils( 'options' )->get( 'cloud_activity' ),
268 223 'has_api' => rest_sanitize_boolean( self::utils( 'options' )->get( 'api_key' ) )
269 224 ];
270 225
@@ -270,12 +225,12 @@
270 225
271 226 return array_merge( $_meta, $meta );
272 227 }
273 228
274 - public static function is_globally_signed(): bool {
229 + public static function is_globally_signed() {
275 230 return rest_sanitize_boolean( ( new static )->utils( 'options' )->is_globally_signed() );
276 231 }
277 232
278 - public static function signed_as_global(): bool {
233 + public static function signed_as_global() {
279 234 return rest_sanitize_boolean( ( new static )->utils( 'options' )->signed_as_global() );
280 235 }
281 236 }