示例#1
0
        protected void Register_Click(object sender, EventArgs e)
        {
            string username = Username.Text;
            string email    = EmailID.Text;
            string pwd      = Password.Text;

            using (UserProfileServiceReference.UserProfileManagementServiceClient client = new UserProfileServiceReference.UserProfileManagementServiceClient())
            {
                string status_msg     = null;
                bool   username_taken = client.IsUsernameTaken(username);
                bool   email_exists   = client.UserWithEmailIdExists(email);
                if (username_taken)
                {
                    status_msg = "This username is unavailable :/ \n";
                }
                if (email_exists)
                {
                    status_msg += "An account with this email already exists -.- \n";
                }
                if (status_msg == null)
                {
                    UserProfileServiceReference.User user = new UserProfileServiceReference.User();
                    user.Username = username;
                    user.Password = pwd;
                    user.EmailID  = email;
                    client.RegisterUser(user);
                    StatusMsg.ForeColor = System.Drawing.Color.Green;
                    StatusMsg.Text      = "Registration Successful! Redirecting you to Login page ...";
                    Response.AddHeader("REFRESH", "3;URL=Login.aspx");
                }
                else
                {
                    StatusMsg.ForeColor = System.Drawing.Color.Red;
                    StatusMsg.Text      = status_msg;
                }
            }
        }
        protected void SendToken_Click(object sender, EventArgs e)
        {
            string emailID = EmailID.Text;

            try
            {
                using (UserProfileServiceReference.UserProfileManagementServiceClient client = new UserProfileServiceReference.UserProfileManagementServiceClient())
                {
                    client.SendPasswordResetToken(emailID);
                }
                Response.Redirect("~/ResetPassword.aspx");
            }
            catch (FaultException ex)
            {
                ErrorLabel.Text = ex.Reason.ToString();
            }
            catch (Exception ex)
            {
                ErrorLabel.Text  = "Some unexpected error occurred :/";
                ErrorLabel.Text += ex.Message;
            }
        }
示例#3
0
        protected void ResetPass_Click(object sender, EventArgs e)
        {
            string npwd     = NewPassword.Text;
            string token    = Token.Text;
            string email_id = EmailID.Text;

            try
            {
                using (UserProfileServiceReference.UserProfileManagementServiceClient client = new UserProfileServiceReference.UserProfileManagementServiceClient())
                {
                    client.ResetPassword(token, email_id, npwd);
                    ErrorLabel.ForeColor = System.Drawing.Color.Green;
                    ErrorLabel.Text      = "Password Reset Successfully! Redirecting you to Login page ...";
                    Response.AddHeader("REFRESH", "3;URL=Login.aspx");
                }
            }
            catch (FaultException ex)
            {
                ErrorLabel.Text = ex.Reason.ToString();
            }
            catch (Exception ex)
            {
                ErrorLabel.Text  = "Some unexpected error occurred :/";
                ErrorLabel.Text += ex.Message;
            }
        }