diff --git a/Yavsc.Server/Helpers/ApplicationUser.cs b/Yavsc.Server/Helpers/ApplicationUser.cs new file mode 100644 index 00000000..81d17d61 --- /dev/null +++ b/Yavsc.Server/Helpers/ApplicationUser.cs @@ -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 + { + /// + /// Another me, as a byte array. + /// This value points a picture that may be used + /// to present the user + /// + /// the path to an user's image, relative to it's user dir + /// Startup.UserFilesOptions + /// + /// + [MaxLength(512)] + public string Avatar { get; set; } + + [MaxLength(512)] + public string FullName { get; set; } + + + /// + /// WIP Paypal + /// + /// + [Display(Name="Account balance")] + public virtual AccountBalance AccountBalance { get; set; } + + /// + /// User's posts + /// + /// + [InverseProperty("Author"),JsonIgnore] + public virtual List Posts { get; set; } + + /// + /// User's contact list + /// + /// + [InverseProperty("Owner"),JsonIgnore] + public virtual List Book { get; set; } + + /// + /// External devices using the API + /// + /// + [InverseProperty("DeviceOwner"),JsonIgnore] + public virtual List Devices { get; set; } + + [InverseProperty("Owner"),JsonIgnore] + public virtual List Connections { get; set; } + + + /// + /// User's circles + /// + /// + [InverseProperty("Owner"),JsonIgnore] + + public virtual List Circles { get; set; } + + /// + /// Billing postal address + /// + /// + [ForeignKeyAttribute("PostalAddressId")] + public virtual Location PostalAddress { get; set; } + public long? PostalAddressId { get; set; } + + /// + /// User's Google calendar + /// + /// + [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 BlackList { get; set; } + + public bool AllowMonthlyEmail { get; set; } = false; + } +} diff --git a/Yavsc/Services/MessageServices.cs b/Yavsc/Services/MessageServices.cs new file mode 100755 index 00000000..67b99c3b --- /dev/null +++ b/Yavsc/Services/MessageServices.cs @@ -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 + +} diff --git a/test/Startup.cs b/test/Startup.cs new file mode 100644 index 00000000..82a5cf2d --- /dev/null +++ b/test/Startup.cs @@ -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(siteSettingsconf); + var smtpSettingsconf = Configuration.GetSection("Smtp"); + services.Configure(smtpSettingsconf); + services.AddInstance(typeof(ILoggerFactory), new LoggerFactory()); + services.AddTransient(typeof(IEmailSender), typeof(MailSender)); + services.AddEntityFramework().AddNpgsql().AddDbContext(); + services.AddTransient((s) => new RazorTemplateEngine(s.GetService())); + services.AddLogging(); + services.AddTransient(); + services.AddLocalization(options => + { + options.ResourcesPath = "Resources"; + }); + + services.AddEntityFramework() + .AddNpgsql() + .AddDbContext( + db => db.UseNpgsql(ConnectionString) + ); + services.Configure(options => + { + options.SignInScheme = "Bearer"; + }); + + services.AddTransient(); + + services.AddAuthentication(); + + } + + public void Configure (IApplicationBuilder app, IHostingEnvironment env, + IOptions siteSettings, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(Configuration.GetSection("Logging")); + loggerFactory.AddDebug(); + logger = loggerFactory.CreateLogger(); + logger.LogInformation(env.EnvironmentName); + var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc"); + var clientId = authConf.GetSection("ClientId").Value; + var clientSecret = authConf.GetSection("ClientSecret").Value; + + } + + } +}