Merge branch 'vnext' of https://github.com/pazof/yavsc.git
This commit is contained in:
commit
1f4a524293
14 changed files with 1817 additions and 11 deletions
|
|
@ -13,6 +13,7 @@ namespace Yavsc.WebApi.Controllers
|
||||||
using Models.Auth;
|
using Models.Auth;
|
||||||
using Yavsc.Helpers;
|
using Yavsc.Helpers;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
[Authorize(),Route("~/api/account"),Obsolete]
|
[Authorize(),Route("~/api/account"),Obsolete]
|
||||||
public class ApiAccountController : Controller
|
public class ApiAccountController : Controller
|
||||||
|
|
@ -141,6 +142,24 @@ namespace Yavsc.WebApi.Controllers
|
||||||
return Ok(user);
|
return Ok(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("~/api/myip"),Authorize]
|
||||||
|
public IActionResult MyIp ()
|
||||||
|
{
|
||||||
|
string ip = null;
|
||||||
|
|
||||||
|
ip = Request.Headers["X-Forwarded-For"];
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(ip)) {
|
||||||
|
ip = Request.Host.Value;
|
||||||
|
} else { // Using X-Forwarded-For last address
|
||||||
|
ip = ip.Split(',')
|
||||||
|
.Last()
|
||||||
|
.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(ip);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Actually only updates the user's name.
|
/// Actually only updates the user's name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Yavsc.Controllers
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IEnumerable<ApplicationUser> GetApplicationUser()
|
public IEnumerable<ApplicationUser> GetApplicationUser()
|
||||||
{
|
{
|
||||||
return _context.Users;
|
return _context.Users.Include(u=>u.Roles).Include(u=>u.Logins).Include(u=>u.Claims);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/ApplicationUserApi/5
|
// GET: api/ApplicationUserApi/5
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ using Yavsc.Services;
|
||||||
using Yavsc.ViewModels.Account;
|
using Yavsc.ViewModels.Account;
|
||||||
using Yavsc.Helpers;
|
using Yavsc.Helpers;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
|
using Microsoft.Data.Entity;
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -35,6 +36,8 @@ namespace Yavsc.Controllers
|
||||||
|
|
||||||
// TwilioSettings _twilioSettings;
|
// TwilioSettings _twilioSettings;
|
||||||
|
|
||||||
|
ApplicationDbContext _dbContext;
|
||||||
|
|
||||||
public AccountController(
|
public AccountController(
|
||||||
UserManager<ApplicationUser> userManager,
|
UserManager<ApplicationUser> userManager,
|
||||||
SignInManager<ApplicationUser> signInManager,
|
SignInManager<ApplicationUser> signInManager,
|
||||||
|
|
@ -42,7 +45,8 @@ namespace Yavsc.Controllers
|
||||||
IOptions<SiteSettings> siteSettings,
|
IOptions<SiteSettings> siteSettings,
|
||||||
IOptions<SmtpSettings> smtpSettings,
|
IOptions<SmtpSettings> smtpSettings,
|
||||||
ILoggerFactory loggerFactory, IOptions<TwilioSettings> twilioSettings,
|
ILoggerFactory loggerFactory, IOptions<TwilioSettings> twilioSettings,
|
||||||
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer)
|
IStringLocalizer<Yavsc.Resources.YavscLocalisation> localizer,
|
||||||
|
ApplicationDbContext dbContext)
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_signInManager = signInManager;
|
_signInManager = signInManager;
|
||||||
|
|
@ -54,7 +58,7 @@ namespace Yavsc.Controllers
|
||||||
_twilioSettings = twilioSettings.Value;
|
_twilioSettings = twilioSettings.Value;
|
||||||
_logger = loggerFactory.CreateLogger<AccountController>();
|
_logger = loggerFactory.CreateLogger<AccountController>();
|
||||||
_localizer = localizer;
|
_localizer = localizer;
|
||||||
|
_dbContext = dbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet(Constants.LoginPath)]
|
[HttpGet(Constants.LoginPath)]
|
||||||
|
|
@ -226,10 +230,18 @@ namespace Yavsc.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sign in the user with this external login provider if the user already has a login.
|
// Sign in the user with this external login provider if the user already has a login.
|
||||||
|
info.ProviderDisplayName = info.ExternalPrincipal.Claims.First(c=>c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
|
||||||
|
|
||||||
var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false);
|
var result = await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false);
|
||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
{
|
{
|
||||||
_logger.LogInformation(5, "User logged in with {Name} provider.", info.LoginProvider);
|
_logger.LogInformation(5, $"User logged in with {info.LoginProvider} provider, as {info.ProviderDisplayName} ({info.ProviderKey})." );
|
||||||
|
|
||||||
|
|
||||||
|
var ninfo = _dbContext.UserLogins.First(l=>l.ProviderKey == info.ProviderKey && l.LoginProvider == info.LoginProvider);
|
||||||
|
ninfo.ProviderDisplayName = info.ProviderDisplayName;
|
||||||
|
_dbContext.Entry(ninfo).State = EntityState.Modified;
|
||||||
|
_dbContext.SaveChanges();
|
||||||
|
|
||||||
return Redirect(returnUrl);
|
return Redirect(returnUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -253,10 +265,10 @@ namespace Yavsc.Controllers
|
||||||
var mobile = info.ExternalPrincipal.FindFirstValue(ClaimTypes.MobilePhone);
|
var mobile = info.ExternalPrincipal.FindFirstValue(ClaimTypes.MobilePhone);
|
||||||
var postalcode = info.ExternalPrincipal.FindFirstValue(ClaimTypes.PostalCode);
|
var postalcode = info.ExternalPrincipal.FindFirstValue(ClaimTypes.PostalCode);
|
||||||
var locality = info.ExternalPrincipal.FindFirstValue(ClaimTypes.Locality);
|
var locality = info.ExternalPrincipal.FindFirstValue(ClaimTypes.Locality);
|
||||||
var country = info.ExternalPrincipal.FindFirstValue(ClaimTypes.Country);*/
|
var country = info.ExternalPrincipal.FindFirstValue(ClaimTypes.Country);
|
||||||
foreach (var claim in info.ExternalPrincipal.Claims)
|
foreach (var claim in info.ExternalPrincipal.Claims)
|
||||||
_logger.LogWarning("# {0} Claim: {1} {2}", info.LoginProvider, claim.Type, claim.Value);
|
_logger.LogWarning("# {0} Claim: {1} {2}", info.LoginProvider, claim.Type, claim.Value);
|
||||||
|
*/
|
||||||
var access_token = info.ExternalPrincipal.FindFirstValue("access_token");
|
var access_token = info.ExternalPrincipal.FindFirstValue("access_token");
|
||||||
var token_type = info.ExternalPrincipal.FindFirstValue("token_type");
|
var token_type = info.ExternalPrincipal.FindFirstValue("token_type");
|
||||||
var expires_in = info.ExternalPrincipal.FindFirstValue("expires_in");
|
var expires_in = info.ExternalPrincipal.FindFirstValue("expires_in");
|
||||||
|
|
@ -292,6 +304,8 @@ namespace Yavsc.Controllers
|
||||||
var result = await _userManager.CreateAsync(user);
|
var result = await _userManager.CreateAsync(user);
|
||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
{
|
{
|
||||||
|
info.ProviderDisplayName = info.ExternalPrincipal.Claims.First(c=>c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name")?.Value;
|
||||||
|
|
||||||
result = await _userManager.AddLoginAsync(user, info);
|
result = await _userManager.AddLoginAsync(user, info);
|
||||||
if (result.Succeeded)
|
if (result.Succeeded)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,7 @@ namespace Yavsc.Migrations
|
||||||
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
|
migrationBuilder.DropForeignKey(name: "FK_PerformerProfile_ApplicationUser_PerformerId", table: "PerformerProfile");
|
||||||
migrationBuilder.DropForeignKey(name: "FK_UserActivity_Activity_DoesCode", table: "UserActivity");
|
migrationBuilder.DropForeignKey(name: "FK_UserActivity_Activity_DoesCode", table: "UserActivity");
|
||||||
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
|
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
|
||||||
|
migrationBuilder.RenameColumn(name:"Action",table:"CommandForm",newName:"ViewName");
|
||||||
migrationBuilder.AddForeignKey(
|
migrationBuilder.AddForeignKey(
|
||||||
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
|
name: "FK_IdentityRoleClaim<string>_IdentityRole_RoleId",
|
||||||
table: "AspNetRoleClaims",
|
table: "AspNetRoleClaims",
|
||||||
|
|
|
||||||
1108
Yavsc/Migrations/20170201002133_blacklisted.Designer.cs
generated
Normal file
1108
Yavsc/Migrations/20170201002133_blacklisted.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
448
Yavsc/Migrations/20170201002133_blacklisted.cs
Normal file
448
Yavsc/Migrations/20170201002133_blacklisted.cs
Normal file
|
|
@ -0,0 +1,448 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.Data.Entity.Migrations;
|
||||||
|
|
||||||
|
namespace Yavsc.Migrations
|
||||||
|
{
|
||||||
|
public partial class blacklisted : 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_BlackListed_ApplicationUser_OwnerId", table: "BlackListed");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Blog_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_Estimate_PerformerProfile_OwnerId", table: "Estimate");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BookQuery_Activity_ActivityCode", table: "BookQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BookQuery_ApplicationUser_ClientId", table: "BookQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BookQuery_PerformerProfile_PerformerId", table: "BookQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Instrumentation_Instrument_InstrumentId", table: "Instrumentation");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_PostTag_Blog_PostId", table: "PostTag");
|
||||||
|
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_UserActivity_Activity_DoesCode", table: "UserActivity");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Ban",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:Serial", true),
|
||||||
|
DateCreated = table.Column<DateTime>(nullable: false),
|
||||||
|
DateModified = table.Column<DateTime>(nullable: false),
|
||||||
|
UserCreated = table.Column<string>(nullable: true),
|
||||||
|
UserModified = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Ban", x => x.Id);
|
||||||
|
});
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "UserId",
|
||||||
|
table: "BlackListed",
|
||||||
|
nullable: false);
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "OwnerId",
|
||||||
|
table: "BlackListed",
|
||||||
|
nullable: 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_BlackListed_ApplicationUser_OwnerId",
|
||||||
|
table: "BlackListed",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleAuthorizationToBlogPost_Blog_BlogPostId",
|
||||||
|
table: "CircleAuthorizationToBlogPost",
|
||||||
|
column: "BlogPostId",
|
||||||
|
principalTable: "Blog",
|
||||||
|
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_Estimate_PerformerProfile_OwnerId",
|
||||||
|
table: "Estimate",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BookQuery_Activity_ActivityCode",
|
||||||
|
table: "BookQuery",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BookQuery_ApplicationUser_ClientId",
|
||||||
|
table: "BookQuery",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BookQuery_PerformerProfile_PerformerId",
|
||||||
|
table: "BookQuery",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
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_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_PostTag_Blog_PostId",
|
||||||
|
table: "PostTag",
|
||||||
|
column: "PostId",
|
||||||
|
principalTable: "Blog",
|
||||||
|
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_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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_BlackListed_ApplicationUser_OwnerId", table: "BlackListed");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleAuthorizationToBlogPost_Blog_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_Estimate_PerformerProfile_OwnerId", table: "Estimate");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BookQuery_Activity_ActivityCode", table: "BookQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BookQuery_ApplicationUser_ClientId", table: "BookQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_BookQuery_PerformerProfile_PerformerId", table: "BookQuery");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_Instrumentation_Instrument_InstrumentId", table: "Instrumentation");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleMember_Circle_CircleId", table: "CircleMember");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_CircleMember_ApplicationUser_MemberId", table: "CircleMember");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_PostTag_Blog_PostId", table: "PostTag");
|
||||||
|
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_UserActivity_Activity_DoesCode", table: "UserActivity");
|
||||||
|
migrationBuilder.DropForeignKey(name: "FK_UserActivity_PerformerProfile_UserId", table: "UserActivity");
|
||||||
|
migrationBuilder.DropTable("Ban");
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "UserId",
|
||||||
|
table: "BlackListed",
|
||||||
|
nullable: true);
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "OwnerId",
|
||||||
|
table: "BlackListed",
|
||||||
|
nullable: true);
|
||||||
|
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_BlackListed_ApplicationUser_OwnerId",
|
||||||
|
table: "BlackListed",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_CircleAuthorizationToBlogPost_Blog_BlogPostId",
|
||||||
|
table: "CircleAuthorizationToBlogPost",
|
||||||
|
column: "BlogPostId",
|
||||||
|
principalTable: "Blog",
|
||||||
|
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_Estimate_PerformerProfile_OwnerId",
|
||||||
|
table: "Estimate",
|
||||||
|
column: "OwnerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BookQuery_Activity_ActivityCode",
|
||||||
|
table: "BookQuery",
|
||||||
|
column: "ActivityCode",
|
||||||
|
principalTable: "Activity",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BookQuery_ApplicationUser_ClientId",
|
||||||
|
table: "BookQuery",
|
||||||
|
column: "ClientId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_BookQuery_PerformerProfile_PerformerId",
|
||||||
|
table: "BookQuery",
|
||||||
|
column: "PerformerId",
|
||||||
|
principalTable: "PerformerProfile",
|
||||||
|
principalColumn: "PerformerId",
|
||||||
|
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_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_PostTag_Blog_PostId",
|
||||||
|
table: "PostTag",
|
||||||
|
column: "PostId",
|
||||||
|
principalTable: "Blog",
|
||||||
|
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_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -95,14 +95,32 @@ namespace Yavsc.Migrations
|
||||||
b.HasAnnotation("Relational:TableName", "AspNetUserRoles");
|
b.HasAnnotation("Relational:TableName", "AspNetUserRoles");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Yavsc.Models.Access.Ban", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreated");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateModified");
|
||||||
|
|
||||||
|
b.Property<string>("UserCreated");
|
||||||
|
|
||||||
|
b.Property<string>("UserModified");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Yavsc.Models.Access.BlackListed", b =>
|
modelBuilder.Entity("Yavsc.Models.Access.BlackListed", b =>
|
||||||
{
|
{
|
||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
.ValueGeneratedOnAdd();
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
b.Property<string>("OwnerId");
|
b.Property<string>("OwnerId")
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.Property<string>("UserId");
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
});
|
});
|
||||||
|
|
@ -735,13 +753,13 @@ namespace Yavsc.Migrations
|
||||||
b.Property<long>("Id")
|
b.Property<long>("Id")
|
||||||
.ValueGeneratedOnAdd();
|
.ValueGeneratedOnAdd();
|
||||||
|
|
||||||
|
b.Property<string>("Action");
|
||||||
|
|
||||||
b.Property<string>("ActivityCode")
|
b.Property<string>("ActivityCode")
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Property<string>("Title");
|
b.Property<string>("Title");
|
||||||
|
|
||||||
b.Property<string>("ViewName");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
32
Yavsc/Models/Access/Ban.cs
Normal file
32
Yavsc/Models/Access/Ban.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Yavsc.Models.Access
|
||||||
|
{
|
||||||
|
public class Ban : IBaseTrackedEntity
|
||||||
|
{
|
||||||
|
public DateTime DateCreated
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime DateModified
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public string UserCreated
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UserModified
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Yavsc/Models/Access/BanByEmail.cs
Normal file
18
Yavsc/Models/Access/BanByEmail.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Yavsc.Models.Access
|
||||||
|
{
|
||||||
|
public class BanByEmail
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public long BanId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("BanId")]
|
||||||
|
public virtual Ban UserBan { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string email { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Yavsc.Models.Access
|
namespace Yavsc.Models.Access
|
||||||
{
|
{
|
||||||
|
|
@ -7,10 +8,14 @@ namespace Yavsc.Models.Access
|
||||||
{
|
{
|
||||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
public string UserId { get; set; }
|
public string UserId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
public string OwnerId { get; set; }
|
public string OwnerId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("OwnerId")]
|
[ForeignKey("OwnerId"),JsonIgnore]
|
||||||
public virtual ApplicationUser Owner { get; set; }
|
public virtual ApplicationUser Owner { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -258,5 +258,8 @@ namespace Yavsc.Models
|
||||||
|
|
||||||
public DbSet<Form> Form { get; set; }
|
public DbSet<Form> Form { get; set; }
|
||||||
|
|
||||||
|
public DbSet<Ban> Banlist { get ; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ namespace Yavsc.ViewComponents
|
||||||
{
|
{
|
||||||
this.dbContext = dbContext;
|
this.dbContext = dbContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<IViewComponentResult> InvokeAsync (ICircleAuthorized target)
|
public async Task<IViewComponentResult> InvokeAsync (ICircleAuthorized target)
|
||||||
{
|
{
|
||||||
var oid = target.GetOwnerId();
|
var oid = target.GetOwnerId();
|
||||||
|
|
|
||||||
126
Yavsc/contrib/kestrel-pkg/etc/init.d/kestrel
Executable file
126
Yavsc/contrib/kestrel-pkg/etc/init.d/kestrel
Executable file
|
|
@ -0,0 +1,126 @@
|
||||||
|
#!/bin/bash
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: kestrel
|
||||||
|
# Required-Start: $local_fs $network $named $time $syslog
|
||||||
|
# Required-Stop: $local_fs $network $named $time $syslog
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Description: Script to run asp.net 5 application in background
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Author: Ivan Derevianko aka druss <drussilla7@gmail.com>
|
||||||
|
# Modified by: Paul Schneider <redienhcs.luap@gmail.com>
|
||||||
|
|
||||||
|
. /lib/init/vars.sh
|
||||||
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
|
CONFIGS="/etc/kestrel/*.webenv"
|
||||||
|
DNX_USER_HOME=/srv/www/dnx
|
||||||
|
DNXRUNTIMEVERSION=$(cat /srv/www/dnx/alias/default.alias)
|
||||||
|
|
||||||
|
# fix issue with DNX exception in case of two env vars with the same name but different case
|
||||||
|
TMP_SAVE_runlevel_VAR=$runlevel
|
||||||
|
unset runlevel
|
||||||
|
|
||||||
|
running() {
|
||||||
|
if [ -f $PIDFILE ]
|
||||||
|
then
|
||||||
|
DNXPID=$(cat $PIDFILE)
|
||||||
|
if kill -0 $DNXPID 2>/dev/null
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setdnxenv() {
|
||||||
|
env=$1
|
||||||
|
. $env
|
||||||
|
# reset all except the name to default values
|
||||||
|
export ASPNET_ENV=$NAME
|
||||||
|
WWW_USER=www-data
|
||||||
|
DNXRUNTIME=${DNX_USER_HOME}/runtimes/${DNXRUNTIMEVERSION}/bin/Microsoft.Dnx.Host.Mono.dll
|
||||||
|
PROJECT=approot/Web
|
||||||
|
CONFIGURATION=Release
|
||||||
|
ROOT=/srv/www/yavsc
|
||||||
|
DESC="$NAME"
|
||||||
|
PIDFILE=/var/run/kestrel-${NAME}.pid
|
||||||
|
export MONO_OPTIONS="--server"
|
||||||
|
# reset to specified values
|
||||||
|
. $env
|
||||||
|
}
|
||||||
|
|
||||||
|
status() {
|
||||||
|
for env in $CONFIGS
|
||||||
|
do
|
||||||
|
setdnxenv "$env"
|
||||||
|
if running;
|
||||||
|
then
|
||||||
|
echo "Service running $DESC (pid: $DNXPID)"
|
||||||
|
else
|
||||||
|
echo "Service stopped ($DESC)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
start() {
|
||||||
|
for env in $CONFIGS
|
||||||
|
do
|
||||||
|
setdnxenv "$env"
|
||||||
|
if running; then
|
||||||
|
echo "Service already running $DESC" "$NAME"
|
||||||
|
log_end_msg 1
|
||||||
|
else
|
||||||
|
log_daemon_msg "Starting service $DESC"
|
||||||
|
start-stop-daemon -SbmCv -u $WWW_USER -p $PIDFILE -d $ROOT -x $DNXRUNTIME -- --project $PROJECT --configuration $CONFIGURATION $NAME >${ROOT}/kestrel-${NAME}.log
|
||||||
|
log_daemon_msg "Service $DESC started"
|
||||||
|
log_end_msg 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
for env in $CONFIGS
|
||||||
|
do
|
||||||
|
setdnxenv "$env"
|
||||||
|
if ! running
|
||||||
|
then
|
||||||
|
echo Service not running $DESC
|
||||||
|
log_end_msg 1
|
||||||
|
else
|
||||||
|
log_daemon_msg "Stopping service $DESC"
|
||||||
|
start-stop-daemon -K -p "$PIDFILE"
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
log_daemon_msg "$DESC stopped."
|
||||||
|
log_end_msg 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
status
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart}"
|
||||||
|
esac
|
||||||
|
|
||||||
|
export runlevel=$TMP_SAVE_runlevel_VAR
|
||||||
|
|
||||||
|
|
||||||
12
Yavsc/contrib/kestrel-pkg/etc/kestrel/webenv.template
Normal file
12
Yavsc/contrib/kestrel-pkg/etc/kestrel/webenv.template
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Dnx command for this web app
|
||||||
|
NAME=[myWebAppName]
|
||||||
|
|
||||||
|
# root path to the server assets
|
||||||
|
ROOT=[/srv/www/[myRootDir]]
|
||||||
|
|
||||||
|
# relative path to the project source tree,
|
||||||
|
# from the above root path
|
||||||
|
PROJECT=[approot/src/[projectName]]
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue