Circles, pub & auth
* Adds a boolean to each Circle, saying that it is public, and its existence may be known by any interested in * Adds claims of type "YavscClaimTypes.CircleMembership" at login, in order to implement some faster authorisation processes and file restricted accesses.
This commit is contained in:
@ -109,6 +109,9 @@ namespace Yavsc.Models
|
|||||||
[JsonIgnore][InverseProperty("User")]
|
[JsonIgnore][InverseProperty("User")]
|
||||||
public virtual List<ChatRoomAccess> RoomAccess { get; set; }
|
public virtual List<ChatRoomAccess> RoomAccess { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore][InverseProperty("Member")]
|
||||||
|
public virtual List<CircleMember> Membership { get; set; }
|
||||||
|
|
||||||
public DateTime DateCreated
|
public DateTime DateCreated
|
||||||
{
|
{
|
||||||
get; set;
|
get; set;
|
||||||
|
@ -7,9 +7,12 @@ using Newtonsoft.Json;
|
|||||||
namespace Yavsc.Models.Relationship
|
namespace Yavsc.Models.Relationship
|
||||||
{
|
{
|
||||||
public class Circle {
|
public class Circle {
|
||||||
|
|
||||||
[Key, DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
|
[Key, DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public bool Public { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string OwnerId { get; set; }
|
public string OwnerId { get; set; }
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ namespace Yavsc.Models.Relationship
|
|||||||
|
|
||||||
[ForeignKey("CircleId")]
|
[ForeignKey("CircleId")]
|
||||||
public virtual Circle Circle { get; set; }
|
public virtual Circle Circle { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string MemberId { get; set; }
|
public string MemberId { get; set; }
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
namespace Yavsc {
|
namespace Yavsc {
|
||||||
public static class YavscClaimTypes {
|
public static class YavscClaimTypes {
|
||||||
|
|
||||||
|
public const string CircleMembership = "CircleMembership";
|
||||||
|
|
||||||
public const string GoogleUserId = "GoogleUserId";
|
public const string GoogleUserId = "GoogleUserId";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,17 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
|
using System.Collections.Generic;
|
||||||
using Yavsc.Abstract.Manage;
|
using Yavsc.Abstract.Manage;
|
||||||
|
using Yavsc.Auth;
|
||||||
using Yavsc.Helpers;
|
using Yavsc.Helpers;
|
||||||
|
|
||||||
public class AccountController : Controller
|
public class AccountController : Controller
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||||
|
const string nextPageTokenKey = "nextPageTokenKey";
|
||||||
|
const int defaultLen = 10;
|
||||||
private readonly IEmailSender _emailSender;
|
private readonly IEmailSender _emailSender;
|
||||||
// private readonly ISmsSender _smsSender;
|
// private readonly ISmsSender _smsSender;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
@ -39,6 +43,7 @@ namespace Yavsc.Controllers
|
|||||||
|
|
||||||
ApplicationDbContext _dbContext;
|
ApplicationDbContext _dbContext;
|
||||||
|
|
||||||
|
|
||||||
public AccountController(
|
public AccountController(
|
||||||
UserManager<ApplicationUser> userManager,
|
UserManager<ApplicationUser> userManager,
|
||||||
SignInManager<ApplicationUser> signInManager,
|
SignInManager<ApplicationUser> signInManager,
|
||||||
@ -49,7 +54,13 @@ namespace Yavsc.Controllers
|
|||||||
ApplicationDbContext dbContext)
|
ApplicationDbContext dbContext)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
|
|
||||||
_signInManager = signInManager;
|
_signInManager = signInManager;
|
||||||
|
var emailUserTokenProvider = new UserTokenProvider();
|
||||||
|
_userManager.RegisterTokenProvider("EmailConfirmation", emailUserTokenProvider);
|
||||||
|
|
||||||
|
_userManager.RegisterTokenProvider("ResetPassword", emailUserTokenProvider);
|
||||||
|
|
||||||
// _userManager.RegisterTokenProvider("SMS",new UserTokenProvider());
|
// _userManager.RegisterTokenProvider("SMS",new UserTokenProvider());
|
||||||
// _userManager.RegisterTokenProvider("Phone", new UserTokenProvider());
|
// _userManager.RegisterTokenProvider("Phone", new UserTokenProvider());
|
||||||
_emailSender = emailSender;
|
_emailSender = emailSender;
|
||||||
@ -60,8 +71,13 @@ namespace Yavsc.Controllers
|
|||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string nextPageTokenKey = "nextPageTokenKey";
|
|
||||||
const int defaultLen = 10;
|
[Authorize(Roles = Constants.AdminGroupName)]
|
||||||
|
public IActionResult Index(string page, string len)
|
||||||
|
{
|
||||||
|
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
[Authorize(Roles = Constants.AdminGroupName)]
|
[Authorize(Roles = Constants.AdminGroupName)]
|
||||||
[Route("Account/UserList/{page?}/{len?}")]
|
[Route("Account/UserList/{page?}/{len?}")]
|
||||||
@ -128,7 +144,9 @@ namespace Yavsc.Controllers
|
|||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
var user = await _userManager.FindByNameAsync(model.UserName);
|
var user = _dbContext.Users.Include(u=>u.Membership).FirstOrDefault(
|
||||||
|
u=>u.UserName == model.UserName);
|
||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
if (!await _userManager.IsEmailConfirmedAsync(user))
|
if (!await _userManager.IsEmailConfirmedAsync(user))
|
||||||
@ -145,8 +163,12 @@ namespace Yavsc.Controllers
|
|||||||
|
|
||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
{
|
{
|
||||||
|
await _userManager.AddClaimsAsync(user, user.Membership.Select(
|
||||||
|
m => new Claim(YavscClaimTypes.CircleMembership, m.CircleId.ToString())
|
||||||
|
));
|
||||||
return Redirect(model.ReturnUrl ?? "/");
|
return Redirect(model.ReturnUrl ?? "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.RequiresTwoFactor)
|
if (result.RequiresTwoFactor)
|
||||||
{
|
{
|
||||||
return RedirectToAction(nameof(SendCode), new { ReturnUrl = model.ReturnUrl, RememberMe = model.RememberMe });
|
return RedirectToAction(nameof(SendCode), new { ReturnUrl = model.ReturnUrl, RememberMe = model.RememberMe });
|
||||||
|
@ -69,7 +69,8 @@ namespace Yavsc.Controllers
|
|||||||
var accepted = Request.Headers["Accept"];
|
var accepted = Request.Headers["Accept"];
|
||||||
if (accepted.Contains("application/json"))
|
if (accepted.Contains("application/json"))
|
||||||
{
|
{
|
||||||
return new BadRequestObjectResult(new { error = this.HttpContext.Items } );
|
_logger.LogError("Invalid http status at authorisation");
|
||||||
|
return new BadRequestObjectResult(new { error = Response.StatusCode} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,6 +146,7 @@ namespace Yavsc.Controllers
|
|||||||
var accepted = Request.Headers["Accept"];
|
var accepted = Request.Headers["Accept"];
|
||||||
if (accepted.Contains("application/json"))
|
if (accepted.Contains("application/json"))
|
||||||
{
|
{
|
||||||
|
_logger.LogInformation("serving available scopes");
|
||||||
return Ok(model);
|
return Ok(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2062
src/Yavsc/Migrations/20190730164137_publicCircle.Designer.cs
generated
Normal file
2062
src/Yavsc/Migrations/20190730164137_publicCircle.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
935
src/Yavsc/Migrations/20190730164137_publicCircle.cs
Normal file
935
src/Yavsc/Migrations/20190730164137_publicCircle.cs
Normal file
@ -0,0 +1,935 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.Data.Entity.Migrations;
|
||||||
|
|
||||||
|
namespace Yavsc.Migrations
|
||||||
|
{
|
||||||
|
public partial class publicCircle : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Ban_ApplicationUser_TargetId", table: "Ban");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BlackListed_ApplicationUser_OwnerId", table: "BlackListed");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BlackListed_ApplicationUser_UserId", table: "BlackListed");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_BlogPost_BlogPostId", table: "CircleAuthorizationToBlogPost");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId", table: "CircleAuthorizationToBlogPost");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_AccountBalance_ApplicationUser_UserId", table: "AccountBalance");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BalanceImpact_AccountBalance_BalanceId", table: "BalanceImpact");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CommandLine_Estimate_EstimateId", table: "CommandLine");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Estimate_ApplicationUser_ClientId", table: "Estimate");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BlogTag_BlogPost_PostId", table: "BlogTag");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BlogTag_Tag_TagId", table: "BlogTag");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Comment_ApplicationUser_AuthorId", table: "Comment");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Comment_BlogPost_PostId", table: "Comment");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Schedule_ApplicationUser_OwnerId", table: "Schedule");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_ChatConnection_ApplicationUser_ApplicationUserId", table: "ChatConnection");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_ChatRoomAccess_ApplicationUser_UserId", table: "ChatRoomAccess");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BrusherProfile_PerformerProfile_UserId", table: "BrusherProfile");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_Activity_ActivityCode", table: "HairCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_ApplicationUser_ClientId", table: "HairCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_PerformerProfile_PerformerId", table: "HairCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_HairPrestation_PrestationId", table: "HairCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_Activity_ActivityCode", table: "HairMultiCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_ApplicationUser_ClientId", table: "HairMultiCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_PerformerProfile_PerformerId", table: "HairMultiCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairPrestationCollectionItem_HairPrestation_PrestationId", table: "HairPrestationCollectionItem");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairPrestationCollectionItem_HairMultiCutQuery_QueryId", table: "HairPrestationCollectionItem");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairTaint_Color_ColorId", table: "HairTaint");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairTaintInstance_HairPrestation_PrestationId", table: "HairTaintInstance");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairTaintInstance_HairTaint_TaintId", table: "HairTaintInstance");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_DimissClicked_Notification_NotificationId", table: "DimissClicked");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_DimissClicked_ApplicationUser_UserId", table: "DimissClicked");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Instrumentation_Instrument_InstrumentId", table: "Instrumentation");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_PayPalPayment_ApplicationUser_ExecutorId", table: "PayPalPayment");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Contact_PostalAddress_AddressId", table: "Contact");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_LiveFlow_ApplicationUser_OwnerId", table: "LiveFlow");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CommandForm_Activity_ActivityCode", table: "CommandForm");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_Activity_ActivityCode", table: "RdvQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_ApplicationUser_ClientId", table: "RdvQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_PerformerProfile_PerformerId", table: "RdvQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_UserActivity_Activity_DoesCode", table: "UserActivity");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_MailingTemplate_ApplicationUser_ManagerId", table: "MailingTemplate");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_MailingTemplate_ApplicationUser_SuccessorId", table: "MailingTemplate");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Project_Activity_ActivityCode", table: "Project");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Project_ApplicationUser_ClientId", table: "Project");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Project_GitRepositoryReference_GitId", table: "Project");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Project_PerformerProfile_PerformerId", table: "Project");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_ProjectBuildConfiguration_Project_ProjectId", table: "ProjectBuildConfiguration");
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "Public",
|
||||||
|
table: "Circle",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
|
||||||
|
table: "AspNetRoleClaims",
|
||||||
|
column: "RoleId",
|
||||||
|
principalTable: "AspNetRoles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
|
||||||
|
table: "AspNetUserClaims",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
|
||||||
|
table: "AspNetUserLogins",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
|
||||||
|
table: "AspNetUserRoles",
|
||||||
|
column: "RoleId",
|
||||||
|
principalTable: "AspNetRoles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
|
||||||
|
table: "AspNetUserRoles",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Ban_ApplicationUser_TargetId",
|
||||||
|
table: "Ban",
|
||||||
|
column: "TargetId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BlackListed_ApplicationUser_OwnerId",
|
||||||
|
table: "BlackListed",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BlackListed_ApplicationUser_UserId",
|
||||||
|
table: "BlackListed",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleAuthorizationToBlogPost_BlogPost_BlogPostId",
|
||||||
|
table: "CircleAuthorizationToBlogPost",
|
||||||
|
column: "BlogPostId",
|
||||||
|
principalTable: "BlogPost",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId",
|
||||||
|
table: "CircleAuthorizationToBlogPost",
|
||||||
|
column: "CircleId",
|
||||||
|
principalTable: "Circle",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_AccountBalance_ApplicationUser_UserId",
|
||||||
|
table: "AccountBalance",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BalanceImpact_AccountBalance_BalanceId",
|
||||||
|
table: "BalanceImpact",
|
||||||
|
column: "BalanceId",
|
||||||
|
principalTable: "AccountBalance",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CommandLine_Estimate_EstimateId",
|
||||||
|
table: "CommandLine",
|
||||||
|
column: "EstimateId",
|
||||||
|
principalTable: "Estimate",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Estimate_ApplicationUser_ClientId",
|
||||||
|
table: "Estimate",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BlogTag_BlogPost_PostId",
|
||||||
|
table: "BlogTag",
|
||||||
|
column: "PostId",
|
||||||
|
principalTable: "BlogPost",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BlogTag_Tag_TagId",
|
||||||
|
table: "BlogTag",
|
||||||
|
column: "TagId",
|
||||||
|
principalTable: "Tag",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Comment_ApplicationUser_AuthorId",
|
||||||
|
table: "Comment",
|
||||||
|
column: "AuthorId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Comment_BlogPost_PostId",
|
||||||
|
table: "Comment",
|
||||||
|
column: "PostId",
|
||||||
|
principalTable: "BlogPost",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Schedule_ApplicationUser_OwnerId",
|
||||||
|
table: "Schedule",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ChatConnection_ApplicationUser_ApplicationUserId",
|
||||||
|
table: "ChatConnection",
|
||||||
|
column: "ApplicationUserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ChatRoomAccess_ApplicationUser_UserId",
|
||||||
|
table: "ChatRoomAccess",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BrusherProfile_PerformerProfile_UserId",
|
||||||
|
table: "BrusherProfile",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairCutQuery_Activity_ActivityCode",
|
||||||
|
table: "HairCutQuery",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairCutQuery_ApplicationUser_ClientId",
|
||||||
|
table: "HairCutQuery",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairCutQuery_PerformerProfile_PerformerId",
|
||||||
|
table: "HairCutQuery",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairCutQuery_HairPrestation_PrestationId",
|
||||||
|
table: "HairCutQuery",
|
||||||
|
column: "PrestationId",
|
||||||
|
principalTable: "HairPrestation",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairMultiCutQuery_Activity_ActivityCode",
|
||||||
|
table: "HairMultiCutQuery",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairMultiCutQuery_ApplicationUser_ClientId",
|
||||||
|
table: "HairMultiCutQuery",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairMultiCutQuery_PerformerProfile_PerformerId",
|
||||||
|
table: "HairMultiCutQuery",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairPrestationCollectionItem_HairPrestation_PrestationId",
|
||||||
|
table: "HairPrestationCollectionItem",
|
||||||
|
column: "PrestationId",
|
||||||
|
principalTable: "HairPrestation",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairPrestationCollectionItem_HairMultiCutQuery_QueryId",
|
||||||
|
table: "HairPrestationCollectionItem",
|
||||||
|
column: "QueryId",
|
||||||
|
principalTable: "HairMultiCutQuery",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairTaint_Color_ColorId",
|
||||||
|
table: "HairTaint",
|
||||||
|
column: "ColorId",
|
||||||
|
principalTable: "Color",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairTaintInstance_HairPrestation_PrestationId",
|
||||||
|
table: "HairTaintInstance",
|
||||||
|
column: "PrestationId",
|
||||||
|
principalTable: "HairPrestation",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairTaintInstance_HairTaint_TaintId",
|
||||||
|
table: "HairTaintInstance",
|
||||||
|
column: "TaintId",
|
||||||
|
principalTable: "HairTaint",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_DimissClicked_Notification_NotificationId",
|
||||||
|
table: "DimissClicked",
|
||||||
|
column: "NotificationId",
|
||||||
|
principalTable: "Notification",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_DimissClicked_ApplicationUser_UserId",
|
||||||
|
table: "DimissClicked",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Instrumentation_Instrument_InstrumentId",
|
||||||
|
table: "Instrumentation",
|
||||||
|
column: "InstrumentId",
|
||||||
|
principalTable: "Instrument",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PayPalPayment_ApplicationUser_ExecutorId",
|
||||||
|
table: "PayPalPayment",
|
||||||
|
column: "ExecutorId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleMember_Circle_CircleId",
|
||||||
|
table: "CircleMember",
|
||||||
|
column: "CircleId",
|
||||||
|
principalTable: "Circle",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleMember_ApplicationUser_MemberId",
|
||||||
|
table: "CircleMember",
|
||||||
|
column: "MemberId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Contact_PostalAddress_AddressId",
|
||||||
|
table: "Contact",
|
||||||
|
column: "AddressId",
|
||||||
|
principalTable: "PostalAddress",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_LiveFlow_ApplicationUser_OwnerId",
|
||||||
|
table: "LiveFlow",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CommandForm_Activity_ActivityCode",
|
||||||
|
table: "CommandForm",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PerformerProfile_Location_OrganizationAddressId",
|
||||||
|
table: "PerformerProfile",
|
||||||
|
column: "OrganizationAddressId",
|
||||||
|
principalTable: "Location",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PerformerProfile_ApplicationUser_PerformerId",
|
||||||
|
table: "PerformerProfile",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RdvQuery_Activity_ActivityCode",
|
||||||
|
table: "RdvQuery",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RdvQuery_ApplicationUser_ClientId",
|
||||||
|
table: "RdvQuery",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RdvQuery_PerformerProfile_PerformerId",
|
||||||
|
table: "RdvQuery",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_UserActivity_Activity_DoesCode",
|
||||||
|
table: "UserActivity",
|
||||||
|
column: "DoesCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_UserActivity_PerformerProfile_UserId",
|
||||||
|
table: "UserActivity",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_MailingTemplate_ApplicationUser_ManagerId",
|
||||||
|
table: "MailingTemplate",
|
||||||
|
column: "ManagerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_MailingTemplate_ApplicationUser_SuccessorId",
|
||||||
|
table: "MailingTemplate",
|
||||||
|
column: "SuccessorId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Project_Activity_ActivityCode",
|
||||||
|
table: "Project",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Project_ApplicationUser_ClientId",
|
||||||
|
table: "Project",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Project_GitRepositoryReference_GitId",
|
||||||
|
table: "Project",
|
||||||
|
column: "GitId",
|
||||||
|
principalTable: "GitRepositoryReference",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Project_PerformerProfile_PerformerId",
|
||||||
|
table: "Project",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ProjectBuildConfiguration_Project_ProjectId",
|
||||||
|
table: "ProjectBuildConfiguration",
|
||||||
|
column: "ProjectId",
|
||||||
|
principalTable: "Project",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId", table: "AspNetRoleClaims");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId", table: "AspNetUserClaims");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId", table: "AspNetUserLogins");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_IdentityRole_RoleId", table: "AspNetUserRoles");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_IdentityUserRole<string>_ApplicationUser_UserId", table: "AspNetUserRoles");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Ban_ApplicationUser_TargetId", table: "Ban");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BlackListed_ApplicationUser_OwnerId", table: "BlackListed");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BlackListed_ApplicationUser_UserId", table: "BlackListed");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_BlogPost_BlogPostId", table: "CircleAuthorizationToBlogPost");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId", table: "CircleAuthorizationToBlogPost");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_AccountBalance_ApplicationUser_UserId", table: "AccountBalance");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BalanceImpact_AccountBalance_BalanceId", table: "BalanceImpact");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CommandLine_Estimate_EstimateId", table: "CommandLine");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Estimate_ApplicationUser_ClientId", table: "Estimate");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BlogTag_BlogPost_PostId", table: "BlogTag");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BlogTag_Tag_TagId", table: "BlogTag");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Comment_ApplicationUser_AuthorId", table: "Comment");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Comment_BlogPost_PostId", table: "Comment");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Schedule_ApplicationUser_OwnerId", table: "Schedule");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_ChatConnection_ApplicationUser_ApplicationUserId", table: "ChatConnection");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_ChatRoomAccess_ApplicationUser_UserId", table: "ChatRoomAccess");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BrusherProfile_PerformerProfile_UserId", table: "BrusherProfile");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_Activity_ActivityCode", table: "HairCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_ApplicationUser_ClientId", table: "HairCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_PerformerProfile_PerformerId", table: "HairCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairCutQuery_HairPrestation_PrestationId", table: "HairCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_Activity_ActivityCode", table: "HairMultiCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_ApplicationUser_ClientId", table: "HairMultiCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairMultiCutQuery_PerformerProfile_PerformerId", table: "HairMultiCutQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairPrestationCollectionItem_HairPrestation_PrestationId", table: "HairPrestationCollectionItem");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairPrestationCollectionItem_HairMultiCutQuery_QueryId", table: "HairPrestationCollectionItem");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairTaint_Color_ColorId", table: "HairTaint");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairTaintInstance_HairPrestation_PrestationId", table: "HairTaintInstance");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_HairTaintInstance_HairTaint_TaintId", table: "HairTaintInstance");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_DimissClicked_Notification_NotificationId", table: "DimissClicked");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_DimissClicked_ApplicationUser_UserId", table: "DimissClicked");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Instrumentation_Instrument_InstrumentId", table: "Instrumentation");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_PayPalPayment_ApplicationUser_ExecutorId", table: "PayPalPayment");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Contact_PostalAddress_AddressId", table: "Contact");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_LiveFlow_ApplicationUser_OwnerId", table: "LiveFlow");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CommandForm_Activity_ActivityCode", table: "CommandForm");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_Location_OrganizationAddressId", table: "PerformerProfile");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_Activity_ActivityCode", table: "RdvQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_ApplicationUser_ClientId", table: "RdvQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_RdvQuery_PerformerProfile_PerformerId", table: "RdvQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_UserActivity_Activity_DoesCode", table: "UserActivity");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_MailingTemplate_ApplicationUser_ManagerId", table: "MailingTemplate");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_MailingTemplate_ApplicationUser_SuccessorId", table: "MailingTemplate");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Project_Activity_ActivityCode", table: "Project");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Project_ApplicationUser_ClientId", table: "Project");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Project_GitRepositoryReference_GitId", table: "Project");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Project_PerformerProfile_PerformerId", table: "Project");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_ProjectBuildConfiguration_Project_ProjectId", table: "ProjectBuildConfiguration");
|
||||||
|
migrationBuilder.DropColumn(name: "Public", table: "Circle");
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
|
||||||
|
table: "AspNetRoleClaims",
|
||||||
|
column: "RoleId",
|
||||||
|
principalTable: "AspNetRoles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityUserClaim<string>_ApplicationUser_UserId",
|
||||||
|
table: "AspNetUserClaims",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityUserLogin<string>_ApplicationUser_UserId",
|
||||||
|
table: "AspNetUserLogins",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityUserRole<string>_IdentityRole_RoleId",
|
||||||
|
table: "AspNetUserRoles",
|
||||||
|
column: "RoleId",
|
||||||
|
principalTable: "AspNetRoles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_IdentityUserRole<string>_ApplicationUser_UserId",
|
||||||
|
table: "AspNetUserRoles",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Ban_ApplicationUser_TargetId",
|
||||||
|
table: "Ban",
|
||||||
|
column: "TargetId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BlackListed_ApplicationUser_OwnerId",
|
||||||
|
table: "BlackListed",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BlackListed_ApplicationUser_UserId",
|
||||||
|
table: "BlackListed",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleAuthorizationToBlogPost_BlogPost_BlogPostId",
|
||||||
|
table: "CircleAuthorizationToBlogPost",
|
||||||
|
column: "BlogPostId",
|
||||||
|
principalTable: "BlogPost",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleAuthorizationToBlogPost_Circle_CircleId",
|
||||||
|
table: "CircleAuthorizationToBlogPost",
|
||||||
|
column: "CircleId",
|
||||||
|
principalTable: "Circle",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_AccountBalance_ApplicationUser_UserId",
|
||||||
|
table: "AccountBalance",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BalanceImpact_AccountBalance_BalanceId",
|
||||||
|
table: "BalanceImpact",
|
||||||
|
column: "BalanceId",
|
||||||
|
principalTable: "AccountBalance",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CommandLine_Estimate_EstimateId",
|
||||||
|
table: "CommandLine",
|
||||||
|
column: "EstimateId",
|
||||||
|
principalTable: "Estimate",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Estimate_ApplicationUser_ClientId",
|
||||||
|
table: "Estimate",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BlogTag_BlogPost_PostId",
|
||||||
|
table: "BlogTag",
|
||||||
|
column: "PostId",
|
||||||
|
principalTable: "BlogPost",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BlogTag_Tag_TagId",
|
||||||
|
table: "BlogTag",
|
||||||
|
column: "TagId",
|
||||||
|
principalTable: "Tag",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Comment_ApplicationUser_AuthorId",
|
||||||
|
table: "Comment",
|
||||||
|
column: "AuthorId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Comment_BlogPost_PostId",
|
||||||
|
table: "Comment",
|
||||||
|
column: "PostId",
|
||||||
|
principalTable: "BlogPost",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Schedule_ApplicationUser_OwnerId",
|
||||||
|
table: "Schedule",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ChatConnection_ApplicationUser_ApplicationUserId",
|
||||||
|
table: "ChatConnection",
|
||||||
|
column: "ApplicationUserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ChatRoomAccess_ApplicationUser_UserId",
|
||||||
|
table: "ChatRoomAccess",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BrusherProfile_PerformerProfile_UserId",
|
||||||
|
table: "BrusherProfile",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairCutQuery_Activity_ActivityCode",
|
||||||
|
table: "HairCutQuery",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairCutQuery_ApplicationUser_ClientId",
|
||||||
|
table: "HairCutQuery",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairCutQuery_PerformerProfile_PerformerId",
|
||||||
|
table: "HairCutQuery",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairCutQuery_HairPrestation_PrestationId",
|
||||||
|
table: "HairCutQuery",
|
||||||
|
column: "PrestationId",
|
||||||
|
principalTable: "HairPrestation",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairMultiCutQuery_Activity_ActivityCode",
|
||||||
|
table: "HairMultiCutQuery",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairMultiCutQuery_ApplicationUser_ClientId",
|
||||||
|
table: "HairMultiCutQuery",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairMultiCutQuery_PerformerProfile_PerformerId",
|
||||||
|
table: "HairMultiCutQuery",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairPrestationCollectionItem_HairPrestation_PrestationId",
|
||||||
|
table: "HairPrestationCollectionItem",
|
||||||
|
column: "PrestationId",
|
||||||
|
principalTable: "HairPrestation",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairPrestationCollectionItem_HairMultiCutQuery_QueryId",
|
||||||
|
table: "HairPrestationCollectionItem",
|
||||||
|
column: "QueryId",
|
||||||
|
principalTable: "HairMultiCutQuery",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairTaint_Color_ColorId",
|
||||||
|
table: "HairTaint",
|
||||||
|
column: "ColorId",
|
||||||
|
principalTable: "Color",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairTaintInstance_HairPrestation_PrestationId",
|
||||||
|
table: "HairTaintInstance",
|
||||||
|
column: "PrestationId",
|
||||||
|
principalTable: "HairPrestation",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_HairTaintInstance_HairTaint_TaintId",
|
||||||
|
table: "HairTaintInstance",
|
||||||
|
column: "TaintId",
|
||||||
|
principalTable: "HairTaint",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_DimissClicked_Notification_NotificationId",
|
||||||
|
table: "DimissClicked",
|
||||||
|
column: "NotificationId",
|
||||||
|
principalTable: "Notification",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_DimissClicked_ApplicationUser_UserId",
|
||||||
|
table: "DimissClicked",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Instrumentation_Instrument_InstrumentId",
|
||||||
|
table: "Instrumentation",
|
||||||
|
column: "InstrumentId",
|
||||||
|
principalTable: "Instrument",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PayPalPayment_ApplicationUser_ExecutorId",
|
||||||
|
table: "PayPalPayment",
|
||||||
|
column: "ExecutorId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleMember_Circle_CircleId",
|
||||||
|
table: "CircleMember",
|
||||||
|
column: "CircleId",
|
||||||
|
principalTable: "Circle",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleMember_ApplicationUser_MemberId",
|
||||||
|
table: "CircleMember",
|
||||||
|
column: "MemberId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Contact_PostalAddress_AddressId",
|
||||||
|
table: "Contact",
|
||||||
|
column: "AddressId",
|
||||||
|
principalTable: "PostalAddress",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_LiveFlow_ApplicationUser_OwnerId",
|
||||||
|
table: "LiveFlow",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CommandForm_Activity_ActivityCode",
|
||||||
|
table: "CommandForm",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PerformerProfile_Location_OrganizationAddressId",
|
||||||
|
table: "PerformerProfile",
|
||||||
|
column: "OrganizationAddressId",
|
||||||
|
principalTable: "Location",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_PerformerProfile_ApplicationUser_PerformerId",
|
||||||
|
table: "PerformerProfile",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RdvQuery_Activity_ActivityCode",
|
||||||
|
table: "RdvQuery",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RdvQuery_ApplicationUser_ClientId",
|
||||||
|
table: "RdvQuery",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_RdvQuery_PerformerProfile_PerformerId",
|
||||||
|
table: "RdvQuery",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_UserActivity_Activity_DoesCode",
|
||||||
|
table: "UserActivity",
|
||||||
|
column: "DoesCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_UserActivity_PerformerProfile_UserId",
|
||||||
|
table: "UserActivity",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_MailingTemplate_ApplicationUser_ManagerId",
|
||||||
|
table: "MailingTemplate",
|
||||||
|
column: "ManagerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_MailingTemplate_ApplicationUser_SuccessorId",
|
||||||
|
table: "MailingTemplate",
|
||||||
|
column: "SuccessorId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Project_Activity_ActivityCode",
|
||||||
|
table: "Project",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Project_ApplicationUser_ClientId",
|
||||||
|
table: "Project",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Project_GitRepositoryReference_GitId",
|
||||||
|
table: "Project",
|
||||||
|
column: "GitId",
|
||||||
|
principalTable: "GitRepositoryReference",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Project_PerformerProfile_PerformerId",
|
||||||
|
table: "Project",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_ProjectBuildConfiguration_Project_ProjectId",
|
||||||
|
table: "ProjectBuildConfiguration",
|
||||||
|
column: "ProjectId",
|
||||||
|
principalTable: "Project",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1107,6 +1107,8 @@ namespace Yavsc.Migrations
|
|||||||
|
|
||||||
b.Property<string>("OwnerId");
|
b.Property<string>("OwnerId");
|
||||||
|
|
||||||
|
b.Property<bool>("Public");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -19,14 +19,16 @@ using Microsoft.Extensions.WebEncoders;
|
|||||||
using OAuth.AspNet.AuthServer;
|
using OAuth.AspNet.AuthServer;
|
||||||
using OAuth.AspNet.Tokens;
|
using OAuth.AspNet.Tokens;
|
||||||
|
|
||||||
namespace Yavsc {
|
namespace Yavsc
|
||||||
|
{
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Auth;
|
using Auth;
|
||||||
using Extensions;
|
using Extensions;
|
||||||
using Models;
|
using Models;
|
||||||
using Yavsc.Helpers.Auth;
|
using Yavsc.Helpers.Auth;
|
||||||
|
|
||||||
public partial class Startup {
|
public partial class Startup
|
||||||
|
{
|
||||||
public static CookieAuthenticationOptions ExternalCookieAppOptions { get; private set; }
|
public static CookieAuthenticationOptions ExternalCookieAppOptions { get; private set; }
|
||||||
|
|
||||||
public static IdentityOptions IdentityAppOptions { get; set; }
|
public static IdentityOptions IdentityAppOptions { get; set; }
|
||||||
@ -40,14 +42,16 @@ namespace Yavsc {
|
|||||||
|
|
||||||
// public static CookieAuthenticationOptions BearerCookieOptions { get; private set; }
|
// public static CookieAuthenticationOptions BearerCookieOptions { get; private set; }
|
||||||
|
|
||||||
private void ConfigureOAuthServices (IServiceCollection services) {
|
private void ConfigureOAuthServices(IServiceCollection services)
|
||||||
|
{
|
||||||
services.Configure<SharedAuthenticationOptions>(options => options.SignInScheme = Constants.ApplicationAuthenticationSheme);
|
services.Configure<SharedAuthenticationOptions>(options => options.SignInScheme = Constants.ApplicationAuthenticationSheme);
|
||||||
|
|
||||||
services.Add(ServiceDescriptor.Singleton(typeof(IOptions<OAuth2AppSettings>), typeof(OptionsManager<OAuth2AppSettings>)));
|
services.Add(ServiceDescriptor.Singleton(typeof(IOptions<OAuth2AppSettings>), typeof(OptionsManager<OAuth2AppSettings>)));
|
||||||
// used by the YavscGoogleOAuth middelware (TODO drop it)
|
// used by the YavscGoogleOAuth middelware (TODO drop it)
|
||||||
services.AddTransient<Microsoft.Extensions.WebEncoders.UrlEncoder, UrlEncoder>();
|
services.AddTransient<Microsoft.Extensions.WebEncoders.UrlEncoder, UrlEncoder>();
|
||||||
|
|
||||||
services.AddAuthentication (options => {
|
services.AddAuthentication(options =>
|
||||||
|
{
|
||||||
options.SignInScheme = Constants.ExternalAuthenticationSheme;
|
options.SignInScheme = Constants.ExternalAuthenticationSheme;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,7 +60,8 @@ namespace Yavsc {
|
|||||||
(ProtectionProvider);
|
(ProtectionProvider);
|
||||||
|
|
||||||
services.AddIdentity<ApplicationUser, IdentityRole>(
|
services.AddIdentity<ApplicationUser, IdentityRole>(
|
||||||
option => {
|
option =>
|
||||||
|
{
|
||||||
IdentityAppOptions = option;
|
IdentityAppOptions = option;
|
||||||
option.User.AllowedUserNameCharacters += " ";
|
option.User.AllowedUserNameCharacters += " ";
|
||||||
option.User.RequireUniqueEmail = true;
|
option.User.RequireUniqueEmail = true;
|
||||||
@ -88,7 +93,8 @@ namespace Yavsc {
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
private void ConfigureOAuthApp(IApplicationBuilder app,
|
private void ConfigureOAuthApp(IApplicationBuilder app,
|
||||||
SiteSettings settingsOptions, ILogger logger) {
|
SiteSettings settingsOptions, ILogger logger)
|
||||||
|
{
|
||||||
|
|
||||||
app.UseIdentity();
|
app.UseIdentity();
|
||||||
app.UseWhen(context => context.Request.Path.StartsWithSegments("/api")
|
app.UseWhen(context => context.Request.Path.StartsWithSegments("/api")
|
||||||
@ -96,18 +102,21 @@ namespace Yavsc {
|
|||||||
branchLiveOrApi =>
|
branchLiveOrApi =>
|
||||||
{
|
{
|
||||||
branchLiveOrApi.UseJwtBearerAuthentication(
|
branchLiveOrApi.UseJwtBearerAuthentication(
|
||||||
options => {
|
options =>
|
||||||
|
{
|
||||||
options.AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
options.AutomaticAuthenticate = true;
|
options.AutomaticAuthenticate = true;
|
||||||
options.SecurityTokenValidators.Clear();
|
options.SecurityTokenValidators.Clear();
|
||||||
options.SecurityTokenValidators.Add (new TicketDataFormatTokenValidator (
|
var tickeDataProtector = new TicketDataFormatTokenValidator(
|
||||||
ProtectionProvider
|
ProtectionProvider
|
||||||
));
|
);
|
||||||
|
options.SecurityTokenValidators.Add(tickeDataProtector);
|
||||||
options.Events = new JwtBearerEvents
|
options.Events = new JwtBearerEvents
|
||||||
{
|
{
|
||||||
OnReceivingToken = context =>
|
OnReceivingToken = context =>
|
||||||
{
|
{
|
||||||
return Task.Run( () => {
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
var signalRTokenHeader = context.Request.Query["signalRTokenHeader"];
|
var signalRTokenHeader = context.Request.Query["signalRTokenHeader"];
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(signalRTokenHeader) &&
|
if (!string.IsNullOrEmpty(signalRTokenHeader) &&
|
||||||
@ -121,9 +130,11 @@ namespace Yavsc {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
app.UseWhen(context => !context.Request.Path.StartsWithSegments("/api") && !context.Request.Path.StartsWithSegments("/live"),
|
app.UseWhen(context => !context.Request.Path.StartsWithSegments("/api") && !context.Request.Path.StartsWithSegments("/live"),
|
||||||
branch => {
|
branch =>
|
||||||
|
{
|
||||||
// External authentication shared cookie:
|
// External authentication shared cookie:
|
||||||
branch.UseCookieAuthentication (options => {
|
branch.UseCookieAuthentication(options =>
|
||||||
|
{
|
||||||
ExternalCookieAppOptions = options;
|
ExternalCookieAppOptions = options;
|
||||||
options.AuthenticationScheme = Constants.ExternalAuthenticationSheme;
|
options.AuthenticationScheme = Constants.ExternalAuthenticationSheme;
|
||||||
options.AutomaticAuthenticate = true;
|
options.AutomaticAuthenticate = true;
|
||||||
@ -132,7 +143,8 @@ namespace Yavsc {
|
|||||||
options.AccessDeniedPath = new PathString(Constants.LoginPath.Substring(1));
|
options.AccessDeniedPath = new PathString(Constants.LoginPath.Substring(1));
|
||||||
});
|
});
|
||||||
|
|
||||||
YavscGoogleAppOptions = new YavscGoogleOptions {
|
YavscGoogleAppOptions = new YavscGoogleOptions
|
||||||
|
{
|
||||||
ClientId = GoogleWebClientConfiguration["web:client_id"],
|
ClientId = GoogleWebClientConfiguration["web:client_id"],
|
||||||
ClientSecret = GoogleWebClientConfiguration["web:client_secret"],
|
ClientSecret = GoogleWebClientConfiguration["web:client_secret"],
|
||||||
AccessType = "offline",
|
AccessType = "offline",
|
||||||
@ -144,16 +156,20 @@ namespace Yavsc {
|
|||||||
},
|
},
|
||||||
SaveTokensAsClaims = true,
|
SaveTokensAsClaims = true,
|
||||||
UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me",
|
UserInformationEndpoint = "https://www.googleapis.com/plus/v1/people/me",
|
||||||
Events = new OAuthEvents {
|
Events = new OAuthEvents
|
||||||
OnCreatingTicket = async context => {
|
{
|
||||||
|
OnCreatingTicket = async context =>
|
||||||
|
{
|
||||||
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
|
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
|
||||||
.CreateScope ()) {
|
.CreateScope())
|
||||||
|
{
|
||||||
var gcontext = context as GoogleOAuthCreatingTicketContext;
|
var gcontext = context as GoogleOAuthCreatingTicketContext;
|
||||||
context.Identity.AddClaim(new Claim(YavscClaimTypes.GoogleUserId, gcontext.GoogleUserId));
|
context.Identity.AddClaim(new Claim(YavscClaimTypes.GoogleUserId, gcontext.GoogleUserId));
|
||||||
var dbContext = serviceScope.ServiceProvider.GetService<ApplicationDbContext>();
|
var dbContext = serviceScope.ServiceProvider.GetService<ApplicationDbContext>();
|
||||||
|
|
||||||
var store = serviceScope.ServiceProvider.GetService<IDataStore>();
|
var store = serviceScope.ServiceProvider.GetService<IDataStore>();
|
||||||
await store.StoreAsync (gcontext.GoogleUserId, new TokenResponse {
|
await store.StoreAsync(gcontext.GoogleUserId, new TokenResponse
|
||||||
|
{
|
||||||
AccessToken = gcontext.TokenResponse.AccessToken,
|
AccessToken = gcontext.TokenResponse.AccessToken,
|
||||||
RefreshToken = gcontext.TokenResponse.RefreshToken,
|
RefreshToken = gcontext.TokenResponse.RefreshToken,
|
||||||
TokenType = gcontext.TokenResponse.TokenType,
|
TokenType = gcontext.TokenResponse.TokenType,
|
||||||
@ -184,7 +200,8 @@ namespace Yavsc {
|
|||||||
|
|
||||||
branch.UseOAuthAuthorizationServer(
|
branch.UseOAuthAuthorizationServer(
|
||||||
|
|
||||||
options => {
|
options =>
|
||||||
|
{
|
||||||
OAuthServerAppOptions = options;
|
OAuthServerAppOptions = options;
|
||||||
options.AuthorizeEndpointPath = new PathString(Constants.AuthorizePath.Substring(1));
|
options.AuthorizeEndpointPath = new PathString(Constants.AuthorizePath.Substring(1));
|
||||||
options.TokenEndpointPath = new PathString(Constants.TokenPath.Substring(1));
|
options.TokenEndpointPath = new PathString(Constants.TokenPath.Substring(1));
|
||||||
@ -193,19 +210,22 @@ namespace Yavsc {
|
|||||||
options.AuthenticationScheme = OAuthDefaults.AuthenticationType;
|
options.AuthenticationScheme = OAuthDefaults.AuthenticationType;
|
||||||
options.TokenDataProtector = ProtectionProvider.CreateProtector("Bearer protection");
|
options.TokenDataProtector = ProtectionProvider.CreateProtector("Bearer protection");
|
||||||
|
|
||||||
options.Provider = new OAuthAuthorizationServerProvider {
|
options.Provider = new OAuthAuthorizationServerProvider
|
||||||
|
{
|
||||||
OnValidateClientRedirectUri = ValidateClientRedirectUri,
|
OnValidateClientRedirectUri = ValidateClientRedirectUri,
|
||||||
OnValidateClientAuthentication = ValidateClientAuthentication,
|
OnValidateClientAuthentication = ValidateClientAuthentication,
|
||||||
OnGrantResourceOwnerCredentials = GrantResourceOwnerCredentials,
|
OnGrantResourceOwnerCredentials = GrantResourceOwnerCredentials,
|
||||||
OnGrantClientCredentials = GrantClientCredetails
|
OnGrantClientCredentials = GrantClientCredetails
|
||||||
};
|
};
|
||||||
|
|
||||||
options.AuthorizationCodeProvider = new AuthenticationTokenProvider {
|
options.AuthorizationCodeProvider = new AuthenticationTokenProvider
|
||||||
|
{
|
||||||
OnCreate = CreateAuthenticationCode,
|
OnCreate = CreateAuthenticationCode,
|
||||||
OnReceive = ReceiveAuthenticationCode,
|
OnReceive = ReceiveAuthenticationCode,
|
||||||
};
|
};
|
||||||
|
|
||||||
options.RefreshTokenProvider = new AuthenticationTokenProvider {
|
options.RefreshTokenProvider = new AuthenticationTokenProvider
|
||||||
|
{
|
||||||
OnCreate = CreateRefreshToken,
|
OnCreate = CreateRefreshToken,
|
||||||
OnReceive = ReceiveRefreshToken,
|
OnReceive = ReceiveRefreshToken,
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ using System.Security.Claims;
|
|||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNet.Identity;
|
||||||
|
using Microsoft.Data.Entity;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using OAuth.AspNet.AuthServer;
|
using OAuth.AspNet.AuthServer;
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
@ -24,6 +25,7 @@ namespace Yavsc
|
|||||||
_logger.LogError($"no app for <{clientId}>");
|
_logger.LogError($"no app for <{clientId}>");
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly ConcurrentDictionary<string, string> _authenticationCodes = new ConcurrentDictionary<string, string>(StringComparer.Ordinal);
|
private readonly ConcurrentDictionary<string, string> _authenticationCodes = new ConcurrentDictionary<string, string>(StringComparer.Ordinal);
|
||||||
|
|
||||||
private Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
|
private Task ValidateClientRedirectUri(OAuthValidateClientRedirectUriContext context)
|
||||||
@ -88,6 +90,7 @@ namespace Yavsc
|
|||||||
else _logger.LogWarning($"ValidateClientAuthentication: neither Basic nor Form credential were found");
|
else _logger.LogWarning($"ValidateClientAuthentication: neither Basic nor Form credential were found");
|
||||||
return Task.FromResult(0);
|
return Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserManager<ApplicationUser> _usermanager;
|
UserManager<ApplicationUser> _usermanager;
|
||||||
|
|
||||||
private async Task<Task> GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
|
private async Task<Task> GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
|
||||||
@ -95,7 +98,8 @@ namespace Yavsc
|
|||||||
_logger.LogWarning($"GrantResourceOwnerCredentials task ... {context.UserName}");
|
_logger.LogWarning($"GrantResourceOwnerCredentials task ... {context.UserName}");
|
||||||
|
|
||||||
ApplicationUser user = null;
|
ApplicationUser user = null;
|
||||||
user = await _usermanager.FindByNameAsync(context.UserName);
|
user = _dbContext.Users.Include(u=>u.Membership).First(u=>u.UserName == context.UserName);
|
||||||
|
|
||||||
if (await _usermanager.CheckPasswordAsync(user, context.Password))
|
if (await _usermanager.CheckPasswordAsync(user, context.Password))
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -107,14 +111,15 @@ namespace Yavsc
|
|||||||
claims.AddRange((await _usermanager.GetRolesAsync(user)).Select(
|
claims.AddRange((await _usermanager.GetRolesAsync(user)).Select(
|
||||||
r => new Claim(ClaimTypes.Role, r)
|
r => new Claim(ClaimTypes.Role, r)
|
||||||
));
|
));
|
||||||
|
claims.AddRange(user.Membership.Select(
|
||||||
|
m => new Claim(YavscClaimTypes.CircleMembership, m.CircleId.ToString())
|
||||||
|
));
|
||||||
ClaimsPrincipal principal = new ClaimsPrincipal(
|
ClaimsPrincipal principal = new ClaimsPrincipal(
|
||||||
new ClaimsIdentity(
|
new ClaimsIdentity(
|
||||||
new GenericIdentity(context.UserName, OAuthDefaults.AuthenticationType),
|
new GenericIdentity(context.UserName, OAuthDefaults.AuthenticationType),
|
||||||
claims)
|
claims)
|
||||||
);
|
);
|
||||||
// TODO set a NameIdentifier, roles and scopes claims
|
|
||||||
context.HttpContext.User = principal;
|
context.HttpContext.User = principal;
|
||||||
|
|
||||||
context.Validated(principal);
|
context.Validated(principal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +128,10 @@ namespace Yavsc
|
|||||||
|
|
||||||
private Task GrantClientCredetails(OAuthGrantClientCredentialsContext context)
|
private Task GrantClientCredetails(OAuthGrantClientCredentialsContext context)
|
||||||
{
|
{
|
||||||
ClaimsPrincipal principal = new ClaimsPrincipal(new ClaimsIdentity(new GenericIdentity(context.ClientId, OAuthDefaults.AuthenticationType), context.Scope.Select(x => new Claim("urn:oauth:scope", x))));
|
var id = new GenericIdentity(context.ClientId, OAuthDefaults.AuthenticationType);
|
||||||
|
var claims = context.Scope.Select(x => new Claim("urn:oauth:scope", x));
|
||||||
|
var cid = new ClaimsIdentity(id, claims);
|
||||||
|
ClaimsPrincipal principal = new ClaimsPrincipal(cid);
|
||||||
|
|
||||||
context.Validated(principal);
|
context.Validated(principal);
|
||||||
|
|
||||||
|
6
src/Yavsc/Views/Account/Index.cshtml
Normal file
6
src/Yavsc/Views/Account/Index.cshtml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = @SR["Index"];
|
||||||
|
}
|
||||||
|
|
||||||
|
<a asp-action="UserList" >@SR["UserList"]</a>
|
Reference in New Issue
Block a user