@@ 878-885 (lines=8) @@ | ||
875 | * |
|
876 | * @return bool|WP_Error True if user is able to disconnect the site. |
|
877 | */ |
|
878 | public static function disconnect_site_permission_callback() { |
|
879 | if ( current_user_can( 'jetpack_disconnect' ) ) { |
|
880 | return true; |
|
881 | } |
|
882 | ||
883 | return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::$user_permissions_error_msg, array( 'status' => rest_authorization_required_code() ) ); |
|
884 | ||
885 | } |
|
886 | ||
887 | /** |
|
888 | * Verify that the user can dismiss JITM messages. |
|
@@ 944-950 (lines=7) @@ | ||
941 | * |
|
942 | * @return bool|WP_Error True if user is able to change master user. |
|
943 | */ |
|
944 | public static function set_connection_owner_permission_callback() { |
|
945 | if ( current_user_can( 'jetpack_disconnect' ) ) { |
|
946 | return true; |
|
947 | } |
|
948 | ||
949 | return new WP_Error( 'invalid_user_permission_set_connection_owner', self::$user_permissions_error_msg, array( 'status' => rest_authorization_required_code() ) ); |
|
950 | } |
|
951 | ||
952 | /** |
|
953 | * Verify that a user can use the /connection/user endpoint. Has to be a registered user and be currently linked. |
|
@@ 1021-1027 (lines=7) @@ | ||
1018 | * |
|
1019 | * @return bool Whether user has capability 'jetpack_disconnect'. |
|
1020 | */ |
|
1021 | public static function identity_crisis_mitigation_permission_check() { |
|
1022 | if ( current_user_can( 'jetpack_disconnect' ) ) { |
|
1023 | return true; |
|
1024 | } |
|
1025 | ||
1026 | return new WP_Error( 'invalid_user_permission_identity_crisis', self::$user_permissions_error_msg, array( 'status' => rest_authorization_required_code() ) ); |
|
1027 | } |
|
1028 | ||
1029 | /** |
|
1030 | * Verify that user can update Jetpack general settings. |
@@ 232-238 (lines=7) @@ | ||
229 | * |
|
230 | * @return bool|WP_Error Whether user has the capability 'jetpack_disconnect'. |
|
231 | */ |
|
232 | public static function jetpack_disconnect_permission_check() { |
|
233 | if ( current_user_can( 'jetpack_disconnect' ) ) { |
|
234 | return true; |
|
235 | } |
|
236 | ||
237 | return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::get_user_permissions_error_msg(), array( 'status' => rest_authorization_required_code() ) ); |
|
238 | } |
|
239 | ||
240 | /** |
|
241 | * Returns generic error message when user is not allowed to perform an action. |