PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 3.6.1
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v3.6.1
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Controllers / Rest / LoginController.php

LoginController.php in SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments 3.6.1, at app/src/Controllers/Rest/LoginController.php

38 lines 861 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCart\Controllers\Rest;
4
5 use SureCart\Models\User;
6
7 /**
8 * Handle coupon requests through the REST API
9 */
10 class LoginController extends RestController {
11 /**
12 * Login user.
13 *
14 * @param WP_REST_Request $request The REST request object.
15 *
16 * @return array|\WP_Error Returns an array with user details on success, or WP_Error on failure.
17 */
18 public function authenticate( \WP_REST_Request $request ) {
19 // Authenticate the user.
20 $user = wp_authenticate( $request->get_param( 'login' ), $request->get_param( 'password' ) );
21
22 // Flush all caches.
23 wp_cache_flush();
24
25 if ( is_wp_error( $user ) ) {
26 return $user;
27 }
28
29 User::find( $user->ID )->login();
30
31 return [
32 'name' => $user->display_name,
33 'email' => $user->user_email,
34 'redirect_url' => apply_filters( 'sc_login_redirect_url', null ),
35 ];
36 }
37 }
38