Пример #1
0
        public async Task <bool> InvokeReturnPathAsync()
        {
            this.logger.WriteVerbose("InvokeReturnPath");

            var model = await this.AuthenticateAsync();

            var context = new YammerReturnEndpointContext(Context, model);

            context.SignInAsAuthenticationType = Options.SignInAsAuthenticationType;
            context.RedirectUri          = model.Properties.RedirectUri;
            model.Properties.RedirectUri = null;
            await Options.Provider.ReturnEndpoint(context);

            if (context.SignInAsAuthenticationType != null && context.Identity != null)
            {
                ClaimsIdentity signInIdentity = context.Identity;
                if (!string.Equals(signInIdentity.AuthenticationType, context.SignInAsAuthenticationType, StringComparison.Ordinal))
                {
                    signInIdentity = new ClaimsIdentity(signInIdentity.Claims, context.SignInAsAuthenticationType, signInIdentity.NameClaimType, signInIdentity.RoleClaimType);
                }
                Context.Authentication.SignIn(context.Properties, signInIdentity);
            }

            if (!context.IsRequestCompleted && context.RedirectUri != null)
            {
                if (context.Identity == null)
                {
                    // add a redirect hint that sign-in failed in some way
                    context.RedirectUri = WebUtilities.AddQueryString(context.RedirectUri, "error", "access_denied");
                }
                Response.Redirect(context.RedirectUri);
                context.RequestCompleted();
            }

            return(context.IsRequestCompleted);
        }
 public virtual Task ReturnEndpoint(YammerReturnEndpointContext context)
 {
     return(this.OnReturnEndpoint(context));
 }