@@ 138-145 (lines=8) @@ | ||
135 | $http_method = $request->get_method(); |
|
136 | $class = $request->get_url_params()['class']; |
|
137 | switch ( $class ) { |
|
138 | case 'salesforce': |
|
139 | if ( ! in_array( $http_method, explode( ',', WP_REST_Server::ALLMETHODS ) ) ) { |
|
140 | return new WP_Error( 'rest_forbidden', esc_html__( 'This kind of request is not allowed.', 'object-sync-for-salesforce' ), array( 'status' => 401 ) ); |
|
141 | } |
|
142 | if ( ! current_user_can( 'configure_salesforce' ) ) { |
|
143 | return new WP_Error( 'rest_forbidden', esc_html__( 'You do not have permissions to view this data.', 'object-sync-for-salesforce' ), array( 'status' => 401 ) ); |
|
144 | } |
|
145 | break; |
|
146 | case 'mappings': |
|
147 | if ( ! in_array( $http_method, explode( ',', WP_REST_Server::ALLMETHODS ) ) ) { |
|
148 | return new WP_Error( 'rest_forbidden', esc_html__( 'This kind of request is not allowed.', 'object-sync-for-salesforce' ), array( 'status' => 401 ) ); |
|
@@ 146-153 (lines=8) @@ | ||
143 | return new WP_Error( 'rest_forbidden', esc_html__( 'You do not have permissions to view this data.', 'object-sync-for-salesforce' ), array( 'status' => 401 ) ); |
|
144 | } |
|
145 | break; |
|
146 | case 'mappings': |
|
147 | if ( ! in_array( $http_method, explode( ',', WP_REST_Server::ALLMETHODS ) ) ) { |
|
148 | return new WP_Error( 'rest_forbidden', esc_html__( 'This kind of request is not allowed.', 'object-sync-for-salesforce' ), array( 'status' => 401 ) ); |
|
149 | } |
|
150 | if ( ! current_user_can( 'configure_salesforce' ) ) { |
|
151 | return new WP_Error( 'rest_forbidden', esc_html__( 'You do not have permissions to view this data.', 'object-sync-for-salesforce' ), array( 'status' => 401 ) ); |
|
152 | } |
|
153 | break; |
|
154 | case 'pull': |
|
155 | if ( ! in_array( $http_method, array( 'GET', 'POST', 'PUT' ) ) ) { |
|
156 | return new WP_Error( 'rest_forbidden', esc_html__( 'This kind of request is not allowed.', 'object-sync-for-salesforce' ), array( 'status' => 401 ) ); |