Ejemplo n.º 1
0
        /// <summary>
        /// Runs the Profile action, taking the current user to the page for their profile in AD B2C
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="redirectUri"></param>
        public virtual void Profile(Controller controller, string redirectUri)
        {
            var settings    = AuthenticationPolicy.GetAuthenticationPolicyInfo(controller.Request.Url.Authority);
            var redirectUrl = settings?.RedirectUrl ?? redirectUri;

            controller.HttpContext.GetOwinContext().Authentication.Challenge(
                new AuthenticationProperties()
            {
                RedirectUri = redirectUrl
            }, settings?.ProfilePolicy ?? ProfilePolicyId);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Signs up the current user, creating a new account
        /// NOTE: You must implement your own user models and permissions, this is just authentication
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="redirectUri"></param>
        public virtual void SignUp(Controller controller, string redirectUri)
        {
            // To execute a policy, you simply need to trigger an OWIN challenge.
            // You can indicate which policy to use by specifying the policy id as the AuthenticationType
            var settings    = AuthenticationPolicy.GetAuthenticationPolicyInfo(controller.Request.Url.Authority);
            var redirectUrl = settings?.RedirectUrl ?? redirectUri;

            controller.HttpContext.GetOwinContext().Authentication.Challenge(
                new AuthenticationProperties()
            {
                RedirectUri = redirectUrl
            }, settings?.SignUpPolicy ?? SignUpPolicyId);
        }