Пример #1
0
        public bool IsAllowChangePWD(AdminPassword admin, out string errorMsg)
        {
            errorMsg = "";
            string sql = $@"select iIsAllowChangePWD from  P_Admin WHERE  iAdminID ={ admin.iAdminID }";

            using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.GisPlateform))
            {
                try
                {
                    List <dynamic> list = conn.Query <dynamic>(sql).ToList();
                    if (list.Count > 0 && list[0].iIsAllowChangePWD == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception e)
                {
                    errorMsg = e.Message;
                    return(false);
                }
            }
        }
Пример #2
0
 public void StartPage()
 {
     status.Text = "";
     this.Show();
     mainWindow.IsEnabled = false;
     AdminPassword.Focus();
 }
Пример #3
0
        public bool UpdateUserPassword(AdminPassword admin, out string errorMsg)
        {
            errorMsg = "";
            string updateSql = @"UPDATE P_Admin
   SET cAdminPassWord = @cAdminPassWord
      
 WHERE  iAdminID = @iAdminID ";

            using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.GisPlateform))
            {
                //conn.Open();
                using (var transaction = conn.BeginTransaction())
                {
                    try
                    {
                        var i = conn.Execute(updateSql, admin, transaction);
                        transaction.Commit();
                        return(i > 0);
                    }
                    catch (Exception e)
                    {
                        transaction.Rollback();
                        errorMsg = e.Message;
                        return(false);
                    }
                }
            }
        }
Пример #4
0
 private void User_OnMessageInitReceivedCallback(Message message)
 {
     if (message.Content == "admin")
     {
         user.Init(AdminPassword.SecureToString());
     }
 }
Пример #5
0
 public static void validateAdminPassword(AdminPassword adminPassword)
 {
     if (adminPassword.Id == 0)
     {
         throw new DataValidationException($"Id does not exists");
     }
     if (!string.IsNullOrEmpty(adminPassword.Password))
     {
         throw new DataValidationException($"Password does not exists");
     }
 }
 public IEnumerable <SqlDeploymentAction> Compile(SqlDeploymentCompileContext context)
 {
     yield return(new SqlDeploymentDistributorAction(context.InstanceName)
     {
         DatabaseName = DatabaseName?.Expand(context),
         AdminPassword = AdminPassword?.Expand(context),
         MinimumRetention = MinimumRetention?.Expand <int>(context),
         MaximumRetention = MaximumRetention?.Expand <int>(context),
         HistoryRetention = HistoryRetention?.Expand <int>(context),
         SnapshotPath = SnapshotPath?.Expand(context),
     });
 }
Пример #7
0
 public IActionResult EditPassword(AdminPassword adminPassword)
 {
     try
     {
         Validator.validateAdminPassword(adminPassword);
         DASuperAdmin dASuperAdmin = new DASuperAdmin();
         return(this.OKResponse(dASuperAdmin.EditPassword(_context, adminPassword, User.ToAppUser()) ? "Updated Successfully" : "Updation Failed"));
     }
     catch (DataValidationException ex)
     {
         return(this.KnowOperationError(ex.Message));
     }
 }
Пример #8
0
 private void VerifyAdmin_Button_Click(object sender, RoutedEventArgs e)
 {
     if (databaseConnection.verifyUser(AdminPassword.Password.ToString().Trim()))
     {
         newUser = new NewUser(this, mainWindow, databaseConnection);
         newUser.StartPage();
         mainWindow.IsEnabled = false;
     }
     else
     {
         status.Text = "Wrong password";
         AdminPassword.Clear();
     }
 }
Пример #9
0
        public MessageEntity ChangePassword([FromBody] AdminPassword admin)
        {
            if (admin == null)
            {
                return(MessageEntityTool.GetMessage(ErrorType.FieldError));
            }

            #region   modify by lsl 20190806 增加旧密码验证
            if (string.IsNullOrEmpty(admin.cAdminName))
            {
                return(MessageEntityTool.GetMessage(ErrorType.OprationError, "", "用户名不能为空"));
            }
            if (string.IsNullOrEmpty(admin.oldcAdminPassWord))
            {
                return(MessageEntityTool.GetMessage(ErrorType.OprationError, "", "密码不能为空"));
            }
            var adminmodel = base.CommonDAL.GetUserInfo(admin.cAdminName, admin.oldcAdminPassWord, out string errorMsg);
            //旧密码输入错误
            if (adminmodel == null)
            {
                return(MessageEntityTool.GetMessage(ErrorType.OprationError, "", "原密码验证错误"));
            }
            //是否允许修改密码验证
            var isallow = base.CommonDAL.IsAllowChangePWD(admin, out string errMsg1);
            //不允许
            if (!isallow)
            {
                return(MessageEntityTool.GetMessage(ErrorType.OprationError, "", "用户不允许修改密码"));
            }
            #endregion

            var entity = base.CommonDAL.UpdateUserPassword(admin, out string errMsg);
            if (entity)
            {
                return(MessageEntityTool.GetMessage(1));
            }
            else
            {
                if (string.IsNullOrEmpty(errMsg))
                {
                    return(MessageEntityTool.GetMessage(ErrorType.FieldError, "", "没有该用户"));
                }
                else
                {
                    return(MessageEntityTool.GetMessage(ErrorType.SqlError, errMsg));
                }
            }
        }
Пример #10
0
        public async Task <IActionResult> SetNewPasswordForAdmin(AdminPassword model)
        {
            var user = await _context.ApplicationUsers
                       .FirstOrDefaultAsync(x => x.IdForVerification == model.Id);

            if (user == null)
            {
                return(NotFound());
            }

            user.EmailConfirmed    = true;
            user.IdForVerification = null;

            var token = await _userManager.GeneratePasswordResetTokenAsync(user);

            var result = await _userManager.ResetPasswordAsync(user, token, model.Password);

            await _context.SaveChangesAsync();

            return(Ok(new { message = "Email verified." }));
        }
        public void SeedUsers(DealDoubleContext context)
        {
            var usersStore   = new UserStore <DealDoubleUser>(context);
            var usersManager = new UserManager <DealDoubleUser>(usersStore);

            var admin = new DealDoubleUser();

            admin.Email    = "*****@*****.**";
            admin.UserName = "******";
            var password = AdminPassword.GetAdminPassword();

            if (usersManager.FindByEmail(admin.Email) == null)
            {
                var result = usersManager.Create(admin, password);

                if (result.Succeeded)
                {
                    //add necessary roles to admin
                    usersManager.AddToRole(admin.Id, "Admin");
                    usersManager.AddToRole(admin.Id, "Moderator");
                    usersManager.AddToRole(admin.Id, "User");
                }
            }
        }
Пример #12
0
        public async Task <ActionResult> Login([Bind(Include = "UserName, Password, RememberMe, _ReturnUrl")] LoginViewModel model)
        {
            // The submitted data should be valid.
            if (ModelState.IsValid)
            {
                // Allow default user to access the application for creating Administrator account.
                // Check for provided values are DefaultUsername & DefaultPassword to allow them access the application until the Administrator account is created.
                if (model.UserName.ToLower() == AdminUsername.ToLower() && model.Password == AdminPassword.ToLower())
                {
                    // If 'true' check whether a Administrator account is exists in the database or not.
                    var User = await db.Users.Where(x => x.UserName.ToLower() == model.UserName.ToLower()).FirstOrDefaultAsync();

                    // If the account doesn't exists allow them to continue the user creation process. Otherwise skip the user creation process.
                    if (User == null)
                    {
                        // Find the current step of the process
                        var InitStep = await db.InitStep.Where(x => x.Mode == model.UserName).FirstOrDefaultAsync();

                        // If no step where found Call ProcessStep to continue the process
                        if (InitStep == null)
                        {
                            await ProcessStep(model);

                            return(RedirectToAction("Init"));
                        }
                        // Otherwise check whether the steps are completed or not.
                        else if (InitStep.Auth <= 4)
                        {
                            // If not secure the Code and set as cookie and let them proceed.
                            HttpContext.SetSecuredSessionCookie(_SessionName, InitStep.Code);
                            return(RedirectToAction("Init"));
                        }
                    }
                }

                // If the account is not default account then authenticate the user
                // BUG: if (await AuthenticateUser(model.UserName, model.Password, model.RememberMe))
                // FIX: User name should be in lowercase. 12/12/2014.
                if (await AuthenticateUser(model.UserName.ToLower(), model.Password, model.RememberMe))
                {
                    // If authenticated redirect to Index or ReturnUrl
                    return(RedirectToLocal(HttpUtility.UrlDecode(model._ReturnUrl)));
                }
            }

            TempData.SetError("Invalid user name or password.", SetInfo);
            return(View(model));
        }