setUserId()

in src/directLine.ts [1045:1060]


    setUserId(userId: string) {
        if (this.connectionStatus$.getValue() === ConnectionStatus.Online) {
            throw new Error('DirectLineJS: It is connected, we cannot set user id.');
        }

        const userIdFromToken = this.parseToken(this.token);
        if (userIdFromToken) {
            return console.warn('DirectLineJS: user id is already set in token, will ignore this user id.');
        }

        if (/^dl_/u.test(userId)) {
            return console.warn('DirectLineJS: user id prefixed with "dl_" is reserved and must be embedded into the Direct Line token to prevent forgery.');
        }

        this.userIdOnStartConversation = userId;
    }