Create a new token record.
@param  \Kbwebs\MultiAuth\PasswordResets\CanResetPassword    $user
@param  string                                               $type
@return string
978095
public function create(CanResetPasswordContract $user, $type)
    {
        $email = $user->getEmailForPasswordReset();
        $this->deleteExisting($user, $type);
        // We will create a new, random token for the user so that we can e-mail them
        // a safe link to the password reset form. Then we will insert a record in
        // the database so that we can verify the token within the actual reset.
        $token = $this->createNewToken();
        $this->getTable()->insert($this->getPayload($email, $token, $type));
        return $token;
    }
753336
public static function createMultipleFromLogin($login, $type, $key = 0)
    {
        $passwords = array();
        $number    = count($login);
        $save      = $number;

        while ($number > 0) {
            while (true) {
                $password = self::createFromLogin($login[$save - $number], $type, $key);
                if (!in_array($password, $passwords)) {
                    $passwords[] = $password;
                    break;
                }
            }
            $number--;
        }
        return $passwords;
    }
1123959
public function setAuthentication($user, $password, $type = self::AUTH_TYPE_BASIC)
    {
        $this->setHeader(
            'Authorization',
            $this->makeAuthentication($user, $password, $type)
        );
    }
1129044
public static function login_user(\stdClass $user) {
        global $DB;

        // Regenerate session id and delete old session,
        // this helps prevent session fixation attacks from the same domain.

        $sid = session_id();
        session_regenerate_id(true);
        $DB->delete_records('sessions', array('sid'=>$sid));
        self::add_session_record($user->id);

        // Let enrol plugins deal with new enrolments if necessary.
        enrol_check_plugins($user);

        // Setup $USER object.
        self::set_user($user);
    }
436849
protected function createRequest($type, $url, $token)
    {
        return $this->client->createRequest($type, $url, $this->getDefaultHeaders($token));
    }
1160305
public function create($user, $password, $role = 'member', $sendEmail = false)
    {
        try {
            DB::transaction(function () use ($user, $password, $role, $sendEmail) {
                $this->userMeta->firstOrCreate([
                    'user_id' => $user->id
                ]);

                $this->assignRole($role, $user->id);

                if ($sendEmail) {
                    event(new UserRegisteredEmail($user, $password));
                }
            });

            $this->setAndSendUserActivationToken($user);

            return $user;
        } catch (Exception $e) {
            throw new Exception("We were unable to generate your profile, please try again later.", 1);
        }
    }
473158
public function createToken(UserInterface $user, string $operator = null): TokenInterface
    {
        return $this->getOperator($operator ?? $this->config->defaultOperator())->createToken($user);
    }
526009
public function create(CanVerifyEmailContract $user)
    {
        $email = $user->getEmailToVerify();

        $this->deleteExisting($user);

        // We will create a new, random token for the user so that we can e-mail them
        // a safe link to verify their email address. Then we will insert a record in
        // the database so that we can verify the token later.
        $token = $this->createNewToken();

        $this->getTable()->insert($this->getPayload($email, $token));

        return $token;
    }
764685
protected function createToken($user)
    {
        $token = $this->getToken();

        DB::table($this->table)->insert([
            'user_id'    => $user->id,
            'token'      => $token,
            'created_at' => Carbon::now()->toDateTimeString(),
        ]);

        return $token;
    }
473533
protected function resetPassword($user, $password)
    {
        $user->forceFill([
            'password' => bcrypt($password),
            'remember_token' => Str::random(60),
        ])->save();
    }
813767
protected function createToken($userId, $csrfToken, Carbon $expiration)
    {
        return JWT::encode([
            'sub' => $userId,
            'csrf' => $csrfToken,
            'expiry' => $expiration->getTimestamp(),
        ], $this->encrypter->getKey());
    }
1244049
public function validateToken(CanResetPasswordContract $user, array $credentials): bool
    {
        $payload = $this->buildPayload($user, $credentials['email'], $credentials['expiration']);

        return hash_equals($credentials['token'], hash_hmac('sha256', $payload, $this->getKey()));
    }
478739
protected function generateToken(SubjectContract $user)
    {
        $tokenGenerator = $this->getGenerator();
        $claims = $user->getJWTClaims();
        $claims['sub'] = $user->getJWTSubject();
        $claims[static::JWT_GUARD_CLAIM] = $this->id;
        if (!($token = $tokenGenerator($claims))) {
            throw new InvalidTokenException("Unable to generate token");
        }
        return $token;
    }
606843
public function exists(CanResetPasswordContract $user, $token)
    {
        $record = (array) $this->getTable()->where(
            'email', $user->getEmailForPasswordReset()
        )->first();

        return $record &&
               ! $this->tokenExpired($record['created_at']) &&
                 $this->hasher->check($token, $record['token']);
    }
1318682
public function privilegeKeyCreate(
        $type = Teamspeak::TOKEN_SERVERGROUP,
        $id1,
        $id2 = 0,
        $description = null,
        $customset = null
    ) {
        $token = $this->execute(
            "privilegekeyadd",
            array(
                "tokentype" => $type,
                "tokenid1" => $id1,
                "tokenid2" => $id2,
                "tokendescription" => $description,
                "tokencustomset" => $customset
            )
        )->toList();

        Signal::getInstance()->emit("notifyTokencreated", $this, $token["token"]);

        return $token["token"];
    }
635126
private static function createUserIdentifier($type, $value)
    {
        // If the user identifier type is a hashed type, normalize and hash the
        // value.
        if (0 === strpos($type, 'HASHED_')) {
            $value = hash('sha256', strtolower(trim($value)));
        }
        $userIdentifier = new UserIdentifier();
        $userIdentifier->setUserIdentifierType($type);
        $userIdentifier->setValue($value);

        return $userIdentifier;
    }
785491
public function deleteCodes4User($userId, $type)
    {
        $query = $this->createQueryBuilder('p')
            ->delete($this->getEntityName(), 'p')
            ->where('p.user = :user_id')
            ->setParameter('user_id', $userId)
            ->andWhere('p.type = :type')
            ->setParameter('type', $type)
            ->getQuery();

        return $query->execute();
    }