Changeset 3309580
- Timestamp:
- 06/11/2025 07:28:39 AM (10 months ago)
- File:
-
- 1 edited
-
flynax-bridge/trunk/src/API.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
flynax-bridge/trunk/src/API.php
r3306501 r3309580 130 130 * Greetings method of the bridges 131 131 * 132 * @since 2.2.1 - Added admin username and password authorization 132 133 * @since 2.2.0 - Method changed to static 133 134 */ 134 135 public static function handShake() 135 136 { 137 $username = sanitize_text_field(wp_unslash($_REQUEST['username'] ?? '')); 138 $password = sanitize_text_field(wp_unslash($_REQUEST['password'] ?? '')); 139 140 if (!$username || !$password) { 141 $response = new WP_Error('handshake-error', __('Missing username or password', 'flynax-bridge')); 142 print(json_encode($response)); 143 return; 144 } 145 146 $user = wp_authenticate($username, $password); 147 148 if (is_wp_error($user)) { 149 $response = new WP_Error('handshake-error', __('Invalid username or password', 'flynax-bridge')); 150 print(json_encode($response)); 151 return; 152 } 153 154 if (!in_array('administrator', (array) $user->roles)) { 155 $response = new WP_Error('handshake-error', __('Forbidden: User is not an administrator', 'flynax-bridge')); 156 print(json_encode($response)); 157 return; 158 } 159 136 160 $self = new self(); 137 161 $token = $self->generateToken();
Note: See TracChangeset
for help on using the changeset viewer.