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 +8 -24 trunk1.0.38 View file →
@@ -6,10 +6,8 @@
6 6 */
7 7
8 8 namespace Timetics\Core\Integrations;
9 9
10 -defined( 'ABSPATH' ) || exit;
11 -
12 10 use Timetics\Core\Integrations\Google\Service\Calendar;
13 11 use Timetics\Utils\Singleton;
14 12
15 13 /**
@@ -37,22 +35,10 @@
37 35 public function authenticate() {
38 36 $query_var = get_query_var( 'timetics-integration', false );
39 37 $user_id = get_current_user_id();
40 38
41 - $code = isset( $_GET['code'] ) ? sanitize_text_field( wp_unslash( $_GET['code'] ) ) : '';
39 + $code = isset( $_GET['code'] ) ? sanitize_text_field( $_GET['code'] ) : '';
42 40
43 - // Verify nonce for security.
44 - if ( empty( $code ) ) {
45 - if ( ! isset( $_GET['timetics_auth_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['timetics_auth_nonce'] ) ), 'timetics_auth_action' ) ) {
46 - return;
47 - }
48 - } else {
49 - $state = isset( $_GET['state'] ) ? sanitize_text_field( wp_unslash( $_GET['state'] ) ) : '';
50 - if ( ! wp_verify_nonce( $state, 'timetics_auth_callback' ) ) {
51 - return;
52 - }
53 - }
54 -
55 41 if ( ! $query_var ) {
56 42 return;
57 43 }
58 44
@@ -69,9 +55,9 @@
69 55 if ( current_user_can('manage_options') ) {
70 56 $redirect_url = admin_url('admin.php?page=timetics#/settings');
71 57 }
72 58
73 - wp_safe_redirect( $redirect_url );
59 + wp_redirect( $redirect_url );
74 60 exit;
75 61 }
76 62
77 63 /**
@@ -83,15 +69,13 @@
83 69 */
84 70 public function google_auth( $code = '' ) {
85 71 $client = timetics_get_google_client();
86 72
87 - // If no code is provided, redirect to Google's authorization page.
88 - if ( empty( $code ) ) {
89 - $state = wp_create_nonce( 'timetics_auth_callback' );
73 + // If no code is provided, redirect to Google's authorization page
74 + if ( empty($code) ) {
90 75 $client->add_scope( Calendar::scope() );
91 - $auth_url = $client->get_auth_url( $state );
92 - // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- Redirecting to external Google OAuth URL.
93 - wp_redirect( $auth_url );
76 + $auth_url = $client->get_auth_url();
77 + wp_redirect($auth_url);
94 78 exit;
95 79 }
96 80
97 81 try {
@@ -100,9 +84,9 @@
100 84 $data['code'] = $code;
101 85
102 86 timetics_update_google_auth( get_current_user_id(), $data );
103 87
104 - wp_safe_redirect(admin_url('admin.php?page=timetics#/settings'));
88 + wp_redirect(admin_url('admin.php?page=timetics#/settings'));
105 89 exit;
106 90 } catch (\Exception $e) {
107 91 $error_message = sprintf(
108 92 '<p>%s</p><p><a href="%s" class="button button-primary">Go Back</a></p>',
@@ -109,9 +93,9 @@
109 93 esc_html( $e->getMessage() ),
110 94 esc_url( admin_url('admin.php?page=timetics#/settings') )
111 95 );
112 96
113 - wp_die( wp_kses_post( $error_message ), esc_html__('Google Auth Error', 'timetics'), array('back_link' => true));
97 + wp_die($error_message, esc_html__('Google Auth Error', 'timetics'), array('back_link' => true));
114 98 }
115 99 }
116 100
117 101 /**