コード例 #1
0
ファイル: Register.aspx.cs プロジェクト: adrianypc/CodeClay
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            var manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>();
            var user          = new ApplicationUser()
            {
                UserName = Email.Text, Email = Email.Text, PhoneNumber = PhoneNumber.Text
            };
            IdentityResult result = manager.Create(user, Password.Text);

            if (result.Succeeded)
            {
                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                string code        = manager.GenerateEmailConfirmationToken(user.Id);
                string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
                manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

                signInManager.SignIn(user, isPersistent: false, rememberBrowser: false);
                MyWebUtils.ShowAlert(Page, "Please check your Inbox for an email confirming your registration", "Login.aspx");

                //IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                ErrorMessage.Text = result.Errors.FirstOrDefault();
            }
        }
コード例 #2
0
ファイル: Login.aspx.cs プロジェクト: adrianypc/CodeClay
        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterHyperLink.NavigateUrl = "Register";
            // Enable this once you have account confirmation enabled for password reset functionality
            ForgotPasswordHyperLink.NavigateUrl = "Forgot";
            OpenAuthLogin.ReturnUrl             = Request.QueryString["ReturnUrl"];
            var returnUrl = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);

            if (!String.IsNullOrEmpty(returnUrl))
            {
                RegisterHyperLink.NavigateUrl += "?ReturnUrl=" + returnUrl;
            }

            string applicationName = MyWebUtils.Application;

            if (!String.IsNullOrEmpty(applicationName))
            {
                Title = string.Format("Log in to {0}", applicationName);
            }

            if (UiApplication.Me != null)
            {
                CiApplication ciApplication = UiApplication.Me.CiApplication;
                if (ciApplication != null)
                {
                    string themeColor = ciApplication.ThemeColor;

                    if (!String.IsNullOrEmpty(themeColor))
                    {
                        btnLogin.ForeColor = Color.White;
                        btnLogin.BackColor = MyWebUtils.ToColor(themeColor);
                    }
                }
            }
        }