public ActionResult FrontCreate(Member Member) { MemberServices services = new MemberServices(); Member.MemberPassword = Encryption.EncryptionMethod(Member.MemberPassword, Member.MemberName); services.CreateMember(Member); return(Redirect("/FrontEnd/Index")); }
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 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 ActionResult MemberPageSetting(Member Member) { MemberServices services = new MemberServices(); HttpCookie rqstCookie = HttpContext.Request.Cookies.Get("myaccount"); var memberDataObj = FormsAuthentication.Decrypt(rqstCookie.Value); var memberData = JsonConvert.DeserializeObject <Member>(memberDataObj.UserData); Member.MemberPassword = Encryption.EncryptionMethod(Member.MemberPassword, Member.MemberName); Member.MemberID = memberData.MemberID; Member.MemberGender = memberData.MemberGender; services.EditMember(Member); return(RedirectToAction("MemberPageOrder")); }