public REply Login([FromBody] AccessModel model) { REply or = new REply(); or.result = 0; try { using (DB_ViviLovelyNailsEntities db = new DB_ViviLovelyNailsEntities()) { var list = db.User.Where(d => d.email == model.email && d.password == model.pass && d.idEstatus == 1); if (list.Count() > 0) { or.result = 1; or.data = Guid.NewGuid().ToString(); User oUser = list.First(); oUser.token = (string)or.data; db.Entry(oUser).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } else { or.message = "Usuarios Incorrectos"; } } } catch (Exception ex) { or.message = "Ocurrio un error, lo estamos corrigiendo"; } return(or); }
public ActionResult AEdit(int id) { AccessService objService = new AccessService(); AccessModel objModel = new AccessModel(); objModel = objService.getByID(id); QuotationService objService1 = new QuotationService(); List <DataCenterModel> ListDC = new List <DataCenterModel>(); ListDC = objService1.getDataCenter(); objModel.ListDC = new List <DataCenterModel>(); objModel.ListDC.AddRange(ListDC); QuotationService objCompUSerService = new QuotationService(); List <CompanyModel> objCompList = new List <CompanyModel>(); objCompList = objCompUSerService.getActiveComp(); objModel.ListComp = new List <CompanyModel>(); objModel.ListComp.AddRange(objCompList); List <UserModel> objUserList = new List <UserModel>(); objUserList = objCompUSerService.getActiveUser(); objModel.UserList = new List <UserModel>(); objModel.UserList.AddRange(objUserList); var comp = Dbcontext.UserMasters.Where(m => m.UID == objModel.CreatedBy).SingleOrDefault(); int?cid = comp.CompID; objModel.comp = cid; return(View(objModel)); }
public ActionResult Login(AccessModel model) { if (!ModelState.IsValid) { string sError = ""; foreach (var item in ModelState) { if (sError.Length > 0) { sError += ", "; } if (item.Value.Errors.Count > 0 && !item.Value.Errors[0].ErrorMessage.Contains("mail")) { sError += item.Value; } } if (sError.Length > 0) { model.ErrorMessage = sError; return(View(model)); } } bool bRet = model.LogIn(); if (bRet) { UserCache.RemoveFromCache(0, model.User.IPAddress); UserCache.AddToCache(model.User); model.GoHome = true; } //if you made it this far, the login didn't work return(View(model)); }
public ActionResult Access(AccessModel model) { if (ModelState.IsValid) { ShopConfigInfo shopConfigInfo = BSPConfig.ShopConfig; shopConfigInfo.IsClosed = model.IsClosed; shopConfigInfo.CloseReason = model.CloseReason == null ? "" : model.CloseReason; shopConfigInfo.BanAccessTime = model.BanAccessTime == null ? "" : model.BanAccessTime; shopConfigInfo.BanAccessIP = model.BanAccessIP == null ? "" : model.BanAccessIP; shopConfigInfo.AllowAccessIP = model.AllowAccessIP == null ? "" : model.AllowAccessIP; shopConfigInfo.AdminAllowAccessIP = model.AdminAllowAccessIP == null ? "" : model.AdminAllowAccessIP; shopConfigInfo.SecretKey = model.SecretKey; shopConfigInfo.CookieDomain = model.CookieDomain == null ? "" : model.CookieDomain.Trim('.'); shopConfigInfo.RandomLibrary = model.RandomLibrary == null ? "" : model.RandomLibrary; shopConfigInfo.VerifyPages = CommonHelper.StringArrayToString(model.VerifyPages); shopConfigInfo.IgnoreWords = model.IgnoreWords == null ? "" : model.IgnoreWords; shopConfigInfo.AllowEmailProvider = model.AllowEmailProvider == null ? "" : model.AllowEmailProvider; shopConfigInfo.BanEmailProvider = model.BanEmailProvider == null ? "" : model.BanEmailProvider; BSPConfig.SaveShopConfig(shopConfigInfo); Emails.ResetShop(); SMSes.ResetShop(); Randoms.ResetRandomLibrary(); FilterWords.ResetIgnoreWordsRegex(); AddAdminOperateLog("修改访问控制"); return(PromptView(Url.Action("access"), "修改访问控制成功")); } ViewData["verifyPages"] = CommonHelper.StringArrayToString(model.VerifyPages); return(View(model)); }
public void RefreshFromSettings(Options settings) { DataVersion = settings.DataVersion; Enabled = settings.Enabled; ProhibitUnfilterableFeeds = settings.ProhibitUnfilterableFeeds; Access = new AccessModel(settings.Access); }
public ActionResult Access(AccessModel access, string Action) { AccessModel dbAccess = reposetory.GetAccess(access.AssociationID); access.SelectPersons = dbAccess.SelectPersons; if (Action == "add") { if (access.Form == null) { access.Form = new List <PersonAccess>(); } if (!access.Form.Where(f => f.FunctionID == access.AddPerson).Any()) { access.Form.Add(new PersonAccess { FunctionID = access.AddPerson, }); } } foreach (PersonAccess p in access.Form) { p.FullName = access.SelectPersons.Find(ps => ps.FunctionID == p.FunctionID) == null ? "????" : access.SelectPersons.Find(ps => ps.FunctionID == p.FunctionID).FullName; } access.SelectPersons.RemoveAll(item => access.Form.Exists(p => p.FunctionID == item.FunctionID)); if (Action == "Access" & ModelState.IsValid) { reposetory.SaveAccess(access.Form); ViewBag.FormSucces = true; } return(View(access)); }
public async Task RunCheckAccess(string userName) { Console.WriteLine(userName); AccessModel accessModel = fromSql.GetAdmins(userName); if (accessModel != null) { #region _ //if (checkClass.CheckAccess(accessModel) == 0) //{ // await RunGetOneUser(accessModel); //} //else //{ // await RunGetAll(accessModel); //} #endregion accessModel.ChangeVisibility(); await RunGetAll(accessModel); } else { await Clients.Caller.SendAsync("AccessDenide", false); } }
public ActionResult Access(AccessModel model) { if (ModelState.IsValid) { ShopConfigInfo shopConfigInfo = BSPConfig.ShopConfig; shopConfigInfo.IsClosed = model.IsClosed; shopConfigInfo.CloseReason = model.CloseReason == null ? "" : model.CloseReason; shopConfigInfo.BanAccessTime = model.BanAccessTime == null ? "" : model.BanAccessTime; shopConfigInfo.BanAccessIP = model.BanAccessIP == null ? "" : model.BanAccessIP; shopConfigInfo.AllowAccessIP = model.AllowAccessIP == null ? "" : model.AllowAccessIP; shopConfigInfo.AdminAllowAccessIP = model.AdminAllowAccessIP == null ? "" : model.AdminAllowAccessIP; shopConfigInfo.SecretKey = model.SecretKey; shopConfigInfo.CookieDomain = model.CookieDomain == null ? "" : model.CookieDomain.Trim('.'); shopConfigInfo.RandomLibrary = model.RandomLibrary == null ? "" : model.RandomLibrary; shopConfigInfo.VerifyPages = CommonHelper.StringArrayToString(model.VerifyPages); shopConfigInfo.IgnoreWords = model.IgnoreWords == null ? "" : model.IgnoreWords; shopConfigInfo.AllowEmailProvider = model.AllowEmailProvider == null ? "" : model.AllowEmailProvider; shopConfigInfo.BanEmailProvider = model.BanEmailProvider == null ? "" : model.BanEmailProvider; BSPConfig.SaveShopConfig(shopConfigInfo); Emails.ResetShop(); SMSes.ResetShop(); Randoms.ResetRandomLibrary(); FilterWords.ResetIgnoreWordsRegex(); AddAdminOperateLog("修改访问控制"); return PromptView(Url.Action("access"), "修改访问控制成功"); } ViewData["verifyPages"] = CommonHelper.StringArrayToString(model.VerifyPages); return View(model); }
public string Add() { if (string.IsNullOrWhiteSpace(Request["roleId"])) { return "0"; } string[] funcIds = Request["funcIds"] == null ? null : Request["funcIds"].Split(','); AccessModel.Delete(" where RoleID = @0", Request["roleId"]); foreach (string item in funcIds) { AccessModel access = new AccessModel(); access.Roleid = Request["roleId"].ToInt(); access.Funcid = item.ToInt(); access.CreateMan = SysConfig.CurrentUser.Id; access.CreateTime = DateTime.Now; int result = access.Insert().ToInt(); if (result <= 0) { return "0"; } } //记录操作日志 CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Access"); return "1"; }
public ActionResult Register(AccessModel model) { if (!ModelState.IsValid) { return(View(model)); } else { int iRet = model.Register(); if (iRet > 0) { return(RedirectToAction("index", "home")); } else if (iRet == -5) { model.ErrorMessage = "This user name or email is taken"; } else { model.ErrorMessage = "You failed to log in"; } } return(View(model)); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { Database.AccessQueries AccessQuery = new Database.AccessQueries(); AccessModel Access = new AccessModel(); Access.LoginToken = HttpContext.Session.GetString("AccessToken"); Access.Username = HttpContext.Session.GetString("Username"); accessToken = Access.LoginToken; Access = AccessQuery.VerifyTokenData(Access, Access.Username, Access.LoginToken); if (Access.LoggedIn == false) { if (!filterContext.Controller.ToString().Contains("AccessController")) { Response.Redirect("Access/"); } } else { EmployeeIsAdmin = Access.IsAdmin; loggedinEmployee = Access.EmployeeId; // Response.Redirect("Home/"); } }
public void AddAccess(AccessModel access) { access.IsNewEntry = true; var accesses = GetAccesses(access.ShortLinkGUID); accesses.Add(access); }
public ActionResult LogOff(int userID) { string ip = ""; if (ViewBag.IPAddress != null) { ip = ViewBag.IPAddress.StringSafe(); } UserType user = UserCache.GetFromCache(userID, ip); AccessModel model = new AccessModel(); UserType _user = new UserType(); if (user != null) { _user = new UserType { UserName = "******", UserID = -1, SessionStart = DateTime.Now }; } bool bRet = model.LogOff(user); if (bRet) { UserCache.RemoveFromCache(user.UserID, ""); UserCache.AddToCache(_user); } return(RedirectToAction("index", "home")); }
public JsonResult RefreshAccessToken(string refreshToken, string clientId, string clientSecret, string serverUrl) { string json = string.Empty; if (ModelState.IsValid && !string.IsNullOrEmpty(refreshToken) && !string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(clientSecret) && !string.IsNullOrEmpty(serverUrl)) { var model = new AccessModel(); try { var authParameters = new AuthParameters() { ClientId = clientId, ClientSecret = clientSecret, ServerUrl = serverUrl, RefreshToken = refreshToken, GrantType = "refresh_token" }; var nopAuthorizationManager = new AuthorizationManager(authParameters.ClientId, authParameters.ClientSecret, authParameters.ServerUrl); string responseJson = nopAuthorizationManager.RefreshAuthorizationData(authParameters); AuthorizationModel authorizationModel = JsonConvert.DeserializeObject <AuthorizationModel>(responseJson); model.AuthorizationModel = authorizationModel; model.UserAccessModel = new UserAccessModel() { ClientId = clientId, ServerUrl = serverUrl }; // Here we use the temp data because this method is called via ajax and here we can't hold a session. // This is needed for the GetCustomers method in the CustomersController. TempData["accessToken"] = authorizationModel.AccessToken; TempData["serverUrl"] = serverUrl; } catch (Exception ex) { json = string.Format("error: '{0}'", ex.Message); return(Json(json, JsonRequestBehavior.AllowGet)); } json = JsonConvert.SerializeObject(model.AuthorizationModel); } else { json = "error: 'something went wrong'"; } return(Json(json, JsonRequestBehavior.AllowGet)); }
public int Update(AccessModel model) { Mapper.CreateMap <AccessModel, AccessMaster>(); AccessMaster objUser = Dbcontext.AccessMasters.SingleOrDefault(m => m.BAID == model.BAID); objUser = Mapper.Map(model, objUser); return(Dbcontext.SaveChanges()); }
public ActionResult Access(Guid id) { AccessModel access = reposetory.GetAccess((Guid)id); access.SelectPersons.RemoveAll(item => access.Form.Exists(p => p.FunctionID == item.FunctionID)); return(View(access)); }
public ActionResult GetAccessToken(string code, string state) { if (ModelState.IsValid && !string.IsNullOrEmpty(code) && !string.IsNullOrEmpty(state)) { if (state != Session["state"].ToString()) { return(BadRequest()); } var model = new AccessModel(); try { // TODO: Here you should get the authorization user data from the database instead from the current Session. string clientId = Session["clientId"].ToString(); string clientSecret = Session["clientSecret"].ToString(); string serverUrl = Session["serverUrl"].ToString(); string redirectUrl = Session["redirectUrl"].ToString(); var authParameters = new AuthParameters() { ClientId = clientId, ClientSecret = clientSecret, ServerUrl = serverUrl, RedirectUrl = redirectUrl, GrantType = "authorization_code", Code = code }; var nopAuthorizationManager = new AuthorizationManager(authParameters.ClientId, authParameters.ClientSecret, authParameters.ServerUrl); string responseJson = nopAuthorizationManager.GetAuthorizationData(authParameters); AuthorizationModel authorizationModel = JsonConvert.DeserializeObject <AuthorizationModel>(responseJson); model.AuthorizationModel = authorizationModel; model.UserAccessModel = new UserAccessModel() { ClientId = clientId, ClientSecret = clientSecret, ServerUrl = serverUrl, RedirectUrl = redirectUrl }; // TODO: Here you can save your access and refresh tokens in the database. For illustration purposes we will save them in the Session and show them in the view. Session["accessToken"] = authorizationModel.AccessToken; } catch (Exception ex) { return(BadRequest(ex.Message)); } return(View("~/Views/AccessToken.cshtml", model)); } return(BadRequest()); }
public ActionResult GetAccessToken(string code, string state, string error, string errorDescription) { if (ModelState.IsValid && !string.IsNullOrEmpty(code) && !string.IsNullOrEmpty(state)) { if (state != Session["state"].ToString()) { return(BadRequest()); } var model = new AccessModel(); try { string clientId = Session["clientId"].ToString(); string clientSecret = Session["clientSecret"].ToString(); string serverUrl = Session["serverUrl"].ToString(); string redirectUrl = Session["redirectUrl"].ToString(); var authParameters = new AuthParameters() { ClientId = clientId, ClientSecret = clientSecret, ServerUrl = serverUrl, RedirectUrl = redirectUrl, GrantType = "authorization_code", Code = code }; var authorizationManager = new AuthorizationManager(authParameters.ClientId, authParameters.ClientSecret, authParameters.ServerUrl); string responseJson = authorizationManager.GetAuthorizationData(authParameters); AuthorizationModel authorizationModel = JsonConvert.DeserializeObject <AuthorizationModel>(responseJson); model.AuthorizationModel = authorizationModel; model.UserAccessModel = new UserAccessModel() { ClientId = clientId, ClientSecret = clientSecret, ServerUrl = serverUrl, RedirectUrl = redirectUrl }; Session["accessToken"] = authorizationModel.AccessToken; } catch (Exception ex) { return(BadRequest(ex.Message)); } return(View("~/Views/AccessToken.cshtml", model)); } return(BadRequest()); }
public JsonResult RefreshAccessToken(string refreshToken, string clientId, string clientSecret, string serverUrl) { string json = string.Empty; if (ModelState.IsValid && !string.IsNullOrEmpty(refreshToken) && !string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(serverUrl) && !string.IsNullOrEmpty(clientSecret)) { var model = new AccessModel(); try { var authParameters = new AuthParameters() { ClientId = clientId, ServerUrl = serverUrl, RefreshToken = refreshToken, GrantType = "refresh_token", ClientSecret = clientSecret }; var authorizationManager = new AuthorizationManager(authParameters.ClientId, authParameters.ClientSecret, authParameters.ServerUrl); string responseJson = authorizationManager.RefreshAuthorizationData(authParameters); AuthorizationModel authorizationModel = JsonConvert.DeserializeObject <AuthorizationModel>(responseJson); model.AuthorizationModel = authorizationModel; model.UserAccessModel = new UserAccessModel() { ClientId = clientId, ServerUrl = serverUrl }; TempData["accessToken"] = authorizationModel.AccessToken; TempData["serverUrl"] = serverUrl; } catch (Exception ex) { json = string.Format("error: '{0}'", ex.Message); return(Json(json, JsonRequestBehavior.AllowGet)); } json = JsonConvert.SerializeObject(model.AuthorizationModel); } else { json = "error: 'something went wrong'"; } return(Json(json, JsonRequestBehavior.AllowGet)); }
public async Task RunGetAll(AccessModel accessModel) { if (accessModel.Access == 0) { await Clients.Caller.SendAsync("GiveAll", new MainObject(accessModel, fromSql.GetWorks(accessModel.Name), fromSql.GetDevices(), fromSql.GetRepairs(), fromSql.GetComboboxes())); } else { await Clients.Caller.SendAsync("GiveAll", new MainObject(accessModel, fromSql.GetWorks(), fromSql.GetDevices(), fromSql.GetRepairs(), fromSql.GetComboboxes())); } }
public async Task StartChangeUser(Admins mutableUser) { var result = toSql.ChangeUser(mutableUser); result.Wait(); await UpdateItems(result.Result); AccessModel accessModel = fromSql.GetAdmins(mutableUser.Name).ChangeVisibility(); await Clients.All.SendAsync("ChangeAccess", accessModel); }
public ActionResult Access() { AccessModel access = reposetory.GetAccess(CurrentProfile.AssociationID); if (access == null) { return(HttpNotFound()); } access.SelectPersons.RemoveAll(item => access.Form.Exists(p => p.FunctionID == item.FunctionID)); return(View(access)); }
public ActionResult Edit(AccessModel model) { if (ModelState.IsValid) { if (model.Update() > 0) { return(Success()); } } TempData[Info] = SaveError; return(Error()); }
public ActionResult Manage(int UserID) { AccessModel model = new AccessModel(); UserType user = UserCache.GetFromCache(UserID, ""); model.User = user; model.UserID = user.UserID; model.UserName = user.UserName; model.FirstName = user.FirstName; model.LastName = user.LastName; model.EMail = user.Email; return(View(model)); }
public ActionResult NewPassword(AccessModel model) { if (model.UserPassword == model.UserPassword2) { model.UpdatePassword(); return(RedirectToAction("index", "home")); } else { model.ErrorMessage = "The passwords don't match!"; return(View(model)); } }
public AccessModel getByID(int id) { try { Mapper.CreateMap <AccessMaster, AccessModel>(); AccessMaster objCityMaster = Dbcontext.AccessMasters.Where(m => m.BAID == id).SingleOrDefault(); AccessModel objCityItem = Mapper.Map <AccessModel>(objCityMaster); return(objCityItem); } catch (Exception ex) { throw ex; } }
public async Task <bool> Access(AccessModel newAccess) { newAccess.GrantedAccess = false; if (newAccess.personEntered.Equals(Guid.Empty) || !string.IsNullOrEmpty(newAccess.Plate) || !string.IsNullOrEmpty(newAccess.CardNumber)) { try { PersonModel owner = new PersonModel(); WellknownAuthorizationLevel accessLevelNeed = WellknownAuthorizationLevel.Root; if (newAccess.personEntered.Equals(Guid.Empty) && !string.IsNullOrEmpty(newAccess.Plate)) { if (await _context.Cars.AnyAsync(c => c.LicencePlate == newAccess.Plate)) { var entered = await _context.Cars.FirstAsync(c => c.LicencePlate == newAccess.Plate).ConfigureAwait(false); owner = entered.Owner; } } else if (await _context.Persons.AnyAsync(c => c.CardNumber.CardNumber == newAccess.CardNumber).ConfigureAwait(false)) { owner = await _context.Persons.FirstAsync(a => a.CardNumber.CardNumber == newAccess.CardNumber).ConfigureAwait(false); if (!await _context.Nodes.AnyAsync(n => n.Name == newAccess.NodeName && n.MacAddress == newAccess.MacAddress)) { return(false); } var node = await _context.Nodes.FirstAsync(n => n.Name == newAccess.NodeName && n.MacAddress == newAccess.MacAddress); accessLevelNeed = node.AuthValue; } if (await _autorizationManagerService.IsAutorized(owner.Id, accessLevelNeed).ConfigureAwait(false)) { newAccess.personEntered = owner.Id; newAccess.GrantedAccess = true; } await _context.Access.AddAsync(newAccess).ConfigureAwait(false); await _context.SaveChangesAsync().ConfigureAwait(false); //StaticEventHandler.SendMail(new MailEventArgs(ResourceString.AccessCarMailSubject, ResourceString.AccessCarMailBody, DateTime.UtcNow)); } catch (Exception ex) { StaticEventHandler.Log(System.Diagnostics.TraceLevel.Error, "error during Card verification", MethodBase.GetCurrentMethod(), ex); return(false); } } return(newAccess.GrantedAccess); }
public AccessModel selecttiao(string name) { MyDbContext db = CreateContext(); var li = db.Access.Select(e => e).Where(e => e.text == name).ToList(); AccessModel uu = new AccessModel(); foreach (var item in li) { uu = new AccessModel() { id = item.id }; } return(uu); }
public ActionResult Resend() { AccessModel model = new AccessModel(); UserType user = UserCache.GetFromCache(0, ViewBag.IPAddress.StringSafe()); int UserID = user.UserID; string sToken = model.GetToken(UserID); model.EMail = user.Email; model.UserName = user.UserName; model.SendConfirmationEmail(sToken, UserID); return(RedirectToAction("index", "home")); }
private void InitialAccessMode(AccessModel accessModel, int capacity, Func <T> func) { switch (accessModel) { case AccessModel.FIFO: _accessMode = new FIFOAccessMode <T>(capacity, func); break; case AccessModel.LIFO: _accessMode = new LIFOAccessMode <T>(capacity, func); break; default: throw new NotImplementedException(); } }
private AccessModel VerifyAccess(AccessModel AccessToken) { AccessToken = AccessQuery.getLoginData(AccessToken); if (AccessToken.LoggedIn) { AccessToken.LoggedInTimestamp = DateTime.Now; AccessToken.LoginToken = GenerateToken(); } else { AccessToken.LoggedInTimestamp = DateTime.MinValue; AccessToken.LoginToken = ""; } return(AccessToken); }
public ActionResult Index(int?roleId) { string url = Request.Url.AbsoluteUri; List <RoleModel> roleList = RoleModel.Fetch("select Id , Name from Role where DelFlag = 0 order by SortNo asc"); roleList.Insert(0, new RoleModel() { ID = "", Name = "请选择" }); ViewBag.roleList = roleList; AccessModel model = new AccessModel(); model.ID = roleId.ToString() ?? ""; ViewData[EditFlag] = true; return(View(model)); }
public ActionResult Access() { ShopConfigInfo shopConfigInfo = BSPConfig.ShopConfig; AccessModel model = new AccessModel(); model.IsClosed = shopConfigInfo.IsClosed; model.CloseReason = shopConfigInfo.CloseReason; model.BanAccessTime = shopConfigInfo.BanAccessTime; model.BanAccessIP = shopConfigInfo.BanAccessIP; model.AllowAccessIP = shopConfigInfo.AllowAccessIP; model.AdminAllowAccessIP = shopConfigInfo.AdminAllowAccessIP; model.SecretKey = shopConfigInfo.SecretKey; model.CookieDomain = shopConfigInfo.CookieDomain; model.RandomLibrary = shopConfigInfo.RandomLibrary; model.VerifyPages = StringHelper.SplitString(shopConfigInfo.VerifyPages); model.IgnoreWords = shopConfigInfo.IgnoreWords; model.AllowEmailProvider = shopConfigInfo.AllowEmailProvider; model.BanEmailProvider = shopConfigInfo.BanEmailProvider; ViewData["verifyPages"] = shopConfigInfo.VerifyPages; return View(model); }