PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.38
Timetics – Appointment Booking Calendar & Scheduling v1.0.38
1.0.62 1.0.63 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 All 64 releases
← All changes | core/integrations/auth.php +32 -5 1.0.101.0.38 View file →
@@ -49,9 +49,15 @@
49 49 }
50 50
51 51 do_action('timetics_integration_auth', $query_var, $code );
52 52
53 - wp_redirect( admin_url( 'admin.php?page=timetics#/my-profile') );
53 + $redirect_url = admin_url('admin.php?page=timetics#/my-profile');
54 +
55 + if ( current_user_can('manage_options') ) {
56 + $redirect_url = admin_url('admin.php?page=timetics#/settings');
57 + }
58 +
59 + wp_redirect( $redirect_url );
54 60 exit;
55 61 }
56 62
57 63 /**
@@ -63,13 +69,34 @@
63 69 */
64 70 public function google_auth( $code = '' ) {
65 71 $client = timetics_get_google_client();
66 72
67 - $client->add_scope( Calendar::scope() );
68 - $data = $client->fetch_access_token_with_auth_code( $code );
69 - $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 + }
70 80
71 - 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 + }
72 99 }
73 100
74 101 /**
75 102 * Authentication for zoom