Fetches the URL to redirect to for a given user (used after switching).

@param  WP_User $new_user Optional. The new user's WP_User object.
@param  WP_User $old_user Optional. The old user's WP_User object.
@return string The URL to redirect to.
960293
protected static function get_redirect( WP_User $new_user = null, WP_User $old_user = null ) {
		if ( ! empty( $_REQUEST['redirect_to'] ) ) {
			$redirect_to           = self::remove_query_args( wp_unslash( $_REQUEST['redirect_to'] ) );
			$requested_redirect_to = wp_unslash( $_REQUEST['redirect_to'] );
		} else {
			$redirect_to           = '';
			$requested_redirect_to = '';
		}

		if ( ! $new_user ) {
			/** This filter is documented in wp-login.php */
			$redirect_to = apply_filters( 'logout_redirect', $redirect_to, $requested_redirect_to, $old_user );
		} else {
			/** This filter is documented in wp-login.php */
			$redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $new_user );
		}

		return $redirect_to;
	}
593338
function redirectTo( $uri )
    {
        $originalURI = $uri;
        $uri = preg_replace( "#(^.*)(/+)$#", "\$1", $uri );
        if ( strlen( $originalURI ) != 0 and
             strlen( $uri ) == 0 )
            $uri = '/';

        $urlComponents = parse_url( $uri );
        // eZSys::hostname() can contain port if present.
        // So parsing it with parse_url() as well to only get host.
        $currentHostname = eZSys::hostname();
        $currentHostnameParsed = parse_url( $currentHostname, PHP_URL_HOST );
        $currentHostname = $currentHostnameParsed ? $currentHostnameParsed : $currentHostname;
        if ( isset( $urlComponents['host'] ) && $urlComponents['host'] !== $currentHostname )
        {
            $allowedHosts = $this->getAllowedRedirectHosts();
            if ( !isset( $allowedHosts[$urlComponents['host']] ) )
            {
                // Non-authorized host, return only the URI (without host) + query string and fragment if present.
                eZDebug::writeError( "Redirection requested on non-authorized host '{$urlComponents['host']}'" );
                header( $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );
                echo "Redirection requested on non-authorized host";
                eZDB::checkTransactionCounter();
                eZExecution::cleanExit();
            }
        }

        $this->RedirectURI = $uri;
        $this->setExitStatus( self::STATUS_REDIRECT );
    }
332388
private function getRedirect($currentRoute, $redirect = false)
    {
        $useRedirect = $this->options->getUseRedirectParameterIfPresent();
        $routeExists = ($redirect && $this->routeExists($redirect));
        if (!$useRedirect || !$routeExists) {
            $redirect = false;
        }

        switch ($currentRoute) {
            case 'zfcuser/login':
            case 'scn-social-auth-user/login':
            case 'scn-social-auth-user/register':
            case 'scn-social-auth-user/authenticate/provider':
            case 'scn-social-auth-user/add-provider/provider':
                $route = ($redirect) ?: $this->options->getLoginRedirectRoute();

                return $this->router->assemble(array(), array('name' => $route));
                break;
            case 'zfcuser/logout':
            case 'scn-social-auth-user/logout':
                $route = ($redirect) ?: $this->options->getLogoutRedirectRoute();

                return $this->router->assemble(array(), array('name' => $route));
                break;
            default:
                return $this->router->assemble(array(), array('name' => 'zfcuser'));
        }
    }
980409
public function getRedirectUrl()
    {
        $siteId = $this->getSiteId();

        $requestUrl = $this->getRequestUrl();

        $redirect = $this->redirectRepo->getRedirect($requestUrl, $siteId);

        if (!empty($redirect)) {
            return $redirect->getRedirectUrl();
        }

        return null;
    }
1258762
public function update($new_instance, $old_instance)
    {
        $instance = $old_instance;

        // Get vars
        foreach ($new_instance as $k => $i) {
            $instance[$k] = isset($new_instance[$k]) ? strip_tags($new_instance[$k]) : false;
        }

        // Flush current widget cache.
        $this->flush_widget_cache();

        // Get options from cache to renew them.
        $alloptions = wp_cache_get('alloptions', 'options');

        // Delete options.
        if (isset($alloptions[$this->getModel()->getIdentifier()])) {
            delete_option($this->getModel()->getIdentifier());
        }

        // Return new data.
        return $instance;
    }
784352
def with_user(self, user):
        
        # N.B. doesn't cleanup query/fragment
        val = self._val
        if user is None:
            password = None
        elif isinstance(user, str):
            user = self._QUOTER(user)
            password = val.password
        else:
            raise TypeError("Invalid user type")
        if not self.is_absolute():
            raise ValueError("user replacement is not allowed " "for relative URLs")
        return URL(
            self._val._replace(
                netloc=self._make_netloc(
                    user, password, val.hostname, val.port, encode=False
                )
            ),
            encoded=True,
        )
410048
public function findOrRegister($user)
    {
        if ($userExist = User::where($user['email'])->first()) {
            return $userExist; 
        }
        $newUser = User::create($user);
        return $newUser;
    }
32746
protected static function changePassword(User $user, $old, $new, $login = true)
    {
        static::isAllowed($user);

        // query with check for old password
        // then update with new password
        if (empty($old) || empty($new)) {
            throw new BadRequestException('Both old and new password are required to change the password.');
        }

        if (null === $user) {
            // bad session
            throw new NotFoundException("The user for the current session was not found in the system.");
        }

        try {
            // validate password
            $isValid = \Hash::check($old, $user->password);
        } catch (\Exception $ex) {
            throw new InternalServerErrorException("Error validating old password.\n{$ex->getMessage()}");
        }

        if (!$isValid) {
            throw new BadRequestException("The password supplied does not match.");
        }

        try {
            $user->password = $new;
            $user->save();

            if ($login) {
                static::userLogin($user->email, $new);

                return ['success' => true, 'session_token' => Session::getSessionToken()];
            }

            return ['success' => true];
        } catch (\Exception $ex) {
            throw new InternalServerErrorException("Error processing password change.\n{$ex->getMessage()}");
        }
    }
742723
public function getURL($use_username = true)
    {
        $url = 'option=com_people&view=person&id='.$this->id;

        if ($use_username) {
            $url .= '&uniqueAlias='.strtolower($this->alias);
        }

        return $url;
    }
293283
public function editUserAction()
    {
        if(!$this->identity()) {
          return $this->redirect()->toRoute($this->getOptions()->getLoginRedirectRoute());
        }
      
        try {
            $id = (int) $this->params()->fromRoute('id', 0);
    
            if ($id == 0) {
                $this->flashMessenger()->addErrorMessage($this->getTranslatorHelper()->translate('User ID invalid'));
                return $this->redirect()->toRoute('user-admin');
            }
            
            $entityManager = $this->getEntityManager();
            $user = $entityManager->getRepository('CsnUser\Entity\User')->find($id);
            
            $form = $this->getUserFormHelper()->createUserForm($user, 'EditUser');
            
            $form->setAttributes(array(
                'action' => $this->url()->fromRoute('user-admin', array('action' => 'edit-user', 'id' => $id)),
            ));
              	
            $request = $this->getRequest();
            if ($request->isPost()) {
                $form->setValidationGroup('username', 'email', 'firstName', 'lastName', 'language', 'state', 'role', 'question', 'answer', 'csrf');
                $form->setData($request->getPost());
                if ($form->isValid()) {
                    $entityManager->persist($user);
                    $entityManager->flush();
                    $this->flashMessenger()->addSuccessMessage($this->getTranslatorHelper()->translate('User Updated Successfully'));
                    return $this->redirect()->toRoute('user-admin');
                }
            }  
        }      
        catch (\Exception $e) {
            return $this->getServiceLocator()->get('csnuser_error_view')->createErrorView(
                $this->getTranslatorHelper()->translate('Something went wrong during update user process! Please, try again later.'),
                $e,
                $this->getOptions()->getDisplayExceptions(),
                false
            );
        }
        
        $viewModel = new ViewModel(array(
            'form' => $form,
            'headerLabel' => $this->getTranslatorHelper()->translate('Edit User').' - '.$user->getDisplayName(),
        ));
        $viewModel->setTemplate('csn-user/admin/edit-user-form');
        return $viewModel;
    }
1219475
public function getSafeRedirectUrl($default, $data = null, $key = 'redirect') {
		$redirectUrl = $data ?: ($this->Controller->getRequest()->getData($key) ?: $this->Controller->getRequest()->getQuery($key));
		if ($redirectUrl && (mb_substr($redirectUrl, 0, 1) !== '/' || mb_substr($redirectUrl, 0, 2) === '//')) {
			$redirectUrl = null;
		}

		return $redirectUrl ?: $default;
	}
844837
public function action_personal_options( WP_User $user ) {
		$link = self::maybe_switch_url( $user );

		if ( ! $link ) {
			return;
		}

		?>
		<tr>
			<th scope="row"><?php echo esc_html_x( 'User Switching', 'User Switching title on user profile screen', 'user-switching' ); ?></th>
			<td><a href="<?php echo esc_url( $link ); ?>"><?php esc_html_e( 'Switch&nbsp;To', 'user-switching' ); ?></a></td>
		</tr>
		<?php
	}
476615
public function getAuthRedirect($redirect_uri)
    {
        empty($this->pre_auth_code) && $this->getPreauthCode();
        if (empty($this->pre_auth_code)) {
            return false;
        }
        return "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$this->component_appid}&pre_auth_code={$this->pre_auth_code}&redirect_uri={$redirect_uri}";
    }
253915
function get_after_plugin_activation_redirect_url() {
            $url = false;

            if ( ! $this->is_addon() || ! $this->has_free_plan() ) {
                $first_time_path = $this->_menu->get_first_time_path();

                if ( $this->is_activation_mode() ) {
                    $url = $this->get_activation_url();
                } else if ( ! empty( $first_time_path ) ) {
                    $url = $first_time_path;
                } else {
                    $page = '';
                    if ( ! empty( $this->_dynamically_added_top_level_page_hook_name ) ) {
                        if ( $this->is_network_registered() ) {
                            $page = 'account';
                        } else if ( $this->is_network_anonymous() ) {
                            $this->maybe_set_slug_and_network_menu_exists_flag();
                        }
                    }

                    $url = $this->_get_admin_page_url( $page );
                }
            } else {
                $plugin_fs = false;

                if ( $this->is_parent_plugin_installed() ) {
                    $plugin_fs = self::get_parent_instance();
                }

                if ( is_object( $plugin_fs ) ) {
                    if ( ! $plugin_fs->is_registered() ) {
                        // Forward to parent plugin connect when parent not registered.
                        $url = $plugin_fs->get_activation_url();
                    } else {
                        // Forward to account page.
                        $url = $plugin_fs->_get_admin_page_url( 'account' );
                    }
                }
            }

            return $url;
        }
1162543
public function getLoginUrl($redirect_uri, $scopes = array("read_public"), $response_type = "code")
    {
        $queryparams = array(
            "response_type"     => $response_type,
            "redirect_uri"      => $redirect_uri,
            "client_id"         => $this->client_id,
            "client_secret"     => $this->client_secret,
            "scope"             => implode(",", $scopes),
            "state"             => $this->state
        );

        // Build url and return it
        return sprintf("%s?%s", self::AUTH_HOST, http_build_query($queryparams));
    }
1051084
public function getCurrentUrl(): string
    {
        /** @var WP $wp */
        $wp = Core::get(WP::class);
        return $this->wpProvider->homeUrl(
            $this->wpProvider->addQueryArg([], $wp->request));
    }
617407
public function ApplyBan($NewBan = NULL, $OldBan = NULL) {
      if (!$NewBan && !$OldBan)
         return;

      $OldUsers = array();
      $OldUserIDs = array();

      $NewUsers = array();
      $NewUserIDs = array();
      
      $AllBans = $this->AllBans();
      
      if ($NewBan) {
         // Get a list of users affected by the new ban.
         if (isset($NewBan['BanID']))
            $AllBans[$NewBan['BanID']] = $NewBan;

         $NewUsers = $this->SQL
            ->Select('u.UserID, u.Banned')
            ->From('User u')
            ->Where($this->BanWhere($NewBan))
            ->Get()->ResultArray();
         $NewUserIDs = ConsolidateArrayValuesByKey($NewUsers, 'UserID');
      } elseif (isset($OldBan['BanID'])) {
         unset($AllBans[$OldBan['BanID']]);
      }

      if ($OldBan) {
         // Get a list of users affected by the old ban.
         $OldUsers = $this->SQL
            ->Select('u.UserID, u.LastIPAddress, u.Name, u.Email, u.Banned')
            ->From('User u')
            ->Where($this->BanWhere($OldBan))
            ->Get()->ResultArray();
         $OldUserIDs = ConsolidateArrayValuesByKey($OldUsers, 'UserID');
      }

      // Check users that need to be unbanned.
      foreach ($OldUsers as $User) {
         if (in_array($User['UserID'], $NewUserIDs))
            continue;
         // TODO check the user against the other bans.
         $this->SaveUser($User, FALSE);
      }

      // Check users that need to be banned.
      foreach ($NewUsers as $User) {
         if ($User['Banned'])
            continue;
         $this->SaveUser($User, TRUE, $NewBan);
      }
   }