This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const pwaAuth = document.querySelector("pwa-auth"); | |
| pwaAuth.addEventListener("signin-completed", ev => { | |
| const signIn = ev.detail; | |
| if (signIn.error) { | |
| console.error("Sign in failed", signIn.error); | |
| } else { | |
| console.log("Email: ", signIn.email); | |
| console.log("Name: ", signIn.name); | |
| console.log("Picture: ", signIn.imageUrl); | |
| console.log("Provider (MS, Google, FB): ", signIn.provider); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var session = raven.OpenSession()) | |
| { | |
| var cowboys = session.Query<Cowboy>().Where(c => c.FavoriteColor == "Orange"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var session = raven.OpenSession()) | |
| { | |
| var cowboy = new Cowboy | |
| { | |
| Name = "Maunder, C.", | |
| FavoriteColor = "Orange" | |
| }; | |
| session.Store(outlaw); | |
| session.SaveChanges(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Connect to our RavenDB Cloud cluster. | |
| // Notice the only thing that has changed is that we're passing 3 URLs in, one for each node in our cluster. | |
| var raven = new DocumentStore | |
| { | |
| Database = "OldWestHeroes", | |
| Urls = new[] | |
| { | |
| "https://a.cluster.clistctrl.ravendb.cloud", | |
| "https://b.cluster.clistctrl.ravendb.cloud", | |
| "https://c.cluster.clistctrl.ravendb.cloud", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var session = raven.OpenSession()) | |
| { | |
| var gunslingers = session.Query<Outlaw>().Where(o => o.IsGunslinger); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (var session = raven.OpenSession()) | |
| { | |
| var outlaw = new Outlaw | |
| { | |
| Name = "Simmons, J.", | |
| IsGunslinger = true | |
| }; | |
| session.Store(outlaw); | |
| session.SaveChanges(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var raven = new DocumentStore | |
| { | |
| Urls = new[] { "https://a.free.clistctrl.ravendb.cloud" }, | |
| Database = "Outlaws", | |
| Certificate = new X509Certificate2("\path\to\free.clistctrl.client.certificate.pfx", "") | |
| }; | |
| raven.Initialize(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class AccountController : Controller | |
| { | |
| private UserManager<AppUser> userManager; | |
| private SignInManager<AppUser> signInManager; | |
| // RavenDB.Identity provides a UserManager and SignInManager for dependency injection. | |
| public AccountController(UserManager<AppUser> userManager, SignInManager<AppUser> signInManager) | |
| { | |
| this.userManager = userManager; | |
| this.signInManager = signInManager; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HomeController : Controller | |
| { | |
| [Authorize] // Authorize: the user must be signed in | |
| public IActionResult Index() | |
| { | |
| } | |
| [Authorize(Roles = "Admin"] // Authorize: the signed in user must be an admin | |
| public IActionResult Index() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| // Add RavenDB and identity. | |
| services | |
| .AddRavenDb(Configuration.GetConnectionString("RavenDbConnection")) // Create a RavenDB DocumentStore singleton. | |
| .AddRavenDbAsyncSession() // Create a RavenDB IAsyncDocumentSession for each request. | |
| .AddRavenDbIdentity<AppUser>(); // Use Raven for users and roles. AppUser is your class, a simple DTO to hold user data. See https://github.com/JudahGabriel/RavenDB.Identity/blob/master/Sample/Models/AppUser.cs | |
| ... | |
| } |