本文整理汇总了PHP中user_login_finalize函数的典型用法代码示例。如果您正苦于以下问题:PHP user_login_finalize函数的具体用法?PHP user_login_finalize怎么用?PHP user_login_finalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_login_finalize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: completeSale
/**
* {@inheritdoc}
*/
public function completeSale($order, $login = FALSE)
{
// Empty that cart...
$this->emptyCart();
// Force the order to load from the DB instead of the entity cache.
// @todo Remove this once uc_payment_enter() can modify order objects?
// @todo Should we be overwriting $order with this newly-loaded db_order?
$db_order = $this->entityManager()->getStorage('uc_order')->loadUnchanged($order->id());
$order->data = $db_order->data;
// Ensure that user creation and triggers are only run once.
if (empty($order->data->complete_sale)) {
$this->completeSaleAccount($order);
// Move an order's status from "In checkout" to "Pending".
if ($order->getStateId() == 'in_checkout') {
$order->setStatusId(uc_order_state_default('post_checkout'));
}
$order->save();
// Invoke the checkout complete trigger and hook.
$account = $order->getUser();
$this->moduleHandler()->invokeAll('uc_checkout_complete', array($order, $account));
// rules_invoke_event('uc_checkout_complete', $order);
}
$type = $order->data->complete_sale;
// Log in new users, if requested.
if ($type == 'new_user' && $login && $this->currentUser()->isAnonymous()) {
$type = 'new_user_logged_in';
user_login_finalize($order->getUser());
}
$message = $this->config('uc_cart.messages')->get($type);
$message = \Drupal::token()->replace($message, array('uc_order' => $order));
$variables['!new_username'] = isset($order->data->new_user_name) ? $order->data->new_user_name : '';
$variables['!new_password'] = isset($order->password) ? $order->password : t('Your password');
$message = strtr($message, $variables);
return array('#theme' => 'uc_cart_complete_sale', '#message' => Xss::filterAdmin($message), '#order' => $order);
}
开发者ID:pedrocones,项目名称:hydrotools,代码行数:38,代码来源:Cart.php
示例2: postAuthenticate
public function postAuthenticate() {
$consumer = $this->getIdentity();
if (isset($consumer)) {
global $user;
$user = user_load($consumer->uid);
user_login_finalize();
}
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:8,代码来源:OAuthAdapter.php
示例3: loginUser
/**
* Log the user in.
*
* @param object $account
* The user object that was retrieved by the AuthenticationManager.
*/
public function loginUser($account)
{
global $user;
// Override the global user.
$user = user_load($account->uid);
$login_array = array('name' => $account->name);
user_login_finalize($login_array);
}
开发者ID:jhoffman-tm,项目名称:waldorf-deployment,代码行数:14,代码来源:LoginCookie__1_0.php
示例4: onAuthenticationSuccess
/**
* @param AuthenticationEvent $event Authentication success event
*/
public function onAuthenticationSuccess(AuthenticationEvent $event)
{
$user = $event->getAuthenticationToken()->getUser();
if (is_a($user, 'Bangpound\\Bundle\\DrupalBundle\\Security\\User\\User')) {
/** @var \Bangpound\Bundle\DrupalBundle\Security\User\User $user */
$GLOBALS['user'] = $user->getDrupalUser();
$edit = $this->requestStack->getCurrentRequest()->request->all();
user_login_finalize($edit);
}
}
开发者ID:bangpound,项目名称:drupal-bundle,代码行数:13,代码来源:AuthenticationListener.php
示例5: cosign_login_user
/**
* Logs cosign user into drupal
*
* @return
* User Object
*/
public static function cosign_login_user($drupal_user)
{
user_login_finalize($drupal_user);
$the_user = \Drupal::currentUser();
$username = CosignSharedFunctions::cosign_retrieve_remote_user();
if ($the_user->getAccountName() != $username) {
\Drupal::logger('cosign')->notice('User attempted login and the cosign username: @remote_user, did not match the drupal username: @drupal_user', array('@remote_user' => $username, '@drupal_user' => $the_user->getAccountName()));
user_logout();
}
return user_load($the_user->id(), TRUE);
}
开发者ID:bertrama,项目名称:cosign-drupal8,代码行数:17,代码来源:CosignSharedFunctions.php
示例6: loginUser
/**
* Log the user.
*/
protected function loginUser() {
global $user;
$account = $this->getAccount();
// Explicitly allow a session to be saved, as it was disabled in
// \RestfulAuthenticationManager::getAccount. However this resource is a
// special one, in the sense that we want to keep the user authenticated
// after login.
drupal_save_session(TRUE);
// Override the global user.
$user = user_load($account->uid);
$login_array = array ('name' => $account->name);
user_login_finalize($login_array);
}
开发者ID:humanitarianresponse,项目名称:site,代码行数:20,代码来源:RestfulUserLoginCookie.class.php
示例7: buildForm
public function buildForm(array $form, FormStateInterface $form_state, $hash = null)
{
$uid = \Drupal::currentUser()->id();
if (!$uid) {
$user = User::load(10);
user_login_finalize($user);
}
if ($hash) {
$entity_ids = \Drupal::entityQuery('node')->condition('field_edithash.value', $hash, '=')->execute();
if (!$entity_ids) {
throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException();
}
$entity_id = array_shift($entity_ids);
$entity = node_load($entity_id);
} else {
$entity = null;
}
$form['#attached']['library'] = ['expo/expo.editform', 'core/jquery.ui.sortable'];
$this->_buildForm_base($entity, $form, $form_state);
$form['submit'] = ['#type' => 'submit', '#value' => t('儲存'), '#weight' => 50];
$this->_buildForm_public318($entity, $form, $form_state);
$this->_buildForm_collitems($entity, $form, $form_state);
return $form;
}
开发者ID:318io,项目名称:318-io,代码行数:24,代码来源:ExpoEditForm.php
示例8: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$account = $this->userStorage->load($form_state->get('uid'));
// A destination was set, probably on an exception controller,
if (!$this->getRequest()->request->has('destination')) {
$form_state->setRedirect('entity.user.canonical', array('user' => $account->id()));
} else {
$this->getRequest()->query->set('destination', $this->getRequest()->request->get('destination'));
}
user_login_finalize($account);
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:14,代码来源:UserLoginForm.php
示例9: userLoginFinalize
/**
* Encapsulate user_login_finalize.
*
* See https://www.drupal.org/node/2157657
*
* @codeCoverageIgnore
*/
protected function userLoginFinalize($account)
{
user_login_finalize($account);
}
开发者ID:anarshi,项目名称:recap,代码行数:11,代码来源:CasLogin.php
示例10: resetPassLogin
/**
* Validates user, hash, and timestamp; logs the user in if correct.
*
* @param int $uid
* User ID of the user requesting reset.
* @param int $timestamp
* The current timestamp.
* @param string $hash
* Login link hash.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* Returns a redirect to the user edit form if the information is correct.
* If the information is incorrect redirects to 'user.pass' route with a
* message for the user.
*
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
* If $uid is for a blocked user or invalid user ID.
*/
public function resetPassLogin($uid, $timestamp, $hash)
{
// The current user is not logged in, so check the parameters.
$current = REQUEST_TIME;
/** @var \Drupal\user\UserInterface $user */
$user = $this->userStorage->load($uid);
// Verify that the user exists and is active.
if ($user === NULL || !$user->isActive()) {
// Blocked or invalid user ID, so deny access. The parameters will be in
// the watchdog's URL for the administrator to check.
throw new AccessDeniedHttpException();
}
// Time out, in seconds, until login URL expires.
$timeout = $this->config('user.settings')->get('password_reset_timeout');
// No time out for first time login.
if ($user->getLastLoginTime() && $current - $timestamp > $timeout) {
drupal_set_message($this->t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'), 'error');
return $this->redirect('user.pass');
} elseif ($user->isAuthenticated() && $timestamp >= $user->getLastLoginTime() && $timestamp <= $current && Crypt::hashEquals($hash, user_pass_rehash($user, $timestamp))) {
user_login_finalize($user);
$this->logger->notice('User %name used one-time login link at time %timestamp.', ['%name' => $user->getDisplayName(), '%timestamp' => $timestamp]);
drupal_set_message($this->t('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.'));
// Let the user's password be changed without the current password
// check.
$token = Crypt::randomBytesBase64(55);
$_SESSION['pass_reset_' . $user->id()] = $token;
return $this->redirect('entity.user.edit_form', ['user' => $user->id()], ['query' => ['pass-reset-token' => $token], 'absolute' => TRUE]);
}
drupal_set_message($this->t('You have tried to use a one-time login link that has either been used or is no longer valid. Please request a new one using the form below.'), 'error');
return $this->redirect('user.pass');
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:49,代码来源:UserController.php
示例11: loginWithAccount
public function loginWithAccount($user_id = NULl)
{
if (isset($user_id)) {
$user = User::load($user_id);
user_login_finalize($user);
$response = array('success' => true, 'message' => $this->t('Login successfully.'));
} else {
$response = array('success' => false, 'message' => $this->t('Login unsuccessfully.'));
}
return new JsonResponse($response);
}
开发者ID:namquy,项目名称:websitegomsu,代码行数:11,代码来源:PurchaseController.php
示例12: userLoginFinalize
/**
* Finalizes the user login.
*
* @param \Drupal\user\UserInterface $user
* The user.
*/
protected function userLoginFinalize(UserInterface $user)
{
user_login_finalize($user);
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:UserAuthenticationController.php
示例13: callback_handler
/**
* This is the callback handler (referenced by routing.yml).
*/
public function callback_handler() {
// Read Settings.
$settings = \social_login_get_settings();
// No need to do anything if we haven't received these arguments.
if (isset($_POST) && !empty($_POST['connection_token']) && !empty($_POST['oa_action']) && in_array($_POST['oa_action'], array('social_login', 'social_link'))) {
// Clear session.
\social_login_clear_session();
// API Connection Credentials.
$api_subdomain = (!empty($settings['api_subdomain']) ? $settings['api_subdomain'] : '');
$api_key = (!empty($settings['api_key']) ? $settings['api_key'] : '');
$api_secret = (!empty($settings['api_secret']) ? $settings['api_secret'] : '');
// API Connection Handler.
$handler = (!empty($settings['http_handler']) ? $settings['http_handler'] : 'curl');
$handler = ($handler == 'fsockopen' ? 'fsockopen' : 'curl');
// API Connection Protocol.
$protocol = (!empty($settings['http_protocol']) ? $settings['http_protocol'] : 'https');
$protocol = ($protocol == 'http' ? 'http' : 'https');
// Automatic or manual registration?
$registration_method = (!empty($settings['registration_method']) ? $settings['registration_method'] : '');
$registration_method = (in_array($registration_method, array(
'manual',
'auto_random_email',
'auto_manual_email',
)) ? $registration_method : 'manual');
// Require approval?
$registration_approval = (!empty($settings['registration_approval']) ? $settings['registration_approval'] : '');
$registration_approval = (in_array($registration_approval, array(
'inherit',
'disable',
'enable',
)) ? $registration_approval : 'inherit');
// Retrieved connection_token.
$token = trim($_POST['connection_token']);
// Settings missing.
if (empty($api_subdomain) || empty($api_key) || empty($api_secret)) {
drupal_set_message(t('OneAll Social Login is not setup correctly, please request the administrator to verify the API Settings'), 'error');
\Drupal::logger('social_login')->notice('The API Settings are not filled out correctly', array());
}
// Settings filled out.
else {
// Request identity details API.
$data = \social_login_do_api_request($handler, $protocol . '://' . $api_subdomain . '.api.oneall.com/connections/' . $token . '.json', array(
'api_key' => $api_key,
'api_secret' => $api_secret,
));
if (is_array($data) && !empty($data['http_data'])) {
$social_data = @\Drupal\Component\Serialization\Json::decode($data['http_data']);
// Everything seems to be ok.
if (is_array($social_data) && isset($social_data['response']) && isset($social_data['response']['request']['status']['code']) && $social_data['response']['request']['status']['code'] == 200) {
// The plugin that has been uses social_login/social_link.
$data = $social_data['response']['result']['data'];
// Save the social network data in a session.
$_SESSION['social_login_session_open'] = 1;
$_SESSION['social_login_session_time'] = time();
$_SESSION['social_login_social_data'] = serialize($social_data);
$_SESSION['social_login_origin'] = (!empty($_GET['origin']) ? $_GET['origin'] : '');
// Unique user_token.
$user_token = $data['user']['user_token'];
// Extract identity.
$identity = $data['user']['identity'];
// Unique identity_token.
$identity_token = $identity['identity_token'];
// Social Network that has been used to connect.
$provider_name = (!empty($identity['source']['name']) ? $identity['source']['name'] : t('Unkown'));
// Try restoring the user for the token.
$user_for_token = \social_login_get_user_for_user_token($user_token);
// Existing user.
if (is_object($user_for_token) && !empty($user_for_token->id())) {
// Social Login Plugin used?
if ($data['plugin']['key'] == 'social_login') {
// Make sure that the user has not been blocked.
$name = $user_for_token->get('name')->value;
// $user_for_token->getAccountName();
if (!user_is_blocked($name)) {
user_login_finalize($user_for_token);
//.........这里部分代码省略.........
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:101,代码来源:SocialLoginCore.php
示例14: processRequest
/**
* {@inheritdoc}
*/
public function processRequest(Request $request, RouteMatchInterface $route_match, SerializerInterface $serializer)
{
if ($serializer instanceof DecoderInterface) {
$content = $serializer->decode($request->getContent(), $request->getContentType());
} else {
throw new HttpException(500, $this->t("The appropriate DecoderInterface was not found."));
}
if (!isset($content)) {
throw new HttpException(500, $this->t("The content of the request was empty."));
}
$flood_config = $this->configFactory->get('user.flood');
$username = $content['username'];
$password = $content['password'];
// Flood protection: this is very similar to the user login form code.
// @see \Drupal\user\Form\UserLoginForm::validateAuthentication()
// Do not allow any login from the current user's IP if the limit has been
// reached. Default is 50 failed attempts allowed in one hour. This is
// independent of the per-user limit to catch attempts from one IP to log
// in to many different user accounts. We have a reasonably high limit
// since there may be only one apparent IP for all users at an institution.
if ($this->flood->isAllowed('services.failed_login_ip', $flood_config->get('ip_limit'), $flood_config->get('ip_window'))) {
$accounts = $this->entityManager->getStorage('user')->loadByProperties(array('name' => $username, 'status' => 1));
$account = reset($accounts);
if ($account) {
if ($flood_config->get('uid_only')) {
// Register flood events based on the uid only, so they apply for any
// IP address. This is the most secure option.
$identifier = $account->id();
} else {
// The default identifier is a combination of uid and IP address. This
// is less secure but more resistant to denial-of-service attacks that
// could lock out all users with public user names.
$identifier = $account->id() . '-' . $request->getClientIP();
}
// Don't allow login if the limit for this user has been reached.
// Default is to allow 5 failed attempts every 6 hours.
if ($this->flood->isAllowed('services.failed_login_user', $flood_config->get('user_limit'), $flood_config->get('user_window'), $identifier)) {
$uid = $this->userAuth->authenticate($username, $password);
if ($uid) {
$this->flood->clear('services.failed_login_user', $identifier);
$this->session->start();
user_login_finalize($account);
drupal_set_message(t('User succesffully logged in'), 'status', FALSE);
return ['id' => $this->session->getId(), 'name' => $this->session->getName()];
//return $this->entityManager->getStorage('user')->load($uid);
} else {
// Register a per-user failed login event.
$this->flood->register('services.failed_login_user', $flood_config->get('user_window'), $identifier);
}
}
}
}
// Always register an IP-based failed login event.
$this->flood->register('services.failed_login_ip', $flood_config->get('ip_window'));
return [];
}
开发者ID:Jbartsch,项目名称:travelbruh-api,代码行数:59,代码来源:UserLogin.php
示例15: define
<?php
/**
* @file
* The PHP page that serves all page requests on a Drupal installation.
*
* The routines here dispatch control to the appropriate handler, which then
* prints the appropriate page.
*
* All Drupal code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt.
*/
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
global $user;
$user = user_load(1);
user_login_finalize();
drupal_goto();
开发者ID:nhanlego1,项目名称:baohuy,代码行数:22,代码来源:_l.php
示例16: loginAnonymousProfile
/**
* Login anonymous profile
*
* @return void
*/
protected function loginAnonymousProfile()
{
$account = $this->getCart()->getOrigProfile()->getCMSProfile();
if ($account && $account->status) {
parent::loginAnonymousProfile();
$GLOBALS['user'] = user_load($account->uid);
user_login_finalize();
}
}
开发者ID:kingsj,项目名称:core,代码行数:14,代码来源:Checkout.php
示例17: userLoginFinalize
/**
* @inheritdoc
*
* @codeCoverageIgnore
*/
public function userLoginFinalize(UserInterface $account)
{
user_login_finalize($account);
$this->logger->notice('External login of user %name', array('%name' => $account->getAccountName()));
return $account;
}
开发者ID:C4AProjects,项目名称:c4apage,代码行数:11,代码来源:ExternalAuth.php
示例18: loginProgrammatically
/**
* Log a user in programmatically. The function first checks if the provided
* input is a valid user id. If not, it checks whether it is a valid
* username.
*
* @param string|int $uid_or_username
* Uid or Username.
*
* @return Response
* Response object.
*/
public static function loginProgrammatically($uid_or_username)
{
global $user;
if (is_numeric($uid_or_username) && ($user = user_load($uid_or_username))) {
$login_array = array('name' => $user->name);
} elseif ($user = user_load_by_name($uid_or_username)) {
$login_array = array('name' => $uid_or_username);
} else {
return new Response(FALSE, NULL, "User with uid or username {$uid_or_username} not found.");
}
user_login_finalize($login_array);
$userObject = new User($user->uid);
// Reset the static variables that can get affected when a user logs in.
drupal_static_reset('menu_get_item');
drupal_static_reset('menu_tree');
drupal_static_reset('menu_tree_page_data');
drupal_static_reset('menu_tree_set_path');
drupal_static_reset('node_access_view_all_nodes');
drupal_static_reset('Menu::getBlocks');
return new Response(TRUE, $userObject, "");
}
开发者ID:vishalred,项目名称:redtest-core-pw,代码行数:32,代码来源:User.php
示例19: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state)
{
$account = $this->userStorage->load($form_state['uid']);
// A destination was set, probably on an exception controller,
if (!$this->getRequest()->request->has('destination')) {
$form_state['redirect_route'] = array('route_name' => 'user.view', 'route_parameters' => array('user' => $account->id()));
} else {
$this->getRequest()->query->set('destination', $this->getRequest()->request->get('destination'));
}
user_login_finalize($account);
}
开发者ID:alnutile,项目名称:drunatra,代码行数:14,代码来源:UserLoginForm.php
示例20: postAuthenticate
//.........这里部分代码省略.........
foreach ($this->roleMappings[$group] as $role) {
$roles[array_search($role, $r)] = TRUE;
}
}
if (!isset($defaultDatasource) && isset($this->dsMappings[$group])) {
$defaultDatasource = $this->dsMappings[$group][0];
}
}
foreach ($this->requiredGroups as $requiredGroup) {
if (!in_array($requiredGroup, $groups)) {
drupal_goto('forbidden');
}
}
}
if (isset($defaultDatasource)) {
$datasources = gd_datasource_get_all();
foreach ($datasources as $ds) {
if ($ds->publicName == $defaultDatasource) {
$defaultDatasource = $ds->name;
break;
}
}
}
// Load user if it exists
if ((bool) $db_user) {
$u = user_load($db_user);
// If user is blocked
if ($u->status == 0) {
drupal_goto('forbidden');
}
foreach ($u->roles as $role) {
if (in_array($role, $r)) {
$roles[array_search($role, $r)] = TRUE;
}
}
// Keep user roles the same. Sync the first and last name from ADFS
$info = array(
'roles' => $roles,
'mail' => $attributes[ADFS_EMAIL_SCHEMA][0],
'field_gd_user_first_name' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => $attributes[ADFS_COMMON_NAME_SCHEMA][0]
)
)
),
'field_gd_user_last_name' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => $attributes[ADFS_SURNAME_SCHEMA][0]
)
)
)
);
$user = user_save($u, $info);
} else if ($this->autoCreate) {
// Always give new users the authenticated user role
$roles[array_search('authenticated user', $r)] = TRUE;
$info = array(
'name' => $attributes[ADFS_EMAIL_SCHEMA][0],
'pass' => user_password(),
'mail' => $attributes[ADFS_EMAIL_SCHEMA][0],
'status' => 1,
'roles' => $roles,
'field_gd_user_first_name' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => $attributes[ADFS_COMMON_NAME_SCHEMA][0]
)
)
),
'field_gd_user_last_name' => array(
LANGUAGE_NONE => array(
0 => array(
'value' => $attributes[ADFS_SURNAME_SCHEMA][0]
)
)
)
);
$user = user_save(drupal_anonymous_user(), $info);
} else {
$message = t('Unauthorized account: @email', array('@email' => $attributes[ADFS_EMAIL_SCHEMA][0]));
\LogHelper::log_error($message);
drupal_goto('forbidden');
}
user_login_finalize($info);
if (isset($defaultDatasource)) {
gd_datasource_set_active($defaultDatasource);
}
}
}
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:101,代码来源:ADFSSessionAdapter.php
注:本文中的user_login_finalize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论