public async Task <IActionResult> StoreAnonymousIdentifier() { if ((await loginHandler.LoggedInUserIdAsync(HttpContext)).HasValue || HttpContext.Session.GetString("anonymousIdentifier") != null) { return(Json(new { success = true })); } HttpContext.Session.SetString("anonymousIdentifier", randomProvider.RandomString(12)); return(Json(new { success = true })); }
public async Task <string> GenerateIdAsync() { bool okay; string generated; do { generated = randomProvider.RandomString(8).ToLowerInvariant(); okay = await GetAsync(generated) == null; } while (!okay); return(generated); }
public string GenerateId() { bool okay; string generated; do { generated = randomProvider.RandomString(8).ToLowerInvariant(); okay = Get(generated) == null; } while (!okay); return(generated); }