コード例 #1
0
            /// <summary>
            /// 开启白名单
            /// </summary>
            /// <param name="type">白名单类型,USERNAME 为用户名、Email 为邮箱、Phone 为手机号。</param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public async Task Enable(WhitelistType type, CancellationToken cancellationToken = default)
            {
                var config = new RegisterWhiteListConfigInput();

                switch (type)
                {
                case WhitelistType.USERNAME:
                    config.UsernameEnabled = true;
                    break;

                case WhitelistType.EMAIL:
                    config.EmailEnabled = true;
                    break;

                case WhitelistType.PHONE:
                    config.PhoneEnabled = true;
                    break;

                default:
                    throw new AuthingException("不支持的白名单类型");
                }

                var param = new UpdateUserpoolParam(new UpdateUserpoolInput()
                {
                    Whitelist = config,
                });

                await client.GetAccessToken();

                await client.Request <UpdateUserpoolResponse>(param.CreateRequest(), cancellationToken);
            }
コード例 #2
0
            /// <summary>
            /// 开启白名单
            /// </summary>
            /// <param name="type">白名单类型,USERNAME 为用户名、Email 为邮箱、Phone 为手机号。</param>
            /// <param name="cancellationToken"></param>
            /// <returns></returns>
            public async Task Enable(WhitelistType type, CancellationToken cancellationToken = default)
            {
                var config = new RegisterWhiteListConfigInput
                {
                    EmailEnabled    = type == WhitelistType.EMAIL,
                    PhoneEnabled    = type == WhitelistType.PHONE,
                    UsernameEnabled = type == WhitelistType.USERNAME,
                };

                var param = new UpdateUserpoolParam(new UpdateUserpoolInput()
                {
                    Whitelist = config,
                });

                await client.Request <UpdateUserpoolResponse>(param.CreateRequest(), cancellationToken);

                // TODO: 缺少返回类型
            }