public ActionResult ChangeProfileInfo(ChangeUserProfileModel profile) { if (ModelState.IsValid) { var u = GetCurrentUser(); u = profile.ToModel(u); //SỬAAAAAAAAAAAAAAAAAA var managementItem = new AccountManagementItem <User_Profile, IUserProfileService>(); //var type = RoleTypeEnum.User; //không sửaaaaaaaaaaa managementItem.ModelState = ModelState; //managementItem.profile = profile; var acc = managementItem.ChangeProfile(this.ControllerContext, u); if (acc != null)//~ account != null && account.IsValid() trong ChangeProfile { SetLoginAuthentication(acc); SetSuccess("Cập nhật thành công"); } else { SetCustomError("Có lỗi xảy ra. Vui lòng kiểm tra lại"); } } return(View(profile)); }
/// <summary> /// Active user sau khi đăng ký thông qua key được gửi về email của user /// </summary> /// <param name="key"></param> /// <returns></returns> public ActionResult Active(string key) { //if (string.IsNullOrEmpty(key)) //{ // return RedirectToError(); //} var managementItem = new AccountManagementItem <User_Profile, IUserProfileService>(); if (!managementItem.Active(this.ControllerContext, key)) { return(RedirectToError(ACCOUNT_MSG_INVALIDACCOUNT)); } var AccountService = IoCConfig.Service <AccountService>(); Account activeAcc = AccountService.FindAll().Where(f => f.Account_ActiveKey == key).First(); if (!CheckLoginAndAuthentication(activeAcc)) { return(RedirectToLogin()); } //var accountService = IoCConfig.Service<IAccountService>(); //var account = accountService.GetAccountByActiveKey(key); //if (account == null) //{ // return RedirectToError(ACCOUNT_MSG_INVALIDACCOUNT); //} //accountService.Active(account); ////send email active thành công //EmailHelper.SendMail_RegisterActiveSuccess(this.ControllerContext, account); return(View()); }
public ActionResult LoginFacebook(string accessToken, string return_url) { var res = CheckLoginFacebook(accessToken); if (res.success == true)//thành công { var user = res.user as User_Profile; Account acc = null; //save session if (res.isNew == true)//nếu user mới { user.SetRole(RoleTypeEnum.User); //adding var managementItem = new AccountManagementItem <User_Profile, IUserProfileService>(); managementItem.ModelState = ModelState; acc = managementItem.AddingNonRegister(this.ControllerContext, user, true); } else//nếu user cũ { acc = IoCConfig.Service <IAccountService>().GetAccountByProfileId(user.Id); } if (CheckLoginAndAuthentication(acc)) { return(Success()); } } return(RedirectToLoginError(res.message)); }
public ActionResult RegisterUser(RegisterUserModel register) { if (ModelState.IsValid) { var response = this.VerifyRecaptcha(true); if (!response) { return(View(register)); } //SỬAAAAAAAAAAAAAAAAAA var managementItem = new AccountManagementItem <User_Profile, IUserProfileService>(); var type = RoleTypeEnum.User; //không sửaaaaaaaaaaa managementItem.ModelState = ModelState; managementItem.register = register; if (managementItem.Validating()) { //not yet active, not yet verified //has set password if (managementItem.Adding(this.ControllerContext) != null) { return(RedirectToRegisterSuccess()); } ViewBag.CustomError = true; } } return(View(register)); }