Merge branch 'vnext' of github.com:pazof/yavsc into vnext
This commit is contained in:
105
Yavsc.Server/Helpers/ApplicationUser.cs
Normal file
105
Yavsc.Server/Helpers/ApplicationUser.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNet.Identity.EntityFramework;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Yavsc.Models
|
||||||
|
{
|
||||||
|
using Models.Relationship;
|
||||||
|
using Models.Identity;
|
||||||
|
using Models.Chat;
|
||||||
|
using Models.Bank;
|
||||||
|
using Models.Access;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
public class ApplicationUser : IdentityUser
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Another me, as a byte array.
|
||||||
|
/// This value points a picture that may be used
|
||||||
|
/// to present the user
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>the path to an user's image, relative to it's user dir<summary>
|
||||||
|
/// <see>Startup.UserFilesOptions</see>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[MaxLength(512)]
|
||||||
|
public string Avatar { get; set; }
|
||||||
|
|
||||||
|
[MaxLength(512)]
|
||||||
|
public string FullName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WIP Paypal
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Display(Name="Account balance")]
|
||||||
|
public virtual AccountBalance AccountBalance { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User's posts
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[InverseProperty("Author"),JsonIgnore]
|
||||||
|
public virtual List<Blog.BlogPost> Posts { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User's contact list
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[InverseProperty("Owner"),JsonIgnore]
|
||||||
|
public virtual List<Contact> Book { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// External devices using the API
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[InverseProperty("DeviceOwner"),JsonIgnore]
|
||||||
|
public virtual List<GoogleCloudMobileDeclaration> Devices { get; set; }
|
||||||
|
|
||||||
|
[InverseProperty("Owner"),JsonIgnore]
|
||||||
|
public virtual List<ChatConnection> Connections { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User's circles
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[InverseProperty("Owner"),JsonIgnore]
|
||||||
|
|
||||||
|
public virtual List<Circle> Circles { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Billing postal address
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[ForeignKeyAttribute("PostalAddressId")]
|
||||||
|
public virtual Location PostalAddress { get; set; }
|
||||||
|
public long? PostalAddressId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User's Google calendar
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[MaxLength(512)]
|
||||||
|
public string DedicatedGoogleCalendar { get; set; }
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return this.Id+" "+this.AccountBalance?.Credits.ToString()+this.Email+" "+this.UserName+" $"+this.AccountBalance?.Credits.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BankIdentity BankInfo { get; set; }
|
||||||
|
|
||||||
|
public long DiskQuota { get; set; } = 512*1024*1024;
|
||||||
|
public long DiskUsage { get; set; } = 0;
|
||||||
|
|
||||||
|
public long MaxFileSize { get; set; } = 512*1024*1024;
|
||||||
|
|
||||||
|
[JsonIgnore][InverseProperty("Owner")]
|
||||||
|
public virtual List<BlackListed> BlackList { get; set; }
|
||||||
|
|
||||||
|
public bool AllowMonthlyEmail { get; set; } = false;
|
||||||
|
}
|
||||||
|
}
|
27
Yavsc/Services/MessageServices.cs
Executable file
27
Yavsc/Services/MessageServices.cs
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MailKit.Net.Smtp;
|
||||||
|
using MimeKit;
|
||||||
|
using MailKit.Security;
|
||||||
|
using System;
|
||||||
|
using Yavsc.Models.Messaging;
|
||||||
|
using Yavsc.Models;
|
||||||
|
using Yavsc.Models.Google.Messaging;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Yavsc.Models.Haircut;
|
||||||
|
using Yavsc.Interfaces.Workflow;
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Yavsc.Server.Helpers;
|
||||||
|
using Yavsc.Abstract.Manage;
|
||||||
|
using Microsoft.AspNet.Identity;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.OptionsModel;
|
||||||
|
|
||||||
|
namespace Yavsc.Services
|
||||||
|
{
|
||||||
|
// This class is used by the application to send Email and SMS
|
||||||
|
// when you turn on two-factor authentication in ASP.NET Identity.
|
||||||
|
// For more details see this link http://go.microsoft.com/fwlink/?LinkID=532713
|
||||||
|
|
||||||
|
}
|
100
test/Startup.cs
Normal file
100
test/Startup.cs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.OptionsModel;
|
||||||
|
using Microsoft.AspNet.Builder;
|
||||||
|
using Microsoft.AspNet.Hosting;
|
||||||
|
using Microsoft.AspNet.Razor;
|
||||||
|
using Microsoft.Extensions.PlatformAbstractions;
|
||||||
|
using Yavsc;
|
||||||
|
using Yavsc.Models;
|
||||||
|
using Yavsc.Services;
|
||||||
|
using Microsoft.Data.Entity;
|
||||||
|
using Microsoft.AspNet.Authentication;
|
||||||
|
using Microsoft.Extensions.WebEncoders;
|
||||||
|
using Yavsc.Lib;
|
||||||
|
|
||||||
|
namespace test
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
public string ConnectionString
|
||||||
|
{
|
||||||
|
get ; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SiteSettings SiteSetup { get; private set; }
|
||||||
|
public static SmtpSettings SmtpSettup { get; private set; }
|
||||||
|
public static IConfiguration Configuration { get; set; }
|
||||||
|
|
||||||
|
public static string HostingFullName { get; private set; }
|
||||||
|
|
||||||
|
ILogger logger;
|
||||||
|
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
||||||
|
{
|
||||||
|
var devtag = env.IsDevelopment()?"D":"";
|
||||||
|
var prodtag = env.IsProduction()?"P":"";
|
||||||
|
var stagetag = env.IsStaging()?"S":"";
|
||||||
|
|
||||||
|
HostingFullName = $"{appEnv.RuntimeFramework.FullName} [{env.EnvironmentName}:{prodtag}{devtag}{stagetag}]";
|
||||||
|
// Set up configuration sources.
|
||||||
|
|
||||||
|
var builder = new ConfigurationBuilder()
|
||||||
|
.AddEnvironmentVariables()
|
||||||
|
.AddJsonFile("appsettings.json")
|
||||||
|
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
|
||||||
|
Configuration = builder.Build();
|
||||||
|
ConnectionString = Configuration["Data:DefaultConnection:ConnectionString"];
|
||||||
|
AppDomain.CurrentDomain.SetData("YAVSC_CONNECTION", ConnectionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConfigureServices (IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddOptions();
|
||||||
|
var siteSettingsconf = Configuration.GetSection("Site");
|
||||||
|
services.Configure<SiteSettings>(siteSettingsconf);
|
||||||
|
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
||||||
|
services.Configure<SmtpSettings>(smtpSettingsconf);
|
||||||
|
services.AddInstance(typeof(ILoggerFactory), new LoggerFactory());
|
||||||
|
services.AddTransient(typeof(IEmailSender), typeof(MailSender));
|
||||||
|
services.AddEntityFramework().AddNpgsql().AddDbContext<ApplicationDbContext>();
|
||||||
|
services.AddTransient((s) => new RazorTemplateEngine(s.GetService<RazorEngineHost>()));
|
||||||
|
services.AddLogging();
|
||||||
|
services.AddTransient<EMailer>();
|
||||||
|
services.AddLocalization(options =>
|
||||||
|
{
|
||||||
|
options.ResourcesPath = "Resources";
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddEntityFramework()
|
||||||
|
.AddNpgsql()
|
||||||
|
.AddDbContext<ApplicationDbContext>(
|
||||||
|
db => db.UseNpgsql(ConnectionString)
|
||||||
|
);
|
||||||
|
services.Configure<SharedAuthenticationOptions>(options =>
|
||||||
|
{
|
||||||
|
options.SignInScheme = "Bearer";
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddTransient<Microsoft.Extensions.WebEncoders.UrlEncoder, UrlEncoder>();
|
||||||
|
|
||||||
|
services.AddAuthentication();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Configure (IApplicationBuilder app, IHostingEnvironment env,
|
||||||
|
IOptions<SiteSettings> siteSettings, ILoggerFactory loggerFactory)
|
||||||
|
{
|
||||||
|
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||||
|
loggerFactory.AddDebug();
|
||||||
|
logger = loggerFactory.CreateLogger<Startup>();
|
||||||
|
logger.LogInformation(env.EnvironmentName);
|
||||||
|
var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc");
|
||||||
|
var clientId = authConf.GetSection("ClientId").Value;
|
||||||
|
var clientSecret = authConf.GetSection("ClientSecret").Value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user