refact
This commit is contained in:
parent
5de53a3cba
commit
476d35ae8a
270 changed files with 477 additions and 401 deletions
20
src/isnd/Data/Account/AccountOptions.cs
Normal file
20
src/isnd/Data/Account/AccountOptions.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class AccountOptions
|
||||
{
|
||||
public static bool AllowLocalLogin = true;
|
||||
public static bool AllowRememberLogin = true;
|
||||
public static TimeSpan RememberMeLoginDuration = TimeSpan.FromDays(30);
|
||||
|
||||
public static bool ShowLogoutPrompt = true;
|
||||
public static bool AutomaticRedirectAfterSignOut = false;
|
||||
|
||||
public static string InvalidCredentialsErrorMessage = "Invalid username or password";
|
||||
}
|
||||
}
|
||||
12
src/isnd/Data/Account/ExternalProvider.cs
Normal file
12
src/isnd/Data/Account/ExternalProvider.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
|
||||
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class ExternalProvider
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string AuthenticationScheme { get; set; }
|
||||
}
|
||||
}
|
||||
19
src/isnd/Data/Account/LoggedOutViewModel.cs
Normal file
19
src/isnd/Data/Account/LoggedOutViewModel.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
|
||||
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class LoggedOutViewModel
|
||||
{
|
||||
public string PostLogoutRedirectUri { get; set; }
|
||||
public string ClientName { get; set; }
|
||||
public string SignOutIframeUrl { get; set; }
|
||||
|
||||
public bool AutomaticRedirectAfterSignOut { get; set; }
|
||||
|
||||
public string LogoutId { get; set; }
|
||||
public bool TriggerExternalSignout => ExternalAuthenticationScheme != null;
|
||||
public string ExternalAuthenticationScheme { get; set; }
|
||||
}
|
||||
}
|
||||
18
src/isnd/Data/Account/LoginInputModel.cs
Normal file
18
src/isnd/Data/Account/LoginInputModel.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
|
||||
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class LoginInputModel
|
||||
{
|
||||
[Required]
|
||||
public string Username { get; set; }
|
||||
[Required]
|
||||
public string Password { get; set; }
|
||||
public bool RememberLogin { get; set; }
|
||||
public string ReturnUrl { get; set; }
|
||||
}
|
||||
}
|
||||
22
src/isnd/Data/Account/LoginViewModel.cs
Normal file
22
src/isnd/Data/Account/LoginViewModel.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class LoginViewModel : LoginInputModel
|
||||
{
|
||||
public bool AllowRememberLogin { get; set; } = true;
|
||||
public bool EnableLocalLogin { get; set; } = true;
|
||||
|
||||
public IEnumerable<ExternalProvider> ExternalProviders { get; set; } = Enumerable.Empty<ExternalProvider>();
|
||||
public IEnumerable<ExternalProvider> VisibleExternalProviders => ExternalProviders.Where(x => !String.IsNullOrWhiteSpace(x.DisplayName));
|
||||
|
||||
public bool IsExternalLoginOnly => EnableLocalLogin == false && ExternalProviders?.Count() == 1;
|
||||
public string ExternalLoginScheme => IsExternalLoginOnly ? ExternalProviders?.SingleOrDefault()?.AuthenticationScheme : null;
|
||||
}
|
||||
}
|
||||
11
src/isnd/Data/Account/LogoutInputModel.cs
Normal file
11
src/isnd/Data/Account/LogoutInputModel.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
|
||||
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class LogoutInputModel
|
||||
{
|
||||
public string LogoutId { get; set; }
|
||||
}
|
||||
}
|
||||
11
src/isnd/Data/Account/LogoutViewModel.cs
Normal file
11
src/isnd/Data/Account/LogoutViewModel.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
|
||||
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class LogoutViewModel : LogoutInputModel
|
||||
{
|
||||
public bool ShowLogoutPrompt { get; set; } = true;
|
||||
}
|
||||
}
|
||||
12
src/isnd/Data/Account/RedirectViewModel.cs
Normal file
12
src/isnd/Data/Account/RedirectViewModel.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
|
||||
|
||||
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class RedirectViewModel
|
||||
{
|
||||
public string RedirectUrl { get; set; }
|
||||
}
|
||||
}
|
||||
32
src/isnd/Data/Account/RegisterViewModel.cs
Normal file
32
src/isnd/Data/Account/RegisterViewModel.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class RegisterViewModel
|
||||
{
|
||||
[Required]
|
||||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 2)]
|
||||
[Display(Name = "FullName")]
|
||||
public string FullName { get; set; }
|
||||
|
||||
[Required]
|
||||
[EmailAddress]
|
||||
[Display(Name = "Email")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Password")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Display(Name = "Confirm password")]
|
||||
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
}
|
||||
}
|
||||
23
src/isnd/Data/ApiKeys/ApiKey.cs
Normal file
23
src/isnd/Data/ApiKeys/ApiKey.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace isn.Data.ApiKeys
|
||||
{
|
||||
public class ApiKey
|
||||
{
|
||||
[Required][Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public string Id { get; set; }
|
||||
|
||||
[Required][ForeignKey("User")]
|
||||
public string UserId { get; set; }
|
||||
|
||||
public virtual ApplicationUser User { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public int ValidityPeriodInDays{ get; set; }
|
||||
|
||||
public DateTime CreationDate { get; set; }
|
||||
}
|
||||
}
|
||||
14
src/isnd/Data/ApiKeys/ApiKeyViewModel.cs
Normal file
14
src/isnd/Data/ApiKeys/ApiKeyViewModel.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace isn.Data.ApiKeys
|
||||
{
|
||||
public class ApiKeyViewModel
|
||||
{
|
||||
[Display(Name = "Key Name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
[Display(Name = "Key Value")]
|
||||
public string ProtectedValue { get; set; }
|
||||
}
|
||||
}
|
||||
14
src/isnd/Data/ApiKeys/CreateModel.cs
Normal file
14
src/isnd/Data/ApiKeys/CreateModel.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace isn.Data.ApiKeys
|
||||
{
|
||||
public class CreateModel
|
||||
{
|
||||
|
||||
[Required][StringLength(255)]
|
||||
[Display(Name = "Key Name")]
|
||||
public string Name { get; set; }
|
||||
public string UserId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
7
src/isnd/Data/ApiKeys/DeleteModel.cs
Normal file
7
src/isnd/Data/ApiKeys/DeleteModel.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace isn.Data.ApiKeys
|
||||
{
|
||||
public class DeleteModel
|
||||
{
|
||||
public ApiKey ApiKey { get; set; }
|
||||
}
|
||||
}
|
||||
8
src/isnd/Data/ApiKeys/DetailModel.cs
Normal file
8
src/isnd/Data/ApiKeys/DetailModel.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
namespace isn.Data.ApiKeys
|
||||
{
|
||||
public class DetailModel : ApiKeyViewModel
|
||||
{
|
||||
public ApiKey ApiKey { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
12
src/isnd/Data/ApiKeys/EditModel.cs
Normal file
12
src/isnd/Data/ApiKeys/EditModel.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
namespace isn.Data.ApiKeys
|
||||
{
|
||||
public class EditModel
|
||||
{
|
||||
public EditModel()
|
||||
{
|
||||
if (ApiKey==null) ApiKey = new ApiKey();
|
||||
}
|
||||
|
||||
public ApiKey ApiKey { get; set; }
|
||||
}
|
||||
}
|
||||
9
src/isnd/Data/ApiKeys/IndexModel.cs
Normal file
9
src/isnd/Data/ApiKeys/IndexModel.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace isn.Data.ApiKeys
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public List<ApiKey> ApiKey { get; set; }
|
||||
}
|
||||
}
|
||||
32
src/isnd/Data/ApplicationDbContext.cs
Normal file
32
src/isnd/Data/ApplicationDbContext.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using isn.Data;
|
||||
using isn.Data.ApiKeys;
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
||||
{
|
||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
modelBuilder.Entity<PackageVersion>().HasKey(v => new
|
||||
{
|
||||
v.PackageId,
|
||||
v.FullString,
|
||||
v.Type
|
||||
});
|
||||
}
|
||||
public DbSet<ApiKey> ApiKeys { get; set; }
|
||||
public DbSet<Package> Packages { get; set; }
|
||||
public DbSet<PackageVersion> PackageVersions { get; set; }
|
||||
}
|
||||
}
|
||||
10
src/isnd/Data/ApplicationUser.cs
Normal file
10
src/isnd/Data/ApplicationUser.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
// Add profile data for application users by adding properties to the ApplicationUser class
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
public string FullName { get; set; }
|
||||
}
|
||||
}
|
||||
11
src/isnd/Data/NewReleaseInfo.cs
Normal file
11
src/isnd/Data/NewReleaseInfo.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class NewReleaseInfo
|
||||
{
|
||||
public string Version { get; set; }
|
||||
public string ChangeLog { get; set; }
|
||||
public DateTime BuildDate { get; set; }
|
||||
}
|
||||
}
|
||||
27
src/isnd/Data/Package.cs
Normal file
27
src/isnd/Data/Package.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class Package
|
||||
{
|
||||
[Key][Required]
|
||||
public string Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[ForeignKey("Owner")]
|
||||
public string OwnerId { get; set; }
|
||||
|
||||
[StringLength(1024)]
|
||||
public string Description { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
virtual public ApplicationUser Owner { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
|
||||
public virtual List<PackageVersion> Versions { get; set; }
|
||||
}
|
||||
}
|
||||
34
src/isnd/Data/PackageVersion.cs
Normal file
34
src/isnd/Data/PackageVersion.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isn.Data
|
||||
{
|
||||
public class PackageVersion
|
||||
{
|
||||
[Required]
|
||||
[ForeignKey("Package")]
|
||||
public string PackageId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Major { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Minor { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Patch { get; set; }
|
||||
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
public string FullString { get; set; }
|
||||
public bool IsPrerelease { get; set; }
|
||||
|
||||
[StringLength(256)]
|
||||
public string Type { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Package Package { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
7
src/isnd/Data/Roles/Administrator.cs
Normal file
7
src/isnd/Data/Roles/Administrator.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace isn.Data.Roles
|
||||
{
|
||||
public class AdminStartupList
|
||||
{
|
||||
public string [] Users { get; set;}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue