public IActionResult FrontCreate(Member Member, IEncryption encryption) { MemberServices services = new MemberServices(); Member.MemberPassword = encryption.EncryptionMethod(Member.MemberPassword, Member.MemberName); services.CreateMember(Member); return(Redirect("/FrontEnd/Index")); }
public ActionResult AddMember(Member member) { if (ModelState.IsValid) { memberModel.CreateMember(member); return(RedirectToAction("Index")); } return(View(member)); }
public ActionResult LineLogin() { var code = Request.QueryString ["code"]; if (string.IsNullOrEmpty(code)) { return(Content("沒有收到 Code")); } var url = HttpContext.Request.Url.Host; var token = Utility.GetTokenFromCodeLine(code, "1653659088", "27d426186987ed6e5d69cb7601129805", "https://" + url + "/FrontEnd/LineLogin"); var UserInfoResult = Utility.GetUserInfoLine(token.access_token, token.id_token); // 這邊不建議直接把 Token 當做參數傳給 CallAPI 可以避免 Token 洩漏 int i = 0; var email = UserInfoResult.email; var name = UserInfoResult.displayName; var password2 = UserInfoResult.userId; if (!item.Members.Any(x => x.MemberEmail == email)) { Member member = new Member(); MemberServices services = new MemberServices(); member.MemberPassword = Encryption.EncryptionMethod(password2, email); member.MemberName = name; member.MemberEmail = email; member.MemberGender = "Line"; member.MemberPhone = "Line"; services.CreateMember(member); } var membership = (from m in item.Members where m.MemberEmail == email select m).FirstOrDefault(); var password = Encryption.EncryptionMethod(password2, membership.MemberName); if (CheckAdmin(password2, password, "Admin")) { TempData["roles"] = "Admin"; } else { TempData["roles"] = "Client"; } LoginProcessmdfity("Client", membership.MemberName, true, membership); return(RedirectToAction("MemberPageAddresschange")); }
public ActionResult Create(Member Member) { var code = Request.QueryString["code"]; //Response.Write("<br/> code: " + code); //get token from code MemberServices services = new MemberServices(); Member.MemberPassword = Encryption.EncryptionMethod(Member.MemberPassword, Member.MemberName); services.CreateMember(Member); return(RedirectToAction("Index")); }
public ActionResult GoogleLogin() { var code = Request.QueryString ["code"]; if (string.IsNullOrEmpty(code)) { return(Content("沒有收到 Code")); } var token = Utility.GetTokenFromCode(code, "145015126077-5afcqbo9rc629k3ilceajnbfrlrdamlj.apps.googleusercontent.com", "At2kDe1L5weKB4Xf7dpf6rmx", "https://" + HttpContext.Request.Url.Host + "/FrontEnd/GoogleLogin"); var UserInfoResult = Utility.GetUserInfo(token.access_token); // 這邊不建議直接把 Token 當做參數傳給 CallAPI 可以避免 Token 洩漏 var email = UserInfoResult.email; var name = UserInfoResult.name; var password2 = UserInfoResult.id; if (!item.Members.Any(x => x.MemberEmail == email)) { Member member = new Member(); MemberServices services = new MemberServices(); member.MemberPassword = Encryption.EncryptionMethod(password2, email); member.MemberName = name; member.MemberEmail = email; member.MemberGender = "Google"; member.MemberPhone = "google"; services.CreateMember(member); } var membership = (from m in item.Members where m.MemberEmail == email select m).FirstOrDefault(); var password = Encryption.EncryptionMethod(password2, membership.MemberName); if (CheckAdmin(password2, password, "Admin")) { TempData["roles"] = "Admin"; } else { TempData["roles"] = "Client"; } LoginProcessmdfity("Client", membership.MemberName, true, membership); return(RedirectToAction("MemberPageAddresschange")); }
public IActionResult CreateMember([FromBody] RequestCreateMember _member) { AppUser user = new AppUser(); Member entity; if (ModelState.IsValid) { entity = _memberServices.CreateMember(_member); _memberServices.Commit(); return(Created($"api/member/{entity.Id}", _member)); } else { return(BadRequest()); } }