private static void EnsureDefaultAccountsHasCorrectSettings(ConnectionStringSettings connectionString, ICommandBus commandBus)
        {
            var accounts = new AccountDao(() => new BookingDbContext(connectionString.ConnectionString));
            var admin    = accounts.FindByEmail("*****@*****.**");

            if (admin != null &&
                (!admin.HasAdminAccess || !admin.IsConfirmed))
            {
                commandBus.Send(new UpdateRoleToUserAccount
                {
                    AccountId = admin.Id,
                    RoleName  = RoleName.SuperAdmin,
                });

                commandBus.Send(new ConfirmAccount
                {
                    AccountId        = admin.Id,
                    ConfimationToken = admin.ConfirmationToken
                });
            }

            var john = accounts.FindByEmail("*****@*****.**");

            if (john != null)
            {
                var updateAccountCommand = new UpdateBookingSettings
                {
                    AccountId         = john.Id,
                    Country           = new CountryISOCode("CA"),
                    Phone             = "6132875020",
                    Name              = "John Doe",
                    Email             = "*****@*****.**",
                    NumberOfTaxi      = john.Settings.NumberOfTaxi,
                    ChargeTypeId      = john.Settings.ChargeTypeId,
                    DefaultTipPercent = john.DefaultTipPercent
                };
                commandBus.Send(updateAccountCommand);
            }
        }
Exemple #2
0
        public ActionResult Update(string currentPwd, string newPassword)
        {
            AccountItem item = AccountDao.FindByEmail(accountItem.Email);

            if (item.Password != currentPwd)
            {
                return(Json(new { result = "fail", message = "현재 비밀번호가 다릅니다." }, JsonRequestBehavior.AllowGet));
            }
            item.Password = newPassword;
            try
            {
                AccountDao.Update(item);
                Session["account"] = item;
                return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { result = "fail", message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #3
0
 public ActionResult FindPassword(string email)
 {
     try
     {
         AccountItem item = AccountDao.FindByEmail(email);
         if (item == null)
         {
             return(Json(new { result = "fail", message = "존재하지 않는 이메일입니다." }, JsonRequestBehavior.AllowGet));
         }
         if (item.State == "DEL")
         {
             return(Json(new { result = "fail", message = "탈퇴한 이메일입니다." }, JsonRequestBehavior.AllowGet));
         }
         SendEmail(email, item.Password);
         return(Json(new { result = "success", message = "비밀번호를 이메일로 전송하였습니다." }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { result = "fail", message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #4
0
        public ActionResult JoinUpdate(string email, string password)
        {
            AccountItem item = AccountDao.FindByEmail(email);

            if (item != null)
            {
                return(Json(new { result = "fail", message = "동일한 이메일이 이미 존재합니다." }, JsonRequestBehavior.AllowGet));
            }
            item          = new AccountItem();
            item.Email    = email;
            item.Password = password;
            item.State    = "REG";
            try
            {
                AccountDao.Insert(item);
                return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { result = "fail", message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #5
0
        public ActionResult Login(string email, string password)
        {
            AccountItem item = AccountDao.FindByEmail(email);

            if (item == null)
            {
                return(Json(new { result = "fail", message = "존재하지 않는 이메일입니다." }, JsonRequestBehavior.AllowGet));
            }
            if (item.State == "DEL")
            {
                return(Json(new { result = "fail", message = "탈퇴한 이메일입니다." }, JsonRequestBehavior.AllowGet));
            }
            if (!item.Password.Equals(password))
            {
                return(Json(new { result = "fail", message = "존재하지 않는 비밀번호입니다." }, JsonRequestBehavior.AllowGet));
            }
            // 쿠키 할당
            FormsAuthentication.SetAuthCookie(item.Email, true);
            Session["account"] = item;
            // JsonResult 액션 결과 반환
            // dafault JsonRequestBehavior.DenyGet - HttpGet x
            return(Json(new { result = "success" }, JsonRequestBehavior.AllowGet));
        }