public MigoErrorException(AccountUser user, string message, int statusCode, string webHostHtmlMessage) : base(message, user) { this.message = message; this.statusCode = statusCode; this.webHostHtmlMessage = webHostHtmlMessage; }
/** * Validate if the instance variables are valid * * bool - true if instance variables are valid, else false */ public bool validate() { if (AccountId < 0) { return(false); } if (AccountUser.validate() == false) { return(false); } if (CreditCard.validate() == false) { return(false); } return(true); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl ??= Url.Content("~/"); if (ModelState.IsValid) { var user = new AccountUser { UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = user.Id, code = code, returnUrl = returnUrl }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); if (_userManager.Options.SignIn.RequireConfirmedAccount) { return(RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl })); } else { await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
public ActionResult Index(AccountUser user) { if (ModelState.IsValid) { dataEntities2 entities2 = new dataEntities2(); if (entities2.AccountUser.Any(x => x.Username == user.Username)) { ViewBag.message = "username is already exists."; return(View("Index")); } entities2.AccountUser.Add(user); entities2.SaveChanges(); return(RedirectToAction("Message")); } return(View()); }
public IHttpActionResult RemoveUser(AccountUser acctUser) { if (!ModelState.IsValid) { return(BadRequest()); } if (u != null && u.Id != acctUser.Uid) { if (db.AccountUsers.Any(o => o.AcctId == acctUser.AcctId && o.Uid == u.Id && o.IsOwner)) { db.Entry(acctUser).State = EntityState.Modified; db.AccountUsers.Remove(acctUser); db.SaveChanges(); } } return(Ok()); }
/// <summary> /// NEW ALBUM view /// </summary> /// <returns>view</returns> public async Task <IActionResult> NewAlbum() { if (TempData["Error"] != null) { ViewBag.Error = TempData["Error"].ToString(); } NewAlbumViewModel model = new NewAlbumViewModel(); AccountUser user = await GetLoggedInUser(); model.AlbumList = albumRepository.GetUserAlbums(user.Id); model.AlbumList.Select(p => { p.ProtectorId = Protector.Protect(p.Id.ToString()); return(p); }).ToList(); model.Album = new Album(); return(View(model)); }
public async Task <TwoFaResult> ConfirmOtp(AccountUser user, int otpId, string otp) { var otpCode = await _db.OtpCodes.FindAsync(otpId); if (otpCode != null && otpCode.UserId == user.Id) { if (otpCode.Code == otp) { if (DateTime.Now.Subtract(otpCode.Expires).Ticks >= 0) { await _db.SaveChangesAsync(); return(new TwoFaResult { Succeeded = false, Error = "Otp code is expired" }); } _db.Remove(otpCode); await _db.SaveChangesAsync(); return(new TwoFaResult { Succeeded = true, Error = "" }); } if (user.AccessFailedCount >= 3) { await _db.SaveChangesAsync(); await _userManager.ResetAccessFailedCountAsync(user); return(new TwoFaResult { Succeeded = false, Error = "Otp code is wrong" }); } else { await _userManager.AccessFailedAsync(user); return(new TwoFaResult { Succeeded = false, Error = "Otp code is wrong" }); } } return(new TwoFaResult { Succeeded = false, Error = "" }); }
// Service login that worh with acount create service. public bool[] LoginService(string username, string password) { bool loginAccount = false; // bool check if login suceess bool exiteAccount = false; // check if account is exit bool[] result = new bool[2]; // return bool value as array size 2 AccountUser loginUser = new AccountUser(); // create object login user RootAccount_inJson RootJson = new RootAccount_inJson(); // create root array fot json List <AccountUser> ListAccount = new List <AccountUser>(); // create a list of account user for convert. EncryptDecrypService.ServiceClient proxyED = new EncryptDecrypService.ServiceClient(); // call the proxy service from encrypt and decrpt String pathJson = HttpRuntime.AppDomainAppPath + "\\UserStoreDataJson.json"; // find the path for Json data file. string Json; try { string JsonData = File.ReadAllText(pathJson); // read the Json path file to string RootJson = JsonConvert.DeserializeObject <RootAccount_inJson>(JsonData); //convert it to a array object of account user //check if the data is exits account. if (RootJson.UsersArray != null) { ListAccount = RootJson.UsersArray.ToList <AccountUser>(); // conver object root to list of acount user foreach (AccountUser item in ListAccount) // scant throught the list { if (item.username == username) // find the username { exiteAccount = true; // turn on the acount exit if (password == proxyED.Decrypt(item.password)) // check the the password it it correct by decrypt password. { loginAccount = true; } else { loginAccount = false; } } } } } catch (Exception ec) { } result[0] = exiteAccount; result[1] = loginAccount; return(result); }
public async Task <Unit> Handle(CreateAccountUserCommand request, CancellationToken cancellationToken) { var user = await _accountUsersRepository.CreateQuery().SingleOrDefaultAsync(x => x.UserRef == request.UserRef && x.AccountId == request.AccountId, cancellationToken); if (user == null) { user = new AccountUser(request.UserRef, request.AccountId, request.Role, request.Created, request.MessageId); await _accountUsersRepository.Add(user, null, cancellationToken); } else { user.Recreate(request.Role, request.Created, request.MessageId); await _accountUsersRepository.Update(user, null, cancellationToken); } return(Unit.Value); }
public bool AccontService(string username, string password) { bool createdAccount = false; // bool check if acount created bool exiteAccount = false; // bool check if account already created AccountUser newUser = new AccountUser(); // object for user create RootAccount_inJson RootJson = new RootAccount_inJson(); List <AccountUser> ListAccount = new List <AccountUser>(); string Json; String pathJson = HttpRuntime.AppDomainAppPath + "\\UserAccountArray.json"; // FInd the path for Json file that store User info //String pathJson = HttpContext.Current.Request.ApplicationPath;// ( @"\\UserStoreDataJson.json"); try { string JsonData = File.ReadAllText(pathJson); // Read all data in Json file int to string RootJson = JsonConvert.DeserializeObject <RootAccount_inJson>(JsonData); // convert string data to Json root // check if there are exit account in the Root if (RootJson.UsersArray != null) { ListAccount = RootJson.UsersArray.ToList <AccountUser>(); // teanser to a list of string for easy to convert and scan for check foreach (AccountUser item in ListAccount) // scan the list account { if (item.username == username) // find the username, mean account exit in the data. { exiteAccount = true; } } } // condition when account does not in the data then create new account. if (!exiteAccount) { newUser.username = username; newUser.password = password; //newUser.password = encrypted_password; ListAccount.Add(newUser); // add new user in the list RootJson.UsersArray = ListAccount.ToArray <AccountUser>(); // convert list to root object Json = JsonConvert.SerializeObject(RootJson, Formatting.Indented); // write back to Json format File.WriteAllText(pathJson, Json); // write back to Json file store in system createdAccount = true; } } catch (Exception ec) { } return(createdAccount); }
public IHttpActionResult GetWechatStatus() { var response = new ResponseObject <WechatAccountModel>(); var message = "当前用户未绑定"; AccountUser account = null; try { var request = HttpContext.Current.Request; var authToken = request.Headers["Authorization"].Replace("Bear ", ""); var openId = _wechatLoginEventService.GetOpenIdWithToken(authToken); if (string.IsNullOrEmpty(openId)) { throw new Exception("当前token无效"); } account = _accountService.GetAccountByOpenId(openId); if (account != null) { response.Data = new WechatAccountModel() { UserName = account.UserName, NickName = account.WechatNickName, AvatarUrl = account.AvatarUrl, Government = account.Government.Name }; message = "用户已绑定。"; } response.Message = message; response.Code = "200"; //_logger.Information("获取微信状态成功!", account); } catch (Exception ex) { response.Message = ex.Message; response.Code = "401"; //_logger.Error(string.Format("获取微信状态失败,错误原因:{0}", ex.GetOriginalException().Message), finder); } return(Ok(response)); }
public int Validates() { if (_account.OwnerId.HasValue) { _owner = MembershipService.GetUserById(_account.OwnerId.Value) as AccountUser; } _operatorUser = MembershipService.GetUserById(OperatorUserId); if (_operatorUser == null || !(_operatorUser is AdminUser)) { return(ResponseCode.InvalidateUser); } _dealWay = DealWayService.GetById(this.HowToDeal); if (_dealWay == null || _dealWay.State != DealWayStates.Normal) { return(ResponseCode.InvalidateDealWay); } return(ResponseCode.Success); }
/// <summary> /// Gets a value indicating whether property is in a certain property role /// </summary> /// <param name="property">AccountUser</param> /// <param name="customerRoleSystemName">AccountUser role system name</param> /// <param name="onlyActiveAccountUserRoles">A value indicating whether we should look only in active property roles</param> /// <returns>Result</returns> public static bool IsInAccountUserRole(this AccountUser property, string customerRoleSystemName, bool onlyActiveAccountUserRoles = true) { if (property == null) { throw new ArgumentNullException("property"); } if (String.IsNullOrEmpty(customerRoleSystemName)) { throw new ArgumentNullException("customerRoleSystemName"); } var result = property.AccountUserRoles .FirstOrDefault(cr => (!onlyActiveAccountUserRoles || cr.Active) && (cr.SystemName == customerRoleSystemName)) != null; return(result); }
private async Task LoadSharedKeyAndQrCodeUriAsync(AccountUser user) { // Load the authenticator key & QR code URI to display on the form var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); if (string.IsNullOrEmpty(unformattedKey)) { await _userManager.ResetAuthenticatorKeyAsync(user); unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); } SharedKey = FormatKey(unformattedKey); var email = await _userManager.GetEmailAsync(user); AuthenticatorUri = GenerateQrCodeUri(email, unformattedKey); }
/// <summary> /// Add roles relation for account user /// </summary> /// <param name="user">The created account user</param> /// <param name="roleId">The assigned role</param> private void addUserToRole(AccountUser user, int roleId) { var role = _roleRepository.GetSingle(roleId); if (role == null) { throw new Exception("Role does not exist."); } var userRole = new AccountUserRole() { RoleId = role.Id, AccountUserId = user.Id }; _accountUserRoleRepository.Add(userRole); _accountUserRoleRepository.Commit(); // change from base }
public async Task <IActionResult> Signin(AccountUser user) { var req = Request.HttpContext; var claims = new List <Claim>() { new Claim(ClaimTypes.Name, user.Username) }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); await req.SignInAsync("PizzaCookie", new ClaimsPrincipal(identity), new AuthenticationProperties() { IsPersistent = true, ExpiresUtc = new DateTimeOffset(DateTime.UtcNow.AddHours(1)) }); return(Ok()); }
private void btn_NewUser_Click(object sender, RoutedEventArgs e) { AccountUser au = new AccountUser(); au.User = new User(); NewUser nu = new NewUser(au); nu.ShowDialog(); if (au.IsAvailable) { if (_myAccount.AcctUsers.Where(c => c.User.Email.ToLower() == au.User.Email.ToLower()).FirstOrDefault() == null) { au.Uid = au.User.Id; _myAccount.AcctUsers.Add(au); } } }
public async Task <OtpCode> GenerateCodeForeUser(AccountUser user) { Random generator = new Random(); string randomValue = generator.Next(0, 999999).ToString("D6"); OtpCode otp = new OtpCode { Code = randomValue, UserId = user.Id, Expires = DateTime.Now.AddMinutes(2) }; _db.OtpCodes.Add(otp); await _emailService.SendEmailAsync(user.Email, otp.Code); await _db.SaveChangesAsync(); return(otp); }
public async Task CheckAndNavigateToMainShell(AccountUser user) { if (IsLoading) { return; } var loginResult = false; loginResult = await LoginTest(user); if (loginResult) { Locator.ViewModels.MainPageVm.CurrentUser = user; Locator.ViewModels.MainPageVm.IsLoggedIn = true; Locator.ViewModels.MainPageVm.PopulateMenu(); new NavigateToWhatsNewPage().Execute(null); } }
public IList <AccountUser> SelectAccounts(long idActivityDefinition, IList <SelectorDefinition> selectors, RuleContext ruleContext) { IList <AccountUser> collected = new List <AccountUser>(); foreach (SelectorDefinition selectorDefinition in selectors) { IList <RuleFilterDefinition> filters = _ruleStorePlugin.FindFiltersBySelectorId((long)selectorDefinition.Id); bool selectorMatch = true; foreach (RuleFilterDefinition ruleFilterDefinition in filters) { string field = ruleFilterDefinition.Field; string operat = ruleFilterDefinition.Operator; string expression = ruleFilterDefinition.Expression; bool result = false; switch (operat) { case "=": result = ruleContext[field].Equals(expression); break; } if (!result) { selectorMatch = false; } } if (selectorMatch) { IAccountStore accountStore = _accountManager.GetStore(); ISet <string> accounts = accountStore.GetAccountIds(selectorDefinition.GroupId); foreach (string accountId in accounts) { AccountUser account = accountStore.GetAccount(accountId); collected.Add(account); } } } return(collected); }
public async Task <IActionResult> ReplacePhoto(Photos model) { if (model != null) { string FileExtension = String.Empty; List <IFormFile> filelst = new List <IFormFile>(); filelst.Add(model.ReplacePhoto); //CHECK for new file if it's valid then proceed if (!ValidateFileExtension(filelst, out FileExtension)) { TempData["Error"] = "File Extension " + FileExtension + " is not allowed"; return(RedirectToAction("AlbumDetail", new RouteValueDictionary(new { controller = "User", action = "AlbumDetail", albumId = model.AlbumEncrypted }))); } Photos p = photoRepository.DeletePhoto(model.Id); //return RedirectToAction("AlbumDetail", new RouteValueDictionary(new { controller = "User", action = "AlbumDetail", albumId = AlbumEncrypted })); LMCommon.DeletePhoto(model.PhotoPath, hostingEnvironment.WebRootPath, configuration["PhotoPath"]); string path = await LMCommon.UploadPhoto(model.ReplacePhoto, hostingEnvironment.WebRootPath, configuration["PhotoPath"]); //REPLACE if (!String.IsNullOrEmpty(path)) { AccountUser user = await GetLoggedInUser(); Photos ph = new Photos(); ph.PhotoPath = path; ph.AlbumId = model.AlbumId; ph.UserId = user.Id; ph.UplodedDate = DateTime.Now.ToString(); ph.ImgName = GetImageName(path); photoRepository.Add(ph); toastNotification.AddSuccessToastMessage("Image Replace successfully"); } } return(RedirectToAction("AlbumDetail", new RouteValueDictionary(new { controller = "User", action = "AlbumDetail", albumId = model.AlbumEncrypted }))); }
public object SignIn(string id) { IUsuario usuario = this.model.SignIn(id); AccountUser retorno = this.model.GetAccount(usuario.UsuarioId); if (retorno.UsuarioId == 0 && String.IsNullOrEmpty(usuario.CustomId)) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent("No user found"), ReasonPhrase = "Error" }; throw new HttpResponseException(resp); } var simpleResult = CleanUser(retorno); return(simpleResult); }
/// <summary> /// 根据AccountUser获取用户对应菜单 /// </summary> /// <param name="user">AccountUser</param> /// <returns>菜单集合</returns> public static List <AccountMenu> GetUserMenus(AccountUser user) { try { if (user == null) { throw new Exception("LoginUser is null"); } return(factory.GetUserRoleMenus(user.userGuid, user.langCode)); } catch (Exception ex) { LogHelper.WriteLog(new Log() { message = ex.Message }, "GetUserMenu"); return(null); } }
public IList <AccountUser> SelectAccounts(IList <SelectorDefinition> selectors, IDictionary <int, List <RuleFilterDefinition> > dicFilters, RuleContext ruleContext) { IList <AccountUser> collected = new List <AccountUser>(); IList <SelectorDefinition> matchingSelectors = FindMatchingSelectors(selectors, dicFilters, ruleContext); IAccountStore accountStore = _accountManager.GetStore(); foreach (SelectorDefinition selectorDefinition in matchingSelectors) { ISet <string> accounts = accountStore.GetAccountIds(selectorDefinition.GroupId); foreach (string accountId in accounts) { AccountUser account = accountStore.GetAccount(accountId); collected.Add(account); } } return(collected); }
public string GetRole(AccountUser user) { var roles = this.roleManager.Roles.ToList(); string userRole = ""; var uRoles = this.userManager.GetRolesAsync(user).Result; if (uRoles.Contains("Admin")) { userRole = "Admin"; } else if (uRoles.Contains("User")) { userRole = "User"; } return(userRole); }
/// <summary>Runs multiple requests against the Content API for Shopping.</summary> internal void RunCalls(ulong merchantId, String emailAddress = "", ulong adWordsAccountId = 0) { // Can get information about your own account if non-MCA. GetAccount(merchantId); // Primary account, user management if (emailAddress != null && emailAddress != "") { AccountUser user = AddUser(merchantId, merchantId, emailAddress); RemoveUser(merchantId, merchantId, user.EmailAddress); } // Primary account, AdWords account link if (adWordsAccountId != 0) { LinkAdWordsAccount(merchantId, adWordsAccountId); UnlinkAdWordsAccount(merchantId, adWordsAccountId); } }
public async Task <IActionResult> ResetPassword(EditProfile obj) { ResetPasswordViewModel model = obj.RSVM; //CHECK user identity and proceed to reset password if (ModelState.IsValid) { AccountUser user = new AccountUser(); if (User.Identity.IsAuthenticated) { user = await userManager.GetUserAsync(User); if (user != null) { if (await userManager.CheckPasswordAsync(user, model.OldPassword)) { string token = await userManager.GeneratePasswordResetTokenAsync(user); var result = await userManager.ResetPasswordAsync(user, token, model.Password); if (result.Succeeded) { toastNotification.AddSuccessToastMessage("Password Reset Successfully."); return(RedirectToAction("EditProfile")); } //GIVE an error if something is wrong else { toastNotification.AddErrorToastMessage("Some issue to reset password."); } string errors = String.Empty; foreach (var item in result.Errors) { errors = errors + item.Description + "</br>"; } TempData["Errors"] = errors; } } } } return(RedirectToAction("EditProfile")); }
/// <summary>Runs multiple requests against the Content API for Shopping.</summary> internal void RunCalls(ulong merchantId, String emailAddress = "", ulong adWordsAccountId = 0) { // Products GetAllProducts(merchantId); Product newProduct = InsertProduct(merchantId); UpdateProduct(merchantId, newProduct.Id); UpdateProductUsingInventory(merchantId, newProduct.Id); DeleteProduct(merchantId, newProduct); // Products - batches List <String> productList = InsertProductCustombatch(merchantId); DeleteProductCustombatch(merchantId, productList); // Datafeeds var datafeed = GetAllDatafeeds(merchantId); Datafeed newDatafeed = InsertDatafeed(merchantId); UpdateDatafeed(merchantId, (ulong)newDatafeed.Id); try { DeleteDatafeed(merchantId, (ulong)newDatafeed.Id); } catch (Google.GoogleApiException e) { Console.WriteLine("Warning: Tried to delete a datafeed too soon after creation. " + e.Message); } // Primary account, user management if (emailAddress != "") { AccountUser user = AddUser(merchantId, merchantId, emailAddress); RemoveUser(merchantId, merchantId, user.EmailAddress); } // Primary account, AdWords account link if (adWordsAccountId != 0) { LinkAdWordsAccount(merchantId, adWordsAccountId); UnlinkAdWordsAccount(merchantId, adWordsAccountId); } }
private string GenerateJwtToken(string email, AccountUser user) { JwtSecurityTokenHandler tokenHandler = new JwtSecurityTokenHandler(); byte[] key = Encoding.ASCII.GetBytes(_appSettings.Secret); SecurityTokenDescriptor tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, user.Id.ToString()), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) }), Expires = DateTime.UtcNow.AddDays(7), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; SecurityToken token = tokenHandler.CreateToken(tokenDescriptor); return(tokenHandler.WriteToken(token)); }
public object SignIn(AccountUser accountUser) { IUsuario usuario = this.model.SignIn(accountUser.Password, accountUser.Email); AccountUser retorno = this.model.GetAccount(usuario.UsuarioId); if (retorno.UsuarioId == 0) { var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(string.Format("No user found!", accountUser.Email)), ReasonPhrase = "User not Found" }; throw new HttpResponseException(resp); } var simpleResult = CleanUser(retorno); return(simpleResult); }
/// <summary> /// Create or Update a user information across all partiations /// </summary> /// <param name="commonUser"></param> /// <param name="createdById"></param> /// <returns></returns> public async Task SaveAccountUser(CommonUser commonUser, Guid createdById, bool isAdmin = false) { //Get all accounts that this user belongs to var accounts = await _commonCtx.UserAccounts.Include(m => m.Account).ThenInclude(m => m.Partition).Where(m => m.UserId == commonUser.Id).ToListAsync(); //Go through each account and create or update the user's informatoin foreach (var account in accounts) { //generate an account context for this account var accountCtx = ContextsUtility.CreateAccountContext(Cryptography.Decrypt(account.Account.Partition.ConnectionString)); //check to see if this user exists in the account var user = await accountCtx.AccountUsers.SingleOrDefaultAsync(m => m.Id == commonUser.Id); //If the user doesn't exit, create them. if (user == null) { user = new AccountUser { Id = commonUser.Id, //IMPORTANT: CommonUser.Id and AccountUser.Id must always match FirstName = commonUser.FirstName, MiddleName = commonUser.MiddleName, LastName = commonUser.LastName, Email = commonUser.Email, ProfileImageKey = commonUser.ProfileImageKey, CreateUserId = createdById, UpdateUserId = createdById }; accountCtx.AccountUsers.Add(user); } else { user.FirstName = commonUser.FirstName; user.MiddleName = commonUser.MiddleName; user.LastName = commonUser.LastName; user.UpdateUserId = createdById; user.UpdateUtc = DateTime.UtcNow; user.ProfileImageKey = commonUser.ProfileImageKey; } await accountCtx.SaveChangesAsync(); } }
public async Task<ActionResult> Register(RegisterViewModel model) { setDisplayParams(); if (ModelState.IsValid) { SpicyGardenDbContext data = new SpicyGardenDbContext(); var user = new AccountUser { UserName = model.UserName, Email = model.Email, Validated = false, CreatedDate = DateTime.Now }; var customer = new Customer { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Telephone = model.Telephone, CreatedDate = DateTime.Now, AccountId = user.Id, Validated = false }; var address = new Address { AddrLine1 = model.AddrLine1, AddrLine2 = model.AddrLine2, CustomerId = customer.Id, AccountId = user.Id, CreatedDate = DateTime.Now, PostalCode = model.PostalCode }; customer.AddressId = address.Id; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { data.Customers.Add(customer); data.Addresses.Add(address); try { data.SaveChanges(); } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage); throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors); } await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); // first check html entity encode the return url just in case string return_url = Server.HtmlEncode(Request.Form["r"]); if (return_url == null) { return Redirect("/"); } else { return Redirect(return_url); } } AddErrors(result); } // If we got this far, something failed, redisplay form return View(model); }
public _BaseException(string message) : base(message) { //this.User = KitStr.SerializeObject(new { UserID = User.AccountUserID, UserName = User.UserName, CompanyID = User.AccountCompanyID }); AccountUser user = new AccountUser(); this.User = user; }
public _BaseException(string message, AccountUser user) : base(message) { this.User = user; }
public NewUser(AccountUser AccountUser):this() { _user = AccountUser; _user.IsAvailable = false; }
public int AddCampaign(Model.EF.Campaign campaign, AccountUser user) { //Updated by Action_Chen 20150805 //EventHandling & Logger框架程式範例 var baseLogger = new _BaseLogger(); //Updated by Action_Chen 20150805 //EventHandling & Logger框架程式範例 try { using (var scope = new DbContextScope(DbContextScopePurpose.Writing)) { campaign.DateCreated = DateTime.Now; campaign.DateModified = campaign.DateCreated; this.RepoCampaign.Insert(campaign); scope.SaveChanges(); } } //Updated by Action_Chen 20150805 //EventHandling & Logger框架程式範例 //catch (DbUpdateException ex) catch (Exception ex) { //throw new MigoDbUpdateException(); throw new MigoCommitFailedException(user); } return campaign.CampaignID; }
public MigoCommitFailedException(AccountUser user) : base(user, Message, StatusCode, WebHostHtmlMessage) { }
/// <summary> /// Adds a user to the primary account. /// </summary> /// <returns>The user that was created.</returns> private AccountUser AddUser(ulong merchantId, ulong accountId, String emailAddress) { Console.WriteLine("================================================================="); Console.WriteLine(String.Format("Linking account {0}", emailAddress)); Console.WriteLine("================================================================="); // First, retrieve list of users. Account account = service.Accounts.Get(merchantId, accountId).Execute(); AccountUser newAccountUser = new AccountUser(); newAccountUser.EmailAddress = emailAddress; newAccountUser.Admin = false; account.Users.Add(newAccountUser); // Set ETag to null as Patch() will reject it otherwise. account.ETag = null; // Patch the new list of accounts. Account response = service.Accounts.Patch(account, merchantId, accountId).Execute(); Console.WriteLine("User \"{0}\" was added to account {1}.", emailAddress, response.Id); Console.WriteLine(); return newAccountUser; }
public MigoDbUpdateException(AccountUser user) : base(user, Message, StatusCode, WebHostHtmlMessage) { }