PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.38
Timetics – Appointment Booking Calendar & Scheduling v1.0.38
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
← All changes | core/integrations/auth.php +25 -4 1.0.161.0.38 View file →
@@ -69,13 +69,34 @@
69 69 */
70 70 public function google_auth( $code = '' ) {
71 71 $client = timetics_get_google_client();
72 72
73 - $client->add_scope( Calendar::scope() );
74 - $data = $client->fetch_access_token_with_auth_code( $code );
75 - $data['code'] = $code;
73 + // If no code is provided, redirect to Google's authorization page
74 + if ( empty($code) ) {
75 + $client->add_scope( Calendar::scope() );
76 + $auth_url = $client->get_auth_url();
77 + wp_redirect($auth_url);
78 + exit;
79 + }
76 80
77 - timetics_update_google_auth( get_current_user_id(), $data );
81 + try {
82 + $client->add_scope( Calendar::scope() );
83 + $data = $client->fetch_access_token_with_auth_code( $code );
84 + $data['code'] = $code;
85 +
86 + timetics_update_google_auth( get_current_user_id(), $data );
87 +
88 + wp_redirect(admin_url('admin.php?page=timetics#/settings'));
89 + exit;
90 + } catch (\Exception $e) {
91 + $error_message = sprintf(
92 + '<p>%s</p><p><a href="%s" class="button button-primary">Go Back</a></p>',
93 + esc_html( $e->getMessage() ),
94 + esc_url( admin_url('admin.php?page=timetics#/settings') )
95 + );
96 +
97 + wp_die($error_message, esc_html__('Google Auth Error', 'timetics'), array('back_link' => true));
98 + }
78 99 }
79 100
80 101 /**
81 102 * Authentication for zoom