PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 2.1.3
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v2.1.3
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
← All changes | app/src/Controllers/Rest/VerificationCodeController.php +6 -14 4.4.22.1.3 View file →
@@ -32,9 +32,9 @@
32 32 $user = $this->getUser( $request->get_param( 'login' ) );
33 33
34 34 // bail if no user.
35 35 if ( ! $user ) {
36 - return new \WP_Error( 'user_not_found', __( 'The user could not be found.', 'surecart' ), [ 'status' => 404 ] );
36 + return new \WP_Error( 'user_not_found', __( 'The user could not be found.', 'surecart' ) );
37 37 }
38 38
39 39 return $model->where( $request->get_query_params() )->create(
40 40 [
@@ -47,9 +47,9 @@
47 47 * Verify a verification code
48 48 *
49 49 * @param \WP_REST_Request $request Rest Request.
50 50 *
51 - * @return mixed|\WP_Error
51 + * @return \SureCart\Models\VerificationCode|\WP_Error
52 52 */
53 53 public function verify( \WP_REST_Request $request ) {
54 54 // run middleware.
55 55 $model = $this->middleware( new $this->class(), $request );
@@ -62,10 +62,9 @@
62 62 $user = $this->getUser( $request->get_param( 'login' ) );
63 63 if ( ! $user ) {
64 64 return new \WP_Error(
65 65 'invalid_email',
66 - __( 'There is no account with that username or email address.', 'surecart' ),
67 - [ 'status' => 404 ]
66 + __( 'There is no account with that username or email address.', 'surecart' )
68 67 );
69 68 }
70 69
71 70 // verify the code.
@@ -82,9 +81,9 @@
82 81 }
83 82
84 83 // code is invalid or not verified.
85 84 if ( empty( $verify->verified ) ) {
86 - return new \WP_Error( 'invalid_code', __( 'Invalid verification code', 'surecart' ), [ 'status' => 400 ] );
85 + return new \WP_Error( 'invalid_code', __( 'Invalid verification code', 'surecart' ) );
87 86 }
88 87
89 88 // get the user based on the login value.
90 89 $user = $this->getUser( $request->get_param( 'login' ) );
@@ -90,9 +89,9 @@
90 89 $user = $this->getUser( $request->get_param( 'login' ) );
91 90
92 91 // bail if no user.
93 92 if ( ! $user ) {
94 - return new \WP_Error( 'user_not_found', __( 'The user could not be found.', 'surecart' ), [ 'status' => 404 ] );
93 + return new \WP_Error( 'user_not_found', __( 'The user could not be found.', 'surecart' ) );
95 94 }
96 95
97 96 // login the user.
98 97 $logged_in = $user->login();
@@ -100,15 +99,8 @@
100 99 if ( is_wp_error( $logged_in ) ) {
101 100 return $logged_in;
102 101 }
103 102
104 - $verify->name = $user->display_name ?? $user->user_login;
105 - $verify->avatar_url = get_avatar_url( $user->user_email, [ 'size' => 48 ] );
106 - $verify->nonce = ( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' );
107 - $redirect_to = $request->get_param( 'redirect_to' );
108 - $redirect_url = ! empty( $redirect_to ) ? wp_validate_redirect( $redirect_to, false ) : null;
109 - $verify->redirect_url = apply_filters( 'sc_login_redirect_url', $redirect_url ); // this is the URL to redirect to after login.
110 -
111 103 // return the model.
112 104 return $verify;
113 105 }
114 106
@@ -119,7 +111,7 @@
119 111 *
120 112 * @return \SureCart\Models\User|false
121 113 */
122 114 public function getUser( $login ) {
123 - return User::getUserby( strpos( $login ?? '', '@' ) ? 'email' : 'login', $login );
115 + return User::getUserby( strpos( $login, '@' ) ? 'email' : 'login', $login );
124 116 }
125 117 }