示例#1
0
        protected void btnRequestDualRole_Click(object sender, EventArgs e)
        {
            
                        

            if (User.IsInRole("client"))
            {
                int nifcheck = Users.CheckDuplicateNIF(NIFTitularOficina.Text);
                if (nifcheck == -1) { Response.Redirect("~/Error.aspx"); }
                else if (nifcheck == 0)
                {
                    Roles w = new Roles();
                    if (w.AddUserToRoleByID(User.Identity.GetUserId(), "workshop") == false) { Response.Redirect("~/Error.aspx"); }
                    if (AccStatus.LockAccount(User.Identity.GetUserId()) == false) { Response.Redirect("~/Error.aspx"); }
                    if (Users.UpdateWorkshopDetails(NomeOficina.Text, MoradaOficina.Text, DdlRegiao.SelectedValue, TelefoneOficina.Text, TitularOficina.Text, NIFTitularOficina.Text, User.Identity.GetUserId()) == false) { Response.Redirect("~/Error.aspx"); }
                    Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                    Response.Redirect("ValidationRequired.aspx");
                }
                else
                {
                    NIFServerValidator.IsValid = false;
                }
               
                
            }
            
        }
示例#2
0
        protected void LogIn(object sender, EventArgs e)
        {
            if (IsValid)
            {
                // Validate the user password
                var manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                var signinManager = Context.GetOwinContext().GetUserManager <ApplicationSignInManager>();


                // This doen't count login failures towards account lockout
                // To enable password failures to trigger lockout, change to shouldLockout: true
                var result = signinManager.PasswordSignIn(Email.Text, Password.Text, RememberMe.Checked, shouldLockout: true);

                switch (result)
                {
                case SignInStatus.Success:
                    if (AccStatus.CheckAccount(Email.Text) == false)
                    {
                        Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                        Response.Redirect("ValidationRequired.aspx");
                        return;
                    }
                    IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                    break;

                case SignInStatus.LockedOut:
                    Response.Redirect("/Account/Lockout");
                    break;

                case SignInStatus.RequiresVerification:
                    Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&RememberMe={1}",
                                                    Request.QueryString["ReturnUrl"],
                                                    RememberMe.Checked),
                                      true);
                    break;

                case SignInStatus.Failure:
                default:
                    FailureText.Text     = "Invalid login attempt";
                    ErrorMessage.Visible = true;
                    break;
                }
            }
        }
示例#3
0
        protected void GridViewToValidate_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ActivateAcc")
            {
                int         index = Convert.ToInt32(e.CommandArgument);
                GridViewRow row   = GridViewToValidate.Rows[index];
                string      id    = row.Cells[1].Text;

                if (AccStatus.EnableAccount(id) == false)
                {
                    Response.Redirect("~/Error.aspx");
                }
            }

            UpdateBadges();
            GridViewTotal.DataBind();
            GridViewToValidate.DataBind();
            EditTablesUpdatePanel.Update();
        }
 /// <summary>
 /// Override method of base class.
 /// </summary>
 protected override int CalculateBonusPoints(AccStatus status, decimal amount)
 {
     return((int)status * (int)(amount / 100));
 }
 /// <summary>
 /// Method contain logic of calculating bonus points.
 /// </summary>
 /// <param name="status">
 /// Status of current account.
 /// </param>
 /// <param name="amount">
 /// Amount money for operation.
 /// </param>
 /// <returns>
 /// Amount of bonus points.
 /// </returns>
 protected abstract int CalculateBonusPoints(AccStatus status, decimal amount);