public IActionResult ChangePassword(string pass1, string pass2) { if (pass1 != pass2) { ViewBag.result += @"Mật khẩu không khớp <br>"; } if (pass1.Length < 6) { ViewBag.result += @"Mật khẩu chưa đủ mạnh"; } if (pass1.Length >= 6 && pass2.Length >= 6 && pass1 == pass2) { CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE)); string token = credential.JwToken; AccountManage profile = GetApiAccountManage.GetAccountManages(credential.JwToken).SingleOrDefault(p => p.Email == credential.Email); profile.Password = Encryptor.MD5Hash(pass1); using (HttpClient client = HelperClient.GetClient(token)) { client.BaseAddress = new Uri(Constants.BASE_URI); var putTask = client.PutAsJsonAsync <AccountManage>(Constants.ACCOUNT_MANAGE + "/" + profile.Email, profile); putTask.Wait(); } return(RedirectToAction("Index", "Home")); } return(View("ChangePassword")); }
public async Task <IActionResult> PutAccountManage(string id, AccountManage accountManage) { if (id != accountManage.Email) { return(BadRequest()); } _context.Entry(accountManage).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountManageExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Login(AccountManage account) { if (IsLogin()) { return(RedirectToAction("Index", "News")); } else { ViewBag.Message = "Thông tin tài khoản hoặc mật khẩu không chính xác, vui lòng kiểm tra lại!"; if (ExecuteNews.Account.LoginByEmail(account.UserName, account.PassWord) || ExecuteNews.Account.LoginByUserName(account.UserName, account.PassWord)) { var user = new tblUser(); user = ExecuteNews.User.GetByUserName(SessionDecentralize(), account.UserName).Data ?? ExecuteNews.User.GetByEmail(SessionDecentralize(), account.UserName).Data; Session[NewsProject.Commons.Session.UserName.ToString()] = user.Email; Session[NewsProject.Commons.Session.Email.ToString()] = user.UserName; Session[NewsProject.Commons.Session.Decentralize.ToString()] = user.Decentralize; Session[NewsProject.Commons.Session.Status.ToString()] = user.Status; Session[NewsProject.Commons.Session.Id.ToString()] = user.Id; return(RedirectToAction("Index", "News")); } return(View("Login", account)); } }
public ActionResult Register(RegisterViewModel newUser) { AccountManage manage = new AccountManage(); if (ModelState.IsValid) { if (manage.CheckUserName(newUser.UserName) && manage.CheckEmail(newUser.Email) && manage.CheckPhonenumber(newUser.Phone)) { User user = new User { Account = newUser.UserName, Email = newUser.Email, PhoneNumber = newUser.Phone, Password = manage.EncryptedPassword(newUser.Password), TypeUser = "******" }; db.Users.Add(user); db.SaveChanges(); } else { ModelState.AddModelError("Register", "Please Check Your Infomation"); return(View()); } } return(View()); }
public JObject updateBasicInfo(BasicParam basic) { AccountManage.setBasicParam(basic); AccountManage.creatAccount("test"); JObject json = new JObject( new JProperty("code", 0), new JProperty("msg", "修改成功")); return(json); }
public JArray accList() { var list = AccountManage.getAccountList(""); list = list.Where(x => x.status == 0).ToList(); JArray json = new JArray( from r in list select new JObject( new JProperty("ID", r.databaseName), new JProperty("name", r.accountName))); return(json); }
void cbi_RemoveMe(object sender, CIEventArgs e) { foreach (var obj in flowLayoutPanel1.Controls.OfType <ConnectionItem>()) { if (obj.Key == e.Key) { flowLayoutPanel1.Controls.Remove(obj); //更新配置文件 AccountManage am = new AccountManage(); am.DeleteAccount(e.Key); } } }
public IActionResult UpdateProfile(string email, AccountManage profileInput, IFormFile Avatar) { CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE)); string token = credential.JwToken; AccountManage profile = GetApiAccountManage.GetAccountManages(credential.JwToken) .Select(p => new AccountManage() { Email = p.Email, AccountRoleId = p.AccountRoleId, FullName = profileInput.FullName, IsActivated = p.IsActivated, Avatar = p.Avatar, Address = profileInput.Address, Password = p.Password }).SingleOrDefault(p => p.Email == email); string accountImg = Encryptor.RandomString(12); string extension = Avatar != null?Path.GetExtension(Avatar.FileName) : ""; if (Avatar != null) { if (SlugHelper.CheckExtension(extension)) { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "images/avatar", accountImg + extension); using (var file = new FileStream(path, FileMode.Create)) { Avatar.CopyTo(file); } profile.Avatar = accountImg + extension; } else { ModelState.AddModelError("", Constants.EXTENSION_IMG_NOT_SUPPORT); return(Content(Constants.EXTENSION_IMG_NOT_SUPPORT)); } } using (HttpClient client = HelperClient.GetClient(token)) { client.BaseAddress = new Uri(Constants.BASE_URI); var putTask = client.PutAsJsonAsync <AccountManage>(Constants.ACCOUNT_MANAGE + "/" + profile.Email, profile); putTask.Wait(); var result = putTask.Result; return(View()); } }
public JObject getBasicInfo() { BasicParam basic = AccountManage.getBasicParam(); JObject json = new JObject( new JProperty("code", 0), new JProperty("data", new JObject( new JProperty("server", basic.server), new JProperty("defaulBase", basic.defaulBase), new JProperty("Uid", basic.Uid), new JProperty("Pwd", basic.Pwd), new JProperty("AccountDir", basic.AccountDir), new JProperty("BackupDir", basic.BackupDir)))); return(json); }
public async Task <IActionResult> OnPostAsync() { if (ModelState.IsValid) { var _user = _db.Users.Where(a => a.UserType == UserType.Career && a.Email.ToLower() == EmailAddress.ToLower()).AsNoTracking().ToList().SingleOrDefault(); if (_user == null) { AuthenticationFailed = true; return(Page()); } if (Password == _user.Password) { AuthenticationFailed = false; AccountManage.IsLoggedIn = true; AccountManage.User = new UserModel { Email = _user.Email, Id = _user.Id, Name = _user.Name, UserType = UserType.Career, Password = _user.Password, UserName = _user.UserName }; AccountManage.User.ProfileImageSrc = AccountManage.ImgSrc(_user.ProfileImage); return(RedirectToPage("/CareerPages/Career_Dashboard")); } else { AuthenticationFailed = true; return(Page()); } } else { AuthenticationFailed = false; return(Page()); } }
public AccountManage ConvertToEntity() { var entity = new AccountManage(); entity.Id = Id; entity.AccountName = AccountName; entity.AccountDescription = AccountDescription; entity.AccountLogo = AccountLogoPath; entity.CorpId = CorpId; entity.QrCode = QrCodePath; entity.AccountType = AccountType; entity.CreatedDate = CreatedDate; entity.CreatedUserID = CreatedUserID; entity.UpdatedDate = UpdatedDate; entity.UpdatedUserID = UpdatedUserID; entity.IsDeleted = IsDeleted; return(entity); }
public void FlushForm() { AccountManage am = new AccountManage(); List <ConnectItem> ci = am.GetAccList(); flowLayoutPanel1.Controls.Clear(); foreach (var obj in ci) { var cbi = new ConnectionItem(); cbi.ConnectName = obj.Name; cbi.HostName = obj.Host; cbi.UserName = obj.UserName; cbi.PassWord = obj.PassWord; cbi.Port = obj.Port; cbi.Key = obj.Key; cbi.RemoveMe += cbi_RemoveMe; flowLayoutPanel1.Controls.Add(cbi); } }
public IActionResult UpdateProfile(string email) { CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE)); AccountManage profile = GetApiAccountManage.GetAccountManages(credential.JwToken) .Select(p => new AccountManage() { Email = p.Email, AccountRoleId = p.AccountRoleId, FullName = p.FullName, IsActivated = p.IsActivated, Avatar = p.Avatar, Address = p.Address }).SingleOrDefault(p => p.Email == email); ViewBag.AccountRoleName = GetApiAccountRoles.GetAccountRoles().SingleOrDefault(k => k.AccountRoleId == profile.AccountRoleId).AccountRoleName; ViewBag.Email = profile.Email; ViewBag.FullName = profile.FullName; ViewBag.DiaChi = profile.Address; return(View()); }
private void button3_Click(object sender, EventArgs e) { AccountManage AM = new AccountManage(); textBox1.Text = textBox1.Text.Replace(" ", ""); if (textBox1.Text.Length > 0) { if (!Model.SavePassWord) { Model.PassWord = ""; } AM.AddAccount(Model); frmMain main = (frmMain)this.Owner; main.FlushForm(); this.Close(); } else { MessageBox.Show("请输入连接名称"); } }
public async Task <ActionResult <AccountManage> > PostAccountManage(AccountManage accountManage) { _context.AccountManage.Add(accountManage); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (AccountManageExists(accountManage.Email)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetAccountManage", new { id = accountManage.Email }, accountManage)); }
public IActionResult ActivateAccount(string accountEmail) { CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE) != null ? HttpContext.Session.GetString(Constants.VM_MANAGE) : ""); string token = credential.JwToken; AccountManage acc = GetApiAccountManage.GetAccountManages(token).SingleOrDefault(p => p.Email == accountEmail); // update status acc.IsActivated = !acc.IsActivated; using (HttpClient client = HelperClient.GetClient(token)) { client.BaseAddress = new Uri(Constants.BASE_URI); var putTask = client.PutAsJsonAsync <AccountManage>(Constants.ACCOUNT_MANAGE + "/" + acc.Email, acc); putTask.Wait(); var result = putTask.Result; } return(RedirectToAction("Index")); }
public ActionResult Login(LoginModel login) { AccountManage manage = new AccountManage(); if (ModelState.IsValid) { if (manage.CheckUserLogin(login)) { Session["user"] = login.UserName; return(RedirectToAction("Index2", "Home")); } else { ModelState.AddModelError("Login", "Wrong password or user name"); return(View()); } } else { return(View()); } }
public JObject getList(string accName, int page, int limit) { List <Account> list = AccountManage.getAccountList(accName); var list1 = list.Skip((page - 1) * limit).Take(limit).ToList(); JObject json = new JObject( new JProperty("code", 0), new JProperty("msg", ""), new JProperty("count", list.Count), new JProperty("data", new JArray( from r in list1 select new JObject( new JProperty("accountID", r.accountID), new JProperty("accountName", r.accountName), new JProperty("creatDate", r.creatDate), new JProperty("databaseName", r.databaseName), new JProperty("databasePath", r.databasePath), new JProperty("ID", r.ID), new JProperty("remark", r.remark), new JProperty("status", r.status))))); return(json); }
public IActionResult ResetPassword(string accountEmail) { CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE) != null ? HttpContext.Session.GetString(Constants.VM_MANAGE) : ""); string token = credential.JwToken; AccountManage acc = GetApiAccountManage.GetAccountManages(token).SingleOrDefault(p => p.Email == accountEmail); string newPassword = Encryptor.RandomString(6); acc.Password = Encryptor.MD5Hash(newPassword); using (HttpClient client = HelperClient.GetClient(token)) { client.BaseAddress = new Uri(Constants.BASE_URI); var putTask = client.PutAsJsonAsync <AccountManage>(Constants.ACCOUNT_MANAGE + "/" + acc.Email, acc); putTask.Wait(); var result = putTask.Result; } //send Email SenderEmail.SendMail(accountEmail, "PETSHOP - Reset Your Password", String.Format("Your new password is here {0} please check it", newPassword)); return(NoContent()); }
public bool IsActionPermited(AccountManage fullPatch, Guid uid) { var role = Participants.FirstOrDefault(x => x.UserInformation.ID == uid); return(role?.AccessStatus == AccessStatus.Owner); }
public IActionResult Create(AccountManageDTO dto, IFormFile Avatar) { var obj = dto; if (dto.Password == null) { return(NoContent()); } AccountManage accountManage = new AccountManage() { FullName = dto.FullName, Address = dto.Address, Email = dto.Email, IsActivated = dto.IsActivated, Password = Encryptor.MD5Hash(dto.Password), AccountRoleId = GetApiAccountRoles.GetAccountRoles().SingleOrDefault(q => q.AccountRoleName == dto.AccountRoleName).AccountRoleId }; string accountImg = Encryptor.RandomString(12); string extension = Avatar != null?Path.GetExtension(Avatar.FileName) : ""; if (Avatar != null) { if (SlugHelper.CheckExtension(extension)) { var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "images/avatar", accountImg + extension); using (var file = new FileStream(path, FileMode.Create)) { Avatar.CopyTo(file); } accountManage.Avatar = accountImg + extension; } else { ModelState.AddModelError("", Constants.EXTENSION_IMG_NOT_SUPPORT); return(Content(Constants.EXTENSION_IMG_NOT_SUPPORT)); } } else { accountManage.Avatar = "denyPaw.png"; } //account avatar CredentialManage credential = JsonConvert.DeserializeObject <CredentialManage>(HttpContext.Session.GetString(Constants.VM_MANAGE) != null ? HttpContext.Session.GetString(Constants.VM_MANAGE) : ""); string token = credential.JwToken; using (HttpClient client = HelperClient.GetClient(token)) { client.BaseAddress = new Uri(Common.Constants.BASE_URI); var postTask = client.PostAsJsonAsync <AccountManage>(Constants.ACCOUNT_MANAGE, accountManage); postTask.Wait(); var result = postTask.Result; if (result.IsSuccessStatusCode) { var readTask = result.Content.ReadAsAsync <Product>(); readTask.Wait(); } return(RedirectToAction(nameof(Index))); } }