public CustomPrincipal(CustomAccount uact) { this.useracct = uact; this.Identity = new GenericIdentity(uact.Username); }
static void Main(string[] args) { var exampleToRun = ExamplesEnumeration.InterfaceConstraint; switch (exampleToRun) { case ExamplesEnumeration.StandartConstaint: Account <int> account = new Account <int>(5); account.ShowSum(); break; case ExamplesEnumeration.CustomConstraint: //AdvancedSum sum = new AdvancedSum() { Quantity = 5, Currency = "eur" }; CustomSum sum = new CustomSum() { Quantity = 5 }; CustomAccount <CustomSum> customAccount = new CustomAccount <CustomSum>(sum); customAccount.ShowSum(); break; case ExamplesEnumeration.InterfaceConstraint: //SpecialSum specialSum = new SpecialSum() { Quantity = 5.2 }; CustomSum specialSum = new CustomSum() { Quantity = 5 }; InterfaceAccount <CustomSum, int> interfaceAccount = new InterfaceAccount <CustomSum, int>(specialSum); interfaceAccount.ShowData(); break; } Console.Read(); }
/// <summary> /// 删除客服账号 /// </summary> /// <param name="accessToken"></param> /// <param name="model"></param> /// <returns></returns> public static WxJsonResult DeleteCustom(string accessToken, CustomAccount model) { string param = string.Format("&kf_account={0}&nickname={1}&password={2}", model.kf_account, model.nickname, model.password); //string result = RequestUtility.HttpGet(StaticUrl.URL_DeleteCustom + param, null); //return ApiHelper.GetResult<WxJsonResult>(result); return(ApiHelper.Get(accessToken, StaticUrl.URL_DeleteCustom + param, new string[0])); }
public ActionResult Index() { if (Session[Common.Const.Session_Account] == null) { HttpCookie use_cookie = Request.Cookies[Common.Const.Cookie_User]; if (use_cookie != null) { FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(use_cookie.Value); Session[Common.Const.Session_Account] = JsonConvert.DeserializeObject <CustomAccount>(ticket.UserData); } } CustomAccount acc = (CustomAccount)Session[Common.Const.Session_Account]; Account account = account_Model.GetAccountByID(acc.AccountID); return(View(account)); }
public async Task <ActionResult> LockAccount(string email = null) { CustomAccount acc = new CustomAccount(); if (Session[Common.Const.Session_Account] != null) { acc = (CustomAccount)Session[Common.Const.Session_Account]; } if (await account_Model.LockAccount(String.IsNullOrEmpty(acc.Account_Email) ? email : acc.Account_Email)) { LogOut(); TempData["Message"] = "Your account has been locked."; return(RedirectToAction("Index", "Home")); } else { ViewBag.Error = "System error."; } return(View()); }
public async Task <ActionResult> ForgotPass(string newpass, string remember, string oldpass = null, string email = null) { CustomAccount acc = new CustomAccount(); if (Session[Common.Const.Session_Account] != null) { acc = (CustomAccount)Session[Common.Const.Session_Account]; } //Nếu quên mật khẩu cũ thì đổi mật khẩu xong gửi mail xác nhận về cho email đó if (remember == "on") { var code = Guid.NewGuid().ToString(); if (await account_Model.changeAccountCode(code, acc.AccountID, email) && await account_Model.ChangePassNoOldPass(acc.AccountID, email, newpass)) { if (await ConfirmEmail(String.IsNullOrEmpty(email) ? acc.Account_Email : email, code)) { if (await account_Model.UnConfirmAccountByEmailOrID(acc.AccountID, email)) { TempData["Success"] = "We sent you a confirmation email with a link to activate your subscription. Please check your email and click the link!"; return(RedirectToAction("LogIn", "Account")); } } } } else { var result = await account_Model.ChangePass(acc.AccountID, email, oldpass, newpass); if (result) { TempData["Success"] = "You have successfully changed your account password !"; return(RedirectToAction("LogIn", "Account")); } } ViewBag.Error = "password change failed."; return(View()); }
public ActionResult LogIn(string email, string pass, string remember, string ReturnUrl) { var Validate = account_Model.ValidateUser(email, pass); switch (Validate) { case "-4": ViewBag.Error = "System error !"; break; case "-3": ViewBag.Error = "This account is locked !"; break; case "-2": { ViewBag.status = true; ViewBag.link = String.Format("ResendActivationEmail?email={0}", email); ViewBag.Error = String.Format("You have not confirmed Email {0}!", email); break; } case "-1": ViewBag.Error = "wrong password !"; break; case "0": ViewBag.Error = "This email does not exist !"; break; default: { Account Acc = (account_Model.GetAccountByID(Validate)); Acc.Account_Pass = String.Empty; CustomAccount account = new CustomAccount { AccountID = Acc.AccountID, Account_Name = Acc.Account_Name, Account_Email = Acc.Account_Email, Account_RoleID = Acc.Account_RoleID, Account_Avarta = Acc.Account_Avarta }; Session[Common.Const.Session_Account] = account; if (remember == "on") { ////Tao cookie su dung System.Web.Security string userData = JsonConvert.SerializeObject(account); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket ( 1, Acc.Account_Name, DateTime.Now, DateTime.Now.AddMinutes(15), false, userData ); string enTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie user_cookie = new HttpCookie(Common.Const.Cookie_User, enTicket); user_cookie.Expires.AddYears(1); user_cookie.HttpOnly = true; HttpContext.Response.SetCookie(user_cookie); } if (String.IsNullOrEmpty(ReturnUrl)) { return(RedirectToAction("Index", "Home")); } else { return(RedirectToLocal(ReturnUrl)); } } } ViewBag.ReturnUrl = ReturnUrl; return(View()); }
/// <summary> /// 修改客服账号 /// </summary> /// <param name="accessToken"></param> /// <param name="model"></param> /// <returns></returns> public static WxJsonResult UpdateCustom(string accessToken, CustomAccount model) { return(ApiHelper.Post(accessToken, StaticUrl.URL_UpdateCustom, model)); }
public ActionResult Index(string id) { CustomAccount Guide = guide_Model.GetGuideByID(id); return(View(Guide)); }