.gitkeep
3 years ago
DashboardController.php
3 years ago
PurchaseController.php
3 years ago
SubscriptionsController.php
3 years ago
WebhookController.php
3 years ago
DashboardController.php
55 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Controllers\Web; |
| 4 | |
| 5 | use SureCart\Models\CustomerLink; |
| 6 | |
| 7 | /** |
| 8 | * Thank you routes |
| 9 | */ |
| 10 | class DashboardController { |
| 11 | /** |
| 12 | * Show the dashboard. |
| 13 | */ |
| 14 | public function show( $request, $view ) { |
| 15 | // do not cache. |
| 16 | $request->noCache(); |
| 17 | return \SureCart::view( $view ); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Get the link from the request. |
| 22 | * |
| 23 | * @param string $link_id The link id. |
| 24 | * @return string|\WP_Error |
| 25 | */ |
| 26 | public function getLink( $link_id ) { |
| 27 | $link = CustomerLink::find( $link_id ); |
| 28 | if ( is_wp_error( $link ) ) { |
| 29 | return $link; |
| 30 | } |
| 31 | return $link; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Login the user |
| 36 | * |
| 37 | * @param int|\WP_User $wp_user WordPress user. |
| 38 | * @return void |
| 39 | */ |
| 40 | public function loginUser( $wp_user ) { |
| 41 | if ( ! $wp_user ) { |
| 42 | return wp_die( esc_html__( 'This user could not be found.', 'surecart' ) ); |
| 43 | } |
| 44 | |
| 45 | $id = ! empty( $wp_user->ID ) ? $wp_user->ID : $wp_user; |
| 46 | if ( ! is_int( $id ) ) { |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | wp_clear_auth_cookie(); |
| 51 | wp_set_current_user( $id ); |
| 52 | wp_set_auth_cookie( $id ); |
| 53 | } |
| 54 | } |
| 55 |