Esempio n. 1
0
        public async Task <IActionResult> Login([FromBody] Member member)
        {
            MemberBiz memberBiz = new MemberBiz();
            CommonValidationCheckBiz validationBiz = new CommonValidationCheckBiz();

            if (!validationBiz.IsEmailCheck(member.Email))
            {
                return(Json(JsonResultString.GetJsonResultStringConvert(false, "올바른 형식이 아닌 이메일입니다.")));
            }

            if (!validationBiz.IsContectEmailCheck(member.Email))
            {
                return(Json(JsonResultString.GetJsonResultStringConvert(false, _emailCheckErrorMessage)));
            }

            member.EncPassword = CommonSHA256GenerateBiz.EncryptionSHA256String(member.Password);
            List <Member> memberList = memberBiz.GetMemberInfo <Member>(member.Email, member.EncPassword);

            if (memberList.Count != 1)
            {
                return(Json(JsonResultString.GetJsonResultStringConvert(false, "아이디 또는 패스워드를 확인 해 주세요.")));
            }
            else
            {
                var claims = new Claim[]
                {
                    new Claim("Email", memberList[0].Email),
                    new Claim("Name", memberList[0].Name)
                };

                var ci = new ClaimsIdentity(claims, member.EncPassword);

                await HttpContext.Authentication.SignInAsync("LoginCookie", new ClaimsPrincipal(ci));

                return(Json(JsonResultString.GetJsonResultStringConvert(true, "로그인성공")));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> RegisterEmail([FromBody] Member member)
        {
            try
            {
                dynamic                  errorList     = null;
                MemberBiz                memberBiz     = new MemberBiz();
                CommonSendEmailBiz       sendMailBiz   = new CommonSendEmailBiz();
                CommonValidationCheckBiz validationBiz = new CommonValidationCheckBiz();

                if (!ModelState.IsValid)
                {
                    errorList = ModelState.ToDictionary(
                        kvp => kvp.Key,
                        kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray()
                        ).ToList();

                    return(Json(JsonResultString.GetJsonResultStringConvert(false, errorList)));
                }

                if (!validationBiz.IsContectEmailCheck(member.Email))
                {
                    Dictionary <string, string> errDictionary = new Dictionary <string, string>();
                    string message = CommonConfigurationBuilderBiz.Configuration.GetSection("valid:emailMessage").Value;
                    errDictionary.Add("email", message);
                    errorList = errDictionary.ToList();

                    return(Json(JsonResultString.GetJsonResultStringConvert(false, errorList)));
                }

                List <Member> memberList = memberBiz.GetMemberInfo <Member>(member.Email);
                if (memberList.Count > 0)
                {
                    throw new UserException("이미 가입한 회원입니다.");
                }

                string authCode          = CommonSHA256GenerateBiz.EncryptionSHA256String(member.Email + DateTime.Now.ToString("yyyyMMddHHmmss"));
                string querystringEncode = string.Format("Email={0}&AuthCode={1}", WebUtility.UrlEncode(member.Email), WebUtility.UrlEncode(authCode));
                HttpContext.Session.SetString("authCode", authCode);

                memberBiz.RegisterAuthMember(member.Email, authCode);

                StringBuilder mailMessage = new StringBuilder();
                mailMessage.AppendFormat("<meta http-equiv='Content-Type' content='text/html; charset = utf-8'>");
                mailMessage.AppendFormat("안녕하세요. {0}님 <br />", member.Name);
                mailMessage.AppendFormat("아래의 링크를 클릭하여 이메일을 인증 해 주세요.");
                mailMessage.AppendFormat("<div style='padding-top:20px; padding-bottom: 30px;'>");
                mailMessage.AppendFormat("<a href='http://www.partneradmin.com/Member/AuthMember?{0}' " +
                                         "style ='display:inline-block;color:#fff;background-color:#d40100;padding:14px;font-weight:bold;text-decoration:none;font-family: Arial;'>", querystringEncode);
                mailMessage.AppendFormat("PartnerAdmin 인증하기");
                mailMessage.AppendFormat("</a></div>");
                mailMessage.AppendFormat("감사합니다.");

                await sendMailBiz.SendEmailAsync(member.Email, "", "[PartnerAdmin]회원가입 승인 메일", mailMessage.ToString());


                return(Json(JsonResultString.GetJsonResultStringConvert(true, "이메일 승인 해 주세요")));
            }
            catch (UserException u_ex)
            {
                return(Json(JsonResultString.GetJsonResultStringConvert(false, u_ex.Message)));
            }
            catch (Exception ex)
            {
                return(Json(JsonResultString.GetJsonResultStringConvert(false, "회원가입실패")));
            }
        }