• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP generate_random_cleartext_password函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中generate_random_cleartext_password函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_random_cleartext_password函数的具体用法?PHP generate_random_cleartext_password怎么用?PHP generate_random_cleartext_password使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了generate_random_cleartext_password函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: cas_insertUser

/**
 * insert user into elgg user table
 *
 * Get user info from db
 * Tries to insert, otherwise return error
 *
 * @return user
 */
function cas_insertUser($username, $casUser, $config)
{
    //     $name = $attr['cn'];
    //     $uname = !empty($attr['textuid']) ? $attr['textuid'] : str_replace(".", "",$username);
    //     $email = $attr['mail'];
    $name = $casUser->name;
    $uname = !empty($casUser->username) ? $casUser->username : $username;
    $email = $casUser->email;
    $password = md5($uname . $email);
    $user = new ElggUser();
    $user->username = $uname;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = 2;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    $user->password = generate_user_password($user, $password);
    $user->save();
    $guid = $user->guid;
    $obj = get_entity($guid);
    if (isset($config->casadminuser) && $config->casadminuser == $username) {
        if ($obj instanceof ElggUser && $obj->canEdit()) {
            $obj->admin = 'yes';
            if ($obj->admin) {
                system_message(elgg_echo('admin:user:makeadmin:yes'));
            } else {
                register_error(elgg_echo('admin:user:makeadmin:no'));
            }
        } else {
            register_error(elgg_echo('admin:user:makeadmin:no'));
        }
    }
    return $user;
}
开发者ID:duanhv,项目名称:mdg-social,代码行数:42,代码来源:lib.php


示例2: testUpdateACL

 public function testUpdateACL()
 {
     // another fake user to test with
     $user = new ElggUser();
     $user->username = 'test_user_' . rand();
     $user->email = '[email protected]' . rand();
     $user->name = 'fake user';
     $user->access_id = ACCESS_PUBLIC;
     $user->salt = generate_random_cleartext_password();
     $user->password = generate_user_password($user, rand());
     $user->owner_guid = 0;
     $user->container_guid = 0;
     $user->save();
     $acl_id = create_access_collection('test acl');
     $member_lists = array(array($this->user->guid, $user->guid), array($user->guid), array($this->user->guid), array());
     foreach ($member_lists as $members) {
         $result = update_access_collection($acl_id, $members);
         $this->assertTrue($result);
         if ($result) {
             $q = "SELECT * FROM {$this->dbPrefix}access_collection_membership\n\t\t\t\t\tWHERE access_collection_id = {$acl_id}";
             $data = get_data($q);
             if (count($members) == 0) {
                 $this->assertFalse($data);
             } else {
                 $this->assertEqual(count($members), count($data));
             }
             foreach ($data as $row) {
                 $this->assertTrue(in_array($row->user_guid, $members));
             }
         }
     }
     delete_access_collection($acl_id);
     $user->delete();
 }
开发者ID:tjcaverly,项目名称:Elgg,代码行数:34,代码来源:ElggCoreAccessCollectionsTest.php


示例3: __construct

 /**
  * Called before each test object.
  */
 public function __construct()
 {
     $this->ia = elgg_set_ignore_access(TRUE);
     parent::__construct();
     $this->user = new ElggUser();
     $this->user->username = 'test_username_' . rand();
     $this->user->email = '[email protected]';
     $this->user->name = 'I am a Test User';
     $this->user->access_id = ACCESS_PUBLIC;
     $this->user->salt = generate_random_cleartext_password();
     $this->user->password = generate_user_password($this->user, "pass123");
     $this->user->container_guid = 0;
     $this->user->owner_guid = 0;
     $this->user->save();
     // all __construct() code should come after here
     $this->user2 = new ElggUser();
     // generating API key
     $keypair = create_api_user($CONFIG->site_id);
     if ($keypair) {
         $this->apikey = new ElggObject();
         $this->apikey->subtype = 'api_key';
         $this->apikey->access_id = ACCESS_PUBLIC;
         $this->apikey->title = "User web services";
         $this->apikey->public = $keypair->api_key;
         $this->apikey->save();
     }
 }
开发者ID:digecon,项目名称:elgg_web_services,代码行数:30,代码来源:user.php


示例4: elgg_set_user_password

/**
 * Set a user's password
 * 
 * @return bool
 * @since 1.8.0
 * @access private
 */
function elgg_set_user_password()
{
    $current_password = get_input('current_password');
    $password = get_input('password');
    $password2 = get_input('password2');
    $user_guid = get_input('guid');
    if (!$user_guid) {
        $user = elgg_get_logged_in_user_entity();
    } else {
        $user = get_entity($user_guid);
    }
    if ($user && $password) {
        // let admin user change anyone's password without knowing it except his own.
        if (!elgg_is_admin_logged_in() || elgg_is_admin_logged_in() && $user->guid == elgg_get_logged_in_user_guid()) {
            $credentials = array('username' => $user->username, 'password' => $current_password);
            try {
                pam_auth_userpass($credentials);
            } catch (LoginException $e) {
                register_error(elgg_echo('LoginException:ChangePasswordFailure'));
                return false;
            }
        }
        try {
            $result = validate_password($password);
        } catch (RegistrationException $e) {
            register_error($e->getMessage());
            return false;
        }
        if ($result) {
            if ($password == $password2) {
                $user->salt = generate_random_cleartext_password();
                // Reset the salt
                $user->password = generate_user_password($user, $password);
                if ($user->save()) {
                    system_message(elgg_echo('user:password:success'));
                    return true;
                } else {
                    register_error(elgg_echo('user:password:fail'));
                }
            } else {
                register_error(elgg_echo('user:password:fail:notsame'));
            }
        } else {
            register_error(elgg_echo('user:password:fail:tooshort'));
        }
    } else {
        // no change
        return null;
    }
    return false;
}
开发者ID:nachopavon,项目名称:Elgg,代码行数:58,代码来源:user_settings.php


示例5: createUser

 /**
  * Create a fake user
  *
  * @return ElggUser
  */
 public static function createUser()
 {
     $user = new ElggUser();
     $user->username = 'fake_user_' . rand();
     $user->email = '[email protected]' . rand();
     $user->name = 'fake user ' . rand();
     $user->access_id = ACCESS_PUBLIC;
     $user->salt = generate_random_cleartext_password();
     $user->password = generate_user_password($user, rand());
     $user->owner_guid = 0;
     $user->container_guid = 0;
     $user->save();
     return $user;
 }
开发者ID:juho-jaakkola,项目名称:hypeGallery,代码行数:19,代码来源:_lib.php


示例6: __construct

 /**
  * Called before each test object.
  */
 public function __construct()
 {
     parent::__construct();
     $this->user = new ElggUser();
     $this->user->username = 'fake_user_' . rand();
     $this->user->email = '[email protected]' . rand();
     $this->user->name = 'fake user ' . rand();
     $this->user->access_id = ACCESS_PUBLIC;
     $this->user->salt = generate_random_cleartext_password();
     $this->user->password = generate_user_password($this->user, rand());
     $this->user->owner_guid = 0;
     $this->user->container_guid = 0;
     $this->user->save();
 }
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:17,代码来源:ElggCoreAccessSQLTest.php


示例7: post

 /**
  * {@inheritdoc}
  */
 public function post(ParameterBag $params)
 {
     if (!elgg_get_config('allow_registration') && !elgg_trigger_plugin_hook('allow_registration', 'graph')) {
         throw new \RegistrationException(elgg_echo('registerdisabled'), 403);
     }
     $email = $params->email;
     $email_parts = explode('@', $params->email);
     $username = $params->username ?: Registration::generateUsername();
     $password = $params->password ?: generate_random_cleartext_password();
     $name = $params->name ?: array_shift($email_parts);
     $guid = register_user($username, $password, $name, $email);
     if (!$guid) {
         throw new RegistrationException(elgg_echo('registerbad'));
     }
     $new_user = get_entity($guid);
     $new_user->language = $params->language;
     $hook_params = array('user' => $new_user, 'password' => $password, 'friend_guid' => $this->graph->get($params->friend_uid)->guid, 'invitecode' => $params->invitecode);
     if (!elgg_trigger_plugin_hook('validate_registration', 'graph', null, true)) {
         // disable uservalidationbyemail
         elgg_unregister_plugin_hook_handler('register', 'user', 'uservalidationbyemail_disable_new_user');
     }
     $ia = elgg_set_ignore_access(true);
     $params->guid = $new_user->guid;
     if (!isset($params->access_id)) {
         $params->access_id = ACCESS_PRIVATE;
     }
     $ctrl = new UserProfile($this->request, $this->graph);
     $ctrl->put($params);
     elgg_set_ignore_access($ia);
     $return = array('nodes' => array($new_user));
     if (!elgg_trigger_plugin_hook('register', 'user', $hook_params, true)) {
         $ia = elgg_set_ignore_access(true);
         $new_user->delete();
         elgg_set_ignore_access($ia);
         throw new RegistrationException(elgg_echo('registerbad'));
     }
     if ($params->notify) {
         $subject = elgg_echo('useradd:subject', array(), $new_user->language);
         $body = elgg_echo('useradd:body', array($name, elgg_get_site_entity()->name, elgg_get_site_entity()->url, $username, $password), $new_user->language);
         notify_user($new_user->guid, elgg_get_site_entity()->guid, $subject, $body);
     }
     return $return;
 }
开发者ID:hypejunction,项目名称:hypegraph,代码行数:46,代码来源:SiteUsers.php


示例8: elgg_set_user_password

/**
 * Set a user's password
 * 
 * @return bool
 * @since 1.8.0
 */
function elgg_set_user_password()
{
    $current_password = get_input('current_password');
    $password = get_input('password');
    $password2 = get_input('password2');
    $user_id = get_input('guid');
    if (!$user_id) {
        $user = elgg_get_logged_in_user_entity();
    } else {
        $user = get_entity($user_id);
    }
    if ($user && $password != "") {
        // let admin user change anyone's password without knowing it except his own.
        if (!elgg_is_admin_logged_in() || elgg_is_admin_logged_in() && $user->guid == elgg_get_logged_in_user_guid()) {
            $credentials = array('username' => $user->username, 'password' => $current_password);
            if (!pam_auth_userpass($credentials)) {
                register_error(elgg_echo('user:password:fail:incorrect_current_password'));
                return false;
            }
        }
        if (strlen($password) >= 4) {
            if ($password == $password2) {
                $user->salt = generate_random_cleartext_password();
                // Reset the salt
                $user->password = generate_user_password($user, $password);
                if ($user->save()) {
                    system_message(elgg_echo('user:password:success'));
                    return true;
                } else {
                    register_error(elgg_echo('user:password:fail'));
                }
            } else {
                register_error(elgg_echo('user:password:fail:notsame'));
            }
        } else {
            register_error(elgg_echo('user:password:fail:tooshort'));
        }
    } else {
        // no change
        return null;
    }
    return false;
}
开发者ID:redvabel,项目名称:Vabelgg,代码行数:49,代码来源:user_settings.php


示例9: handle

 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $admin = $this->option('admin');
     $notify = $this->option('notify');
     $email = $this->ask('Enter account email: ');
     list($username, ) = explode('@', $email, 2);
     $username = $this->ask("Enter account username [{$username}]: ", $username);
     $password = $this->ask('Enter account password (leave empty to autegenerate): ', null, true, false);
     if (empty($password)) {
         $password = generate_random_cleartext_password();
     }
     $name = $this->ask("Enter account display name [{$username}]: ", $username);
     $guid = register_user($username, $password, $name, $email);
     $user = get_entity($guid);
     $user->admin_created = true;
     elgg_set_user_validation_status($user->guid, true, 'cli');
     $params = ['user' => $user, 'password' => $password];
     if (!elgg_trigger_plugin_hook('register', 'user', $params, TRUE)) {
         $ia = elgg_set_ignore_access(true);
         $user->delete();
         elgg_set_ignore_access($ia);
         throw new RegistrationException(elgg_echo('registerbad'));
     }
     if ($admin) {
         $ia = elgg_set_ignore_access(true);
         $user->makeAdmin();
         elgg_set_ignore_access($ia);
     }
     if ($notify) {
         $subject = elgg_echo('useradd:subject', array(), $user->language);
         $body = elgg_echo('useradd:body', array($name, elgg_get_site_entity()->name, elgg_get_site_entity()->url, $username, $password), $user->language);
         notify_user($user->guid, elgg_get_site_entity()->guid, $subject, $body, ['password' => $password]);
     }
     if ($user->isAdmin()) {
         system_message("New admin user has been registered [guid: {$user->guid}]");
     } else {
         system_message("New user has been registered [guid: {$user->guid}]");
     }
 }
开发者ID:hypejunction,项目名称:elgg-cli,代码行数:42,代码来源:AddUserCommand.php


示例10: simplesaml_register_user

/**
 * Register a user in Elgg based on information provided by the Service Provider (SP).
 *
 * @param string $name        the (display)name of the new user
 * @param string $email       the email address of the user
 * @param string $saml_source the name of the SP this information came from
 * @param bool   $validate    do we need to validate the email address of this new users
 * @param string $username    the username provided by the SP (optional)
 *
 * @return false|ElggUser
 */
function simplesaml_register_user($name, $email, $saml_source, $validate = false, $username = '')
{
    if (empty($name) || empty($email) || empty($saml_source)) {
        return false;
    }
    // check which username to use
    if (!empty($username)) {
        // make sure the username is unique
        $username = simplesaml_generate_unique_username($username);
    } else {
        // create a username from email
        $username = simplesaml_generate_username_from_email($email);
    }
    if (empty($username)) {
        register_error(elgg_echo("registration:usernamenotvalid"));
        return false;
    }
    // generate a random password
    $password = generate_random_cleartext_password();
    try {
        $user_guid = register_user($username, $password, $name, $email);
        if (empty($user_guid)) {
            return false;
        }
        $new_user = get_user($user_guid);
        if (!$validate) {
            // no need for extra validation. We trust this user
            elgg_set_user_validation_status($new_user->getGUID(), true, 'simplesaml');
        }
        $params = ['user' => $new_user, 'password' => $password, 'friend_guid' => null, 'invitecode' => null];
        if (!elgg_trigger_plugin_hook('register', 'user', $params, true)) {
            register_error(elgg_echo('registerbad'));
        } else {
            return $new_user;
        }
    } catch (Exception $e) {
        register_error($e->getMessage());
    }
    return false;
}
开发者ID:coldtrick,项目名称:simplesaml,代码行数:51,代码来源:functions.php


示例11: twitter_api_create_user

/**
 * Create a new user from Twitter information
 * 
 * @param object $twitter Twitter OAuth response
 * @return ElggUser
 */
function twitter_api_create_user($twitter)
{
    // check new registration allowed
    if (!twitter_api_allow_new_users_with_twitter()) {
        register_error(elgg_echo('registerdisabled'));
        forward();
    }
    // Elgg-ify Twitter credentials
    $username = $twitter->screen_name;
    while (get_user_by_username($username)) {
        // @todo I guess we just hope this is good enough
        $username = $twitter->screen_name . '_' . rand(1000, 9999);
    }
    $password = generate_random_cleartext_password();
    $name = $twitter->name;
    $user = new ElggUser();
    $user->username = $username;
    $user->name = $name;
    $user->access_id = ACCESS_PUBLIC;
    $user->salt = _elgg_generate_password_salt();
    $user->password = generate_user_password($user, $password);
    $user->owner_guid = 0;
    $user->container_guid = 0;
    if (!$user->save()) {
        register_error(elgg_echo('registerbad'));
        forward();
    }
    return $user;
}
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:35,代码来源:twitter_api.php


示例12: cas_insertUser

/**
 * Insert user into elgg user table using info from ldap
 * Tries to insert, otherwise returns error
 *
 * @return user or error (false?)
 */
function cas_insertUser($username, $ldap_attributes, $config)
{
    // name is 'cn' in ldap
    $name = $ldap_attributes['cn'];
    // remove periods from ldap username
    // ex. anthony.hopkins -> anthonyhopkins
    $uname = !empty($ldap_attributes['textUid']) ? $ldap_attributes['textUid'] : str_replace(".", "", $username);
    $email = $ldap_attributes['mail'];
    $user = new ElggUser();
    $user->username = $uname;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = 2;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    // cas users don't need password stored locally
    // so create an invalid password
    // a real password can be saved at a later time if they become a local user
    $user->password = md5(time());
    //generate_user_password($user, $password);
    // returns guid or false
    $guid = $user->save();
    if (!$guid) {
        return false;
    }
    $obj = get_entity($guid);
    if (isset($config->casadminuser) && $config->casadminuser == $uname) {
        if ($obj instanceof \ElggUser) {
            //set context for permissions check
            elgg_push_context('au_cas_auth_make_admin');
            if (make_user_admin($guid)) {
                system_message(elgg_echo('admin:user:makeadmin:yes'));
            } else {
                register_error(elgg_echo('admin:user:makeadmin:no'));
            }
            // set context back
            elgg_pop_context();
        } else {
            register_error(elgg_echo('admin:user:makeadmin:no'));
        }
    }
    return $user;
}
开发者ID:AU-Landing-Project,项目名称:au_cas_auth,代码行数:49,代码来源:functions.php


示例13: register_user

/**
 * Registers a user, returning false if the username already exists
 *
 * @param string $username              The username of the new user
 * @param string $password              The password
 * @param string $name                  The user's display name
 * @param string $email                 Their email address
 * @param bool   $allow_multiple_emails Allow the same email address to be
 *                                      registered multiple times?
 * @param int    $friend_guid           GUID of a user to friend once fully registered
 * @param string $invitecode            An invite code from a friend
 *
 * @return int|false The new user's GUID; false on failure
 */
function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $friend_guid = 0, $invitecode = '')
{
    // Load the configuration
    global $CONFIG;
    // no need to trim password.
    $username = trim($username);
    $name = trim(strip_tags($name));
    $email = trim($email);
    // A little sanity checking
    if (empty($username) || empty($password) || empty($name) || empty($email)) {
        return false;
    }
    // Make sure a user with conflicting details hasn't registered and been disabled
    $access_status = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    if (!validate_email_address($email)) {
        throw new RegistrationException(elgg_echo('registration:emailnotvalid'));
    }
    if (!validate_password($password)) {
        throw new RegistrationException(elgg_echo('registration:passwordnotvalid'));
    }
    if (!validate_username($username)) {
        throw new RegistrationException(elgg_echo('registration:usernamenotvalid'));
    }
    if ($user = get_user_by_username($username)) {
        throw new RegistrationException(elgg_echo('registration:userexists'));
    }
    if (!$allow_multiple_emails && get_user_by_email($email)) {
        throw new RegistrationException(elgg_echo('registration:dupeemail'));
    }
    access_show_hidden_entities($access_status);
    // Create user
    $user = new ElggUser();
    $user->username = $username;
    $user->email = $email;
    $user->name = $name;
    $user->access_id = ACCESS_PUBLIC;
    $user->salt = generate_random_cleartext_password();
    // Note salt generated before password!
    $user->password = generate_user_password($user, $password);
    $user->owner_guid = 0;
    // Users aren't owned by anyone, even if they are admin created.
    $user->container_guid = 0;
    // Users aren't contained by anyone, even if they are admin created.
    $user->language = get_current_language();
    $user->save();
    // If $friend_guid has been set, make mutual friends
    if ($friend_guid) {
        if ($friend_user = get_user($friend_guid)) {
            if ($invitecode == generate_invite_code($friend_user->username)) {
                $user->addFriend($friend_guid);
                $friend_user->addFriend($user->guid);
                // @todo Should this be in addFriend?
                add_to_river('river/relationship/friend/create', 'friend', $user->getGUID(), $friend_guid);
                add_to_river('river/relationship/friend/create', 'friend', $friend_guid, $user->getGUID());
            }
        }
    }
    // Turn on email notifications by default
    set_user_notification_setting($user->getGUID(), 'email', true);
    return $user->getGUID();
}
开发者ID:riggo,项目名称:Elgg,代码行数:76,代码来源:users.php


示例14: elgg_tokeninput_get_secret

/**
 * Returns a secret key to sign ajax requests
 * @return string
 */
function elgg_tokeninput_get_secret()
{
    $secret = elgg_get_plugin_setting('__secret', 'elgg_tokeninput');
    if (!$secret) {
        $secret = generate_random_cleartext_password();
        elgg_set_plugin_setting('__secret', $secret, 'elgg_tokeninput');
    }
    return $secret;
}
开发者ID:n8b,项目名称:VMN,代码行数:13,代码来源:tokeninput.php


示例15: simplesaml_register_user

/**
 * Register a user in Elgg based on information provided by the Service Provider (SP).
 *
 * @param string $name        the (display)name of the new user
 * @param string $email       the email address of the user
 * @param string $saml_source the name of the SP this information came from
 * @param bool   $validate    do we need to validate the email address of this new users
 * @param string $username    the username provided by the SP (optional)
 *
 * @return bool|ElggUser the new user, false on failure
 */
function simplesaml_register_user($name, $email, $saml_source, $validate = false, $username = "")
{
    $result = false;
    if (!empty($name) && !empty($email) && !empty($saml_source)) {
        // check which username to use
        if (!empty($username)) {
            // make sure the username is unique
            $username = simplesaml_generate_unique_username($username);
        } else {
            // create a username from email
            $username = simplesaml_generate_username_from_email($email);
        }
        if (!empty($username)) {
            // generate a random password
            $password = generate_random_cleartext_password();
            try {
                $user_guid = register_user($username, $password, $name, $email);
                if (!empty($user_guid)) {
                    $new_user = get_user($user_guid);
                    if (!$validate) {
                        // no need for extra validation. We trust this user
                        elgg_set_user_validation_status($new_user->getGUID(), true, "simplesaml");
                    }
                    $params = array("user" => $new_user, "password" => $password, "friend_guid" => null, "invitecode" => null);
                    if (!elgg_trigger_plugin_hook("register", "user", $params, true)) {
                        register_error(elgg_echo("registerbad"));
                    } else {
                        $result = $new_user;
                    }
                }
            } catch (Exception $e) {
                register_error($e->getMessage());
            }
        } else {
            register_error(elgg_echo("registration:usernamenotvalid"));
        }
    }
    return $result;
}
开发者ID:pleio,项目名称:simplesaml,代码行数:50,代码来源:functions.php


示例16: import_to_stormpath

function import_to_stormpath()
{
    $dbprefix = elgg_get_config('dbprefix');
    $subject = elgg_get_plugin_setting('import_subject', PLUGIN_ID);
    $message = elgg_get_plugin_setting('import_message', PLUGIN_ID);
    $site = elgg_get_site_entity();
    $site_url = elgg_get_site_url();
    if (!$subject || !$message) {
        error_log('no subject/message');
        return true;
    }
    if (is_elgg18()) {
        $name_id = add_metastring('__stormpath_user');
        $value_id = add_metastring(1);
    } else {
        $name_id = elgg_get_metastring_id('__stormpath_user');
        $value_id = elgg_get_metastring_id(1);
    }
    $options = array('type' => 'user', 'joins' => array("LEFT JOIN {$dbprefix}metadata md ON md.entity_guid = e.guid AND md.name_id = {$name_id}"), 'wheres' => array('md.name_id IS NULL'), 'limit' => false);
    $batch = new \ElggBatch('elgg_get_entities', $options);
    $batch->setIncrementOffset(false);
    foreach ($batch as $user) {
        // search stormpath for a matching account
        $application = get_application();
        $accts = $application->getAccounts(array('email' => $user->email));
        $already_exists = false;
        foreach ($accts as $a) {
            $user->__stormpath_user = $a->href;
            error_log('set user ' . $user->username . ': ' . $a->href);
            $already_exists = true;
            break;
        }
        if ($already_exists) {
            continue;
        }
        // change it locally
        $password = generate_random_cleartext_password();
        $user->salt = _elgg_generate_password_salt();
        $user->password = generate_user_password($user, $password);
        $user->save();
        error_log('adding to stormpath ' . $user->email);
        $result = add_to_stormpath($user, $password);
        if ($result) {
            // notify them of the change
            // replace tokens in the message
            $message_m = str_replace('{{password}}', $password, $message);
            $message_m = str_replace('{{name}}', $user->name, $message_m);
            $message_m = str_replace('{{username}}', $user->username, $message_m);
            $message_m = str_replace('{{email}}', $user->email, $message_m);
            $message_m = str_replace('{{forgot_password}}', $site_url . 'forgotpassword', $message_m);
            $message_m = str_replace('{{site_email}}', $site->email, $message_m);
            $message_m = str_replace('{{site_url}}', $site_url, $message_m);
            notify_user($user->guid, $site->guid, $subject, $message_m, null, 'email');
        }
    }
}
开发者ID:arckinteractive,项目名称:elgg_stormpath,代码行数:56,代码来源:functions.php


示例17: socialink_linkedin_create_user

/**
 * Create a user based on LinkedIn information
 *
 * @param string $token LinkedIn access token
 *
 * @return bool|ElggUser
 */
function socialink_linkedin_create_user($token)
{
    if (empty($token) || !is_array($token)) {
        return false;
    }
    $keys = socialink_linkedin_available();
    if (empty($keys)) {
        return false;
    }
    $keys["oauth_token"] = $token["oauth_token"];
    $keys["oauth_secret"] = $token["oauth_token_secret"];
    $api = socialink_linkedin_get_api_object($keys);
    if (empty($api)) {
        return false;
    }
    try {
        // get user data
        $response = $api->profile("~:(first-name,last-name,email-address)");
    } catch (Exception $e) {
    }
    $api_result = socialink_linkedin_verify_response($response);
    if (empty($api_result)) {
        return false;
    }
    $api_result = json_decode($api_result);
    // build user information
    $name = $api_result->firstName . " " . $api_result->lastName;
    $email = $api_result->emailAddress;
    $pwd = generate_random_cleartext_password();
    $username = socialink_create_username_from_email($email);
    // check email address
    if (get_user_by_email($email)) {
        register_error(elgg_echo("socialink:networks:create_user:error:email"));
        return false;
    }
    try {
        // register user
        $user_guid = register_user($username, $pwd, $name, $email);
        if (empty($user_guid)) {
            return false;
        }
        // show hidden entities
        $access = access_get_show_hidden_status();
        access_show_hidden_entities(true);
        $user = get_user($user_guid);
        if (empty($user)) {
            access_show_hidden_entities($access);
            return false;
        }
        // save user tokens
        elgg_set_plugin_user_setting("linkedin_oauth_token", $token["oauth_token"], $user_guid, "socialink");
        elgg_set_plugin_user_setting("linkedin_oauth_secret", $token["oauth_token_secret"], $user_guid, "socialink");
        // no need for uservalidationbyemail
        elgg_unregister_plugin_hook_handler("register", "user", "uservalidationbyemail_disable_new_user");
        // sync user data
        socialink_linkedin_sync_profile_metadata($user->getGUID());
        // trigger hook for registration
        $params = array("user" => $user, "password" => $pwd, "friend_guid" => 0, "invitecode" => "");
        if (elgg_trigger_plugin_hook("register", "user", $params, true) !== false) {
            // return the user
            access_show_hidden_entities($access);
            return $user;
        }
        // restore hidden entities
        access_show_hidden_entities($access);
    } catch (Exception $e) {
    }
    return false;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:76,代码来源:linkedin.php


示例18: str_replace

 $userlogin = str_replace(' ', '-', $user_profile->displayName);
 if (!$userlogin) {
     $userlogin = 'user-' . rand(10000, 99999);
 }
 while (get_user_by_username($userlogin)) {
     $userlogin = str_replace(' ', '-', $user_profile->displayName) . '-' . rand(1000, 9999);
 }
 $password = generate_random_cleartext_password();
 $username = $user_profile->displayName;
 $useremail = $user_profile->email;
 $user = new ElggUser();
 $user->username = $userlogin;
 $user->name = $username;
 $user->access_id = ACCESS_PUBLIC;
 $user->email = $user_profile->email;
 $user->salt = generate_random_cleartext_password();
 $user->password = generate_user_password($user, $password);
 $user->owner_guid = 0;
 $user->container_guid = 0;
 if (!$user->save()) {
     register_error(elgg_echo('registerbad'));
 }
 // register user && provider
 elgg_set_plugin_user_setting('uid', $user_uid, $user->guid, 'elgg_social_login');
 elgg_set_plugin_user_setting('provider', $provider, $user->guid, 'elgg_social_login');
 // notice && login
 if (elgg_get_plugin_setting("social_login_notify", "social_login") == "yes") {
     if (strtolower($provider) == "facebook" || strtolower($provider) == "linkedin") {
         if (empty($user->last_login)) {
             $message = elgg_echo('social:register:joined');
             $adapter->setUserStatus($message);
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:31,代码来源:authenticate.php


示例19: executeNewPasswordReset

 /**
  * Validate and change password for a user.
  *
  * @param int    $user_guid The user id
  * @param string $conf_code Confirmation code as sent in the request email.
  * @param string $password  Optional new password, if not randomly generated.
  *
  * @return bool True on success
  */
 function executeNewPasswordReset($user_guid, $conf_code, $password = null)
 {
     $user_guid = (int) $user_guid;
     $user = get_entity($user_guid);
     if ($password === null) {
         $password = generate_random_cleartext_password();
         $reset = true;
     } else {
         $reset = false;
     }
     if (!$user instanceof \ElggUser) {
         return false;
     }
     $saved_code = $user->getPrivateSetting('passwd_conf_code');
     $code_time = (int) $user->getPrivateSetting('passwd_conf_time');
     $codes_match = _elgg_services()->crypto->areEqual($saved_code, $conf_code);
     if (!$saved_code || !$codes_match) {
         return false;
     }
     // Discard for security if it is 24h old
     if (!$code_time || $code_time < time() - 24 * 60 * 60) {
         return false;
     }
     if (!$this->forcePasswordReset($user, $password)) {
         return false;
     }
     remove_private_setting($user_guid, 'passwd_conf_code');
     remove_private_setting($user_guid, 'passwd_conf_time');
     // clean the logins failures
     reset_login_failure_count($user_guid);
     $ns = $reset ? 'resetpassword' : 'changepassword';
     $message = _elgg_services()->translator->translate("email:{$ns}:body", array($user->username, $password), $user->language);
     $subject = _elgg_services()->translator->translate("email:{$ns}:subject", array(), $user->language);
     notify_user($user->guid, elgg_get_site_entity()->guid, $subject, $message, array(), 'email');
     return true;
 }
开发者ID:ibou77,项目名称:elgg,代码行数:45,代码来源:PasswordService.php


示例20: execute_new_password_request

/**
 * Validate and execute a password reset for a user.
 *
 * @param int    $user_guid The user id
 * @param string $conf_code Confirmation code as sent in the request email.
 *
 * @return mixed
 */
function execute_new_password_request($user_guid, $conf_code)
{
    global $CONFIG;
    $user_guid = (int) $user_guid;
    $user = get_entity($user_guid);
    if ($user instanceof ElggUser) {
        $saved_code = $user->getPrivateSetting('passwd_conf_code');
        if ($saved_code && $saved_code == $conf_code) {
            $password = generate_random_cleartext_password();
            if (force_user_password_reset($user_guid, $password)) {
                remove_private_setting($user_guid, 'passwd_conf_code');
                // clean the logins failures
                reset_login_failure_count($user_guid);
                $email = '<div style="color:#333;font-size:16px;">' . elgg_echo('email:resetpassword:body', array($user->name, $password)) . '</div>';
                //return notify_user($user->guid, $CONFIG->site->guid,
                //	elgg_echo('email:resetpassword:subject'), $email, array(), 'email');
                $site_name = elgg_get_site_entity()->name;
                return zhgroups_send_email($site_name, $user->email, elgg_echo('email:resetpassword:subject', array($site_name)), $email);
            }
        }
    }
    return FALSE;
}
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:31,代码来源:users.php



注:本文中的generate_random_cleartext_password函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP generate_random_password函数代码示例发布时间:2022-05-15
下一篇:
PHP generate_quickjump_cache函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap