Ejemplo n.º 1
0
        /// <summary>
        /// Generates a login card and presents it to the user.
        /// </summary>
        /// <param name="context">A <see cref="IDialogContext"/></param>
        /// <param name="result">A <see cref="IMessageActivity"/>.</param>
        /// <returns>A <see cref="Task"/>.</returns>
        public virtual async Task LogOnAsync(IDialogContext context, IMessageActivity result)
        {
            context.ThrowIfNull(nameof(context));
            result.ThrowIfNull(nameof(result));

            if (!context.UserData.TryGetValue("userData", out UserData data))
            {
                data = new UserData();
            }

            // Set pin.
            this.Pin = GeneratePin();
            data.Pin = this.Pin;

            context.UserData.SetValue("userData", data);

            var card = new LogOnCard(this.appId, this.appScope, new Uri(this.authorizeUrl), result.ChannelId, result.From.Id);

            var reply = context.MakeMessage();

            reply.Attachments.Add(card);

            await context.PostAsync(reply);

            context.Wait(this.PinReceivedAsync);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates a login card and presents it to the user.
        /// </summary>
        /// <param name="context">A <see cref="IDialogContext"/></param>
        /// <param name="result">A <see cref="IMessageActivity"/>.</param>
        /// <returns>A <see cref="Task"/>.</returns>
        public virtual async Task LogOnAsync(IDialogContext context, IMessageActivity result)
        {
            context.ThrowIfNull(nameof(context));
            result.ThrowIfNull(nameof(result));

            // Set pin.
            this.Pin = GeneratePin();
            context.UserData.SetPin(this.Pin);

            var vstsApplication = this.VstsApplicationRegistry.GetVstsApplicationRegistration(result.From.Id);

            var card = new LogOnCard(vstsApplication, result.ChannelId, result.From.Id);

            var reply = context.MakeMessage();

            reply.Attachments.Add(card);

            await context.PostAsync(reply);

            context.Wait(this.PinReceivedAsync);
        }
Ejemplo n.º 3
0
        public void Constructor()
        {
            var target = new LogOnCard("appId", "appScope", new Uri("https://authorize.url"), ChannelIds.Skype, "userId");

            target = new LogOnCard("appId", "appScope", new Uri("https://authorize.url"), ChannelIds.Msteams, "userId");
        }