generate unique user_id
424589
function getUIDCallback (err, uid) {
		if (err) {
			return onDone('UID_ERROR');
		}
		var ip = (extra) ? extra.conn.host : "server";
		// NOTE: by default a user is a normal user, user 'groups' can later be customized
		var reg = {
			uid: 		uid,
			account:	args.account,
			password:	l_encryptPass(args.password),
			email:		args.email,
			// verify:		{email_verify: false, phone_verify: false},
			tokens: 	{reset: '', pass: {}},
			enc_type:	l_enc_type,
			control:	{groups: args.groups || [], permissions: []},
			data: 		args.data || {},
			login: 		{IP: ip, count: 1}
		};

		// special handling (by default 'admin' account is special and will be part of the 'admin' group by default
		if (!args.authWP && reg.account === 'admin') {
			reg.control.groups.push('admin');
		}

		LOG.warn('creating new account [' + args.account + ']...', l_name);
		l_accounts.add(reg, function (err) {
			if (err) {
				return onDone('DB_ERROR', err);
			}
			// register success
			LOG.warn('account register success', l_name);
			onDone(null);
		});
	}
537688
async def create(cls, user_id: Union[int, str],
                     is_active: bool = True,
                     is_admin: bool = False,
                     resource_policy: str = None,
                     rate_limit: int = None,
                     fields: Iterable[str] = None) -> dict:
        '''
        
        '''
        if fields is None:
            fields = ('access_key', 'secret_key')
        uid_type = 'Int!' if isinstance(user_id, int) else 'String!'
        q = 'mutation($user_id: {0}, $input: KeyPairInput!) {{'.format(uid_type) + \
            '  create_keypair(user_id: $user_id, props: $input) {' \
            '    ok msg keypair { $fields }' \
            '  }' \
            '}'
        q = q.replace('$fields', ' '.join(fields))
        variables = {
            'user_id': user_id,
            'input': {
                'is_active': is_active,
                'is_admin': is_admin,
                'resource_policy': resource_policy,
                'rate_limit': rate_limit,
            },
        }
        rqst = Request(cls.session, 'POST', '/admin/graphql')
        rqst.set_json({
            'query': q,
            'variables': variables,
        })
        async with rqst.fetch() as resp:
            data = await resp.json()
            return data['create_keypair']
654642
def _generate_session_id(self):
        """"""

        while True:
            rand = os.urandom(16)
            now = time.time()
            secret_key = self._config.secret_key
            session_id = hashlib.sha1(("%s%s%s%s" % (rand, now, utils.safestr(web.ctx.ip), secret_key)).encode("utf-8"))
            session_id = session_id.hexdigest()
            if session_id not in self.store:
                break
        return session_id
840986
def id_unique(dict_id, name, lineno):
    """"""
    if dict_id in name_dict:
        global error_occurred
        error_occurred = True
        print(
            "ERROR - {0:s} definition {1:s} at line {2:d} conflicts with {3:s}"
            .format(name, dict_id, lineno, name_dict[dict_id]))
        return False
    else:
        return True
492489
public function forceUniqueUserNames()
    {
        //Check for not unique index in user table
        $userLoginIndex = $this->db->get_row("SHOW INDEX FROM " . $this->db->users . " WHERE Key_name = 'user_login_key' AND Non_unique = 1");

        if (is_object($userLoginIndex) && !empty($userLoginIndex)) {

            //Remove old index
            $this->db->query("ALTER TABLE " . $this->db->users . " DROP INDEX user_login_key");

            //Add new index
            $this->db->query("ALTER TABLE " . $this->db->users . " ADD UNIQUE user_login_key (user_login);");
        }
    }
322403
def get_id(self):
        """"""

        # This function is used by Flask-Login to store a User ID securely as a browser cookie.
        # The last part of the password is included to invalidate tokens when password change.
        # user_id and password_ends_with are encrypted, timestamped and signed.
        # This function works in tandem with UserMixin.get_user_by_token()
        user_manager = current_app.user_manager

        user_id = self.id
        password_ends_with = '' if user_manager.USER_ENABLE_AUTH0 else self.password[-8:]
        user_token = user_manager.generate_token(
            user_id,               # User ID
            password_ends_with,    # Last 8 characters of user password
        )
        # print("UserMixin.get_id: ID:", self.id, "token:", user_token)
        return user_token
54053
def uniquelogins(sessions):
    
    # sessions = LoginSession.query.order_by(LoginSession.started_at.asc()).all()
    if not sessions:
        return [], [], []
    dates = {}
    for session in sessions:
        user = session.user
        # time value is discarded to aggregate on days only
        date = session.started_at.strftime("%Y/%m/%d")

        if date not in dates:
            dates[date] = set()  # we want unique users on a given day
            dates[date].add(user)
        else:
            dates[date].add(user)

    daily = []
    weekly = []
    monthly = []

    for date in sorted(dates.keys()):
        # print u"{} : {}".format(date, len(dates[date]))
        date_epoch = unix_time_millis(datetime.strptime(date, "%Y/%m/%d"))
        daily.append({"x": date_epoch, "y": len(dates[date])})

    # first_day = data[0]['x']
    # last_day = data[-1]['x']

    daily_serie = pd.Series(dates)
    # convert the index to Datetime type
    daily_serie.index = pd.DatetimeIndex(daily_serie.index)
    # calculate the values instead of users lists
    daily_serie = daily_serie.apply(lambda x: len(x))

    # GroupBy Week/month, Thanks Panda
    weekly_serie = daily_serie.groupby(pd.Grouper(freq="W")).aggregate(numpysum)
    monthly_serie = daily_serie.groupby(pd.Grouper(freq="M")).aggregate(numpysum)

    for date, value in weekly_serie.items():
        try:
            value = int(value)
        except ValueError:
            continue
        date_epoch = unix_time_millis(date)
        weekly.append({"x": date_epoch, "y": value})

    for date, value in monthly_serie.items():
        try:
            value = int(value)
        except ValueError:
            continue
        date_epoch = unix_time_millis(date)
        monthly.append({"x": date_epoch, "y": value})

    return daily, weekly, monthly
1003203
public function generate(): string
    {
        $uniqueId = uniqid((string) rand(), true);

        return (string) md5($uniqueId);
    }
912344
def user_to_uid(user):
    '''
    
    '''
    if user is None:
        user = salt.utils.user.get_user()

    return salt.utils.win_dacl.get_sid_string(user)
835477
def generate_random_id(size=6, chars=string.ascii_uppercase + string.digits):
    """"""
    return "".join(random.choice(chars) for x in range(size))
851422
def unique_id(self) -> str:
        
        if not self._unique_id:
            id_list = [item.mediaid for item in self.get_items()]
            id_list.sort()
            self._unique_id = str().join([str(self.owner_id)] + list(map(str, id_list)))
        return self._unique_id
700805
public void createUniqueData()
    {
        LoginGenerator.LoginRecord unique_login;
        unique_login = random_login_generator.createUniqueLogin("voltdb", true);
        doLogin(unique_login);
        unique_login = random_login_generator.createUniqueLogin("voltdb2", false);
        doLogin(unique_login);
    }
1045015
def get_user_by_id(self, uid):
        """"""
        self.logger.debug('User %s has been found in database', uid)
        return dict(uid=uid, password_hash='secret_hash')
1368872
function generateUniqueHubId() {
		//TODO ensure generated hub id is unique (not in db)
		// do {
		var length = 10;
		var letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV0123456789';
		var s = '';
		for (var i=0; i<length; i++) {
			s += letters.charAt(Math.floor(Math.random() * letters.length));
		}
		// } while (s == 0); //TODO actually check in db for value existence

		return s;
	}
372952
def check_unique(self):
        """"""
        emails = yield self.view.values(key=self.email)
        user_id = getattr(self, 'id', None)
        users = {x for x in emails if x != user_id and x}

        if users:
            raise exceptions.ValidationError(
                "User with email '{}' already exists".format(self.email))
727890
private function _generateUniqueId()
    {
        $rand = uniqid(rand(10, 99));
        $time = microtime(true);
        $micro = sprintf('%06d', ($time - floor($time)) * 1000000);
        $date = new DateTime(date('Y-m-d H:i:s.' . $micro, $time));
        return sha1($date->format('YmdHisu'));
    }
723022
protected function uniqId()
    {
        $exists = true;

        while ($exists) {
            $key = $this->generateKey();
            $exists = $this->find()->where(['id' => $key])->first();
        }

        return $key;
    }