public ActionResult AdminConsent() { Tenant tenant = ClaimsIdentityExtensions.GetTenant(); string callBackUrl = "https://localhost:44300/Tenants/Create"; string url = "https://login.microsoftonline.com/" + tenant.TenantID + "/oauth2/authorize?client_id=" + Startup.clientId + "&response_type=code&redirect_uri=" + callBackUrl + "&nonce=1234&resource=https://graph.windows.net&prompt=admin_consent"; return(Redirect(url)); }
public ActionResult Index() { Models.Tenant tenantModel = ClaimsIdentityExtensions.GetTenant(); if (db.Tenants.Where(tenant => tenant.TenantID == tenantModel.TenantID).Count() > 0) { return(this.RedirectToAction("Index", "NewsItems")); } else { return(this.RedirectToAction("AdminConsent", "Permissions")); } }
// GET: Tenants/Create public ActionResult Create() { DatabaseContext.Tenant tenant = new Tenant(); if (true) { Models.Tenant tenantModel = ClaimsIdentityExtensions.GetTenant(); tenant.TenantID = tenantModel.TenantID; tenant.TenantName = tenantModel.TenantName; tenant.ClientID = Startup.clientId; tenant.ClientSecret = new Startup().appKey; tenant.URL = tenantModel.TenantDomain; tenant.Modified = DateTime.Now.Date; tenant.Created = DateTime.Now.Date; tenant.CreateBy = User.Identity.Name; tenant.ModifiedBy = User.Identity.Name; db.Tenants.Add(tenant); db.SaveChanges(); return(RedirectToAction("Index")); } }