Two things:

* User views its devices, from a /manage index link
* Yavsc.Server resurection
This commit is contained in:
Paul Schneider 2018-05-15 12:13:38 +02:00
commit b962d58ded
201 changed files with 3756 additions and 502 deletions

View file

@ -1,20 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.Models.Account { 
public class ChangePasswordBindingModel {
[Required]
[DataType(DataType.Password)]
public string OldPassword { get; set; }
[Required]
[DataType(DataType.Password)]
public string NewPassword { get; set; }
}
public class SetPasswordBindingModel {
[Required]
[DataType(DataType.Password)]
public string NewPassword { get; set; }
}
}

View file

@ -1,17 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Account
{
public class ExternalLoginConfirmationViewModel
{
[Required]
public string Name { get; set; }
[Required]
[EmailAddress]
public string Email { get; set; }
}
}

View file

@ -1,12 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Account
{
public class ForgotPasswordViewModel
{
[Required]
[StringLength(512)]
public string LoginOrEmail { get; set; }
}
}

View file

@ -1,54 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Http.Authentication;
namespace Yavsc.ViewModels.Account
{
public class SignInViewModel
{
/// <summary>
/// Local user's name.
/// </summary>
/// <returns></returns>
[Required]
public string UserName { get; set; }
/// <summary>
/// Local user's password .
/// </summary>
/// <returns></returns>
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
/// <summary>
/// When true, asks for a two-factor identification
/// </summary>
/// <returns></returns>
[Display(Name = "Se souvenir de moi?")]
public bool RememberMe { get; set; }
/// <summary>
/// Indicates the authentication provider'name chosen to authenticate,
/// contains "LOCAL" to choose the local application identity
/// and user password credentials.
/// </summary>
/// <returns></returns>
public string Provider { get; set; }
/// <summary>
/// This value does NOT indicate the OAuth client method recieving the code,
/// but the one called once authorized.
/// </summary>
/// <returns></returns>
public string ReturnUrl { get; set; }
/// <summary>
/// Lists external identity provider descriptions.
/// </summary>
/// <returns>an enumeration of the descriptions.</returns>
public IEnumerable<AuthenticationDescription> ExternalProviders { get; set; }
}
}

View file

@ -1,39 +0,0 @@
namespace Yavsc.Models.Auth
{
public class Me : IApplicationUser {
public Me(ApplicationUser user)
{
Id = user.Id;
UserName = user.UserName;
EMail = user.Email;
Avatar = user.Avatar;
PostalAddress = user.PostalAddress;
DedicatedGoogleCalendar = user.DedicatedGoogleCalendar;
}
public string Id { get; set; }
public string UserName { get; set; }
public string EMail { get; set; }
public string[] Roles { get; set; }
/// <summary>
/// Known as profile, could point to an avatar
/// </summary>
/// <returns></returns>
public string Avatar { get; set; }
public IAccountBalance AccountBalance
{
get; set;
}
public string DedicatedGoogleCalendar
{
get; set;
}
public ILocation PostalAddress
{
get; set;
}
}
}

View file

@ -1,36 +0,0 @@
using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account
{
public class RegisterViewModel
{
// ErrorMessage = "",
[Display(ResourceType = typeof(RegisterViewModel), Name = "UserName")]
[StringLength(102)]
[YaRegularExpression(@"[a-zA-Z0-9 .'_-]+", ErrorMessageResourceName="InvalidUserName", ErrorMessageResourceType = typeof(RegisterViewModel))]
public string UserName { get; set; }
[YaRequired()]
// [EmailAddress]
[Display(Name = "Email")]
public string Email { get; set; }
[StringLength(100, MinimumLength = 6)]
[DataType(DataType.Password)]
// ErrorMessage = "Les mots de passe doivent contenir au moins un caractère spécial, qui ne soit ni une lettre ni un chiffre.")]
[Display(ResourceType = typeof(RegisterViewModel), Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(ResourceType = typeof(RegisterViewModel), Name = "PasswordConfirm")]
[Compare("Password", ErrorMessageResourceName = "PassAndConfirmDontMach", ErrorMessageResourceType = typeof(RegisterViewModel) )]
public string ConfirmPassword { get; set; }
public string GoogleRegId { get; set; }
}
}

View file

@ -1,23 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Account
{
public class ResetPasswordViewModel
{
[Required]
[EmailAddress]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "Le {0} doit être long d'au moins {2} caractères.", MinimumLength = 6)]
[DataType(DataType.Password)]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirmer le mot de passe")]
[Compare("Password", ErrorMessage = "Le mot de passe et sa confirmation ne sont pas les mêmes.")]
public string ConfirmPassword { get; set; }
public string Code { get; set; }
}
}

View file

@ -1,11 +0,0 @@
namespace Yavsc.ViewModels.Account
{
public class ShortUserInfo
{
public string Avatar { get; set; }
public string UserName { get; set; }
public string UserId { get; set; }
}
}

View file

@ -1,8 +0,0 @@
namespace Yavsc.ViewModels.Account
{
public class UnregisterViewModel
{
public string ReturnUrl { get; set; }
}
}

View file

@ -1,21 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Account
{
public class VerifyCodeViewModel
{
[Required]
public string Provider { get; set; }
[Required]
public string Code { get; set; }
public string ReturnUrl { get; set; }
[Display(Name = "Se souvenir de ce navigateur?")]
public bool RememberBrowser { get; set; }
[Display(Name = "Se souvenir de moi?")]
public bool RememberMe { get; set; }
}
}

View file

@ -1,11 +0,0 @@
namespace Yavsc.ViewModels.Administration {
public class AdminViewModel {
public RoleInfo [] Roles { get; set; }
public int AdminCount { get; set; }
public bool YouAreAdmin { get; set; }
public int UserCount { get; set; }
}
}

View file

@ -1,22 +0,0 @@
using System.Linq;
using Microsoft.AspNet.Identity.EntityFramework;
namespace Yavsc.ViewModels.Administration
{
public class RoleInfo
{
public RoleInfo ()
{
}
public RoleInfo ( IdentityRole role)
{
Name = role.Name;
Id = role.Id;
Users = role.Users.Select(u => u.UserId).ToArray();
}
public string Id { get; set; }
public string Name { get; set; }
public string[] Users { get; set; }
}
}

View file

@ -1,15 +0,0 @@
using Yavsc.Models.Auth;
namespace Yavsc.ViewModels.Administration
{
public class RoleUserCollection
{
public RoleUserCollection()
{
}
public string Id { get; set; }
public string Name { get; set; }
public UserInfo[] Users { get; set; }
}
}

View file

@ -1,10 +0,0 @@
namespace Yavsc.Models.Auth
{
public class AuthorisationView { 
public Scope[] Scopes { get; set; }
public string Message { get; set; }
}
}

View file

@ -1,10 +0,0 @@
namespace Yavsc {
public static class YavscClaimTypes {
public const string GoogleUserId = "GoogleUserId";
}
}

View file

@ -1,11 +0,0 @@
using Microsoft.AspNet.FileProviders;
namespace Yavsc.ViewModels.Auth
{
public class ViewFileContext
{
public string UserName { get; set; }
public IFileInfo File { get; set; }
public string Path { get; set; }
}
}

View file

@ -1,8 +0,0 @@
namespace Yavsc.ViewModels
{
public class BasketView
{
public long HairCutActiveQueryCount { get; set; }
}
}

View file

@ -1,31 +0,0 @@
namespace Yavsc.ViewModels.Blogspot
{
public class BlogIndexKey
{
public string AuthorId { get; set; }
public string Title { get; set; }
// override object.Equals
public override bool Equals (object obj)
{
//
// See the full list of guidelines at
// http://go.microsoft.com/fwlink/?LinkID=85237
// and also the guidance for operator== at
// http://go.microsoft.com/fwlink/?LinkId=85238
//
if (obj == null || GetType() != obj.GetType())
{
return false;
}
var blogindexkey = (BlogIndexKey)obj;
return Title == blogindexkey.Title && AuthorId == blogindexkey.AuthorId;
}
// override object.GetHashCode
public override int GetHashCode()
{
return Title.GetHashCode() * AuthorId.GetHashCode();
}
}
}

View file

@ -1,31 +0,0 @@
using System.Collections.Generic;
using Yavsc.Models.Chat;
namespace Yavsc.ViewModels.Chat { 
public class ChatUserInfo : IChatUserInfo
{
public List<ChatConnection> Connections { get; set; }
public string UserId { get; set; }
public string UserName { get; set; }
public string Avatar { get; set; }
public string[] Roles { get; set; }
}
public interface IChatUserInfo
{
List<ChatConnection> Connections { get; set; }
string UserId { get; set; }
string UserName { get; set; }
string Avatar { get; set; }
string[] Roles { get; set; }
}
}

View file

@ -1,10 +0,0 @@
namespace Yavsc.ViewModels.Controls
{
public class AjaxCheckBoxInfo
{
public string Text { get; set; }
public string Value { get; set; }
public bool Checked { get; set; }
}
}

View file

@ -1,13 +0,0 @@
namespace Yavsc.ViewModels.FrontOffice
{
public class FrontOfficeIndexViewModel
{
public int EstimateToProduceCount { get; set; }
public int EstimateToSignAsProCount { get; set; }
public int EstimateToSignAsCliCount { get; set; }
public int BillToSignAsProCount { get; set; }
public int BillToSignAsCliCount { get; set; }
public int NewPayementsCount { get; set; }
}
}

View file

@ -1,7 +0,0 @@
namespace Yavsc.ViewModels.Haircut
{
public class HaircutAdminViewModel
{
}
}

View file

@ -1,7 +0,0 @@
namespace Yavsc.ViewModels.Haircut
{
public class HaircutClientView
{
}
}

View file

@ -1,7 +0,0 @@
namespace Yavsc.ViewModels.Haircut
{
public class HaircutProviderView
{
}
}

View file

@ -1,12 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Manage
{
public class AddPhoneNumberViewModel
{
[Required]
[Phone]
[Display(Name = "Phone number")]
public string PhoneNumber { get; set; }
}
}

View file

@ -1,23 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Manage
{
public class ChangePasswordViewModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm new password")]
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
}

View file

@ -1,35 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Manage
{
public class DoDirectCreditViewModel {
[Required]
public string PaymentType  { get; set;}
[Required]
public string PayerName  { get; set;}
[Required]
public string FirstName  { get; set;}
[Required]
public string LastName  { get; set;}
[Required]
public string CreditCardNumber  { get; set;}
public string CreditCardType  { get; set;}
public string Cvv2Number  { get; set;}
public string CardExpiryDate  { get; set;}
public string IpnNotificationUrl { get; set; }
[Required]
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
[Required]
public string PostalCode { get; set; }
public string Phone { get; set; }
[Required]
public string CurrencyCode { get; set; }
[Required]
public string Amount { get; set; }
}
}

View file

@ -1,7 +0,0 @@
namespace Yavsc.ViewModels.Manage
{
public class FactorViewModel
{
public string Purpose { get; set; }
}
}

View file

@ -1,55 +0,0 @@
using System.Collections.Generic;
using Microsoft.AspNet.Identity;
namespace Yavsc.ViewModels.Manage
{
using Models.Bank;
using Models;
using Models.Workflow;
public class IndexViewModel
{
public string UserName {get; set; }
public string Avatar { get; set; }
public bool HasPassword { get; set; }
public IList<UserLoginInfo> Logins { get; set; }
public string PhoneNumber { get; set; }
public bool TwoFactor { get; set; }
public bool BrowserRemembered { get; set; }
public List<UserActivity> Activity { get; set; }
public bool HaveProfessionalSettings { get; set; }
public bool HaveActivityToConfigure { get; set; }
public long PostsCounter { get; set; }
public AccountBalance Balance { get; set; }
public long ActiveCommandCount { get; set; }
public bool HasDedicatedCalendar { get; set; }
public IEnumerable<string> Roles { get; set; }
public string FullName { get; set; }
public string PostalAddress { get; set; }
public BankIdentity BankInfo { get; set; }
public long DiskQuota { get; set; }
public long DiskUsage { get; set; }
public string DedicatedCalendarId { get; set; }
public string EMail { get; set; }
public bool EmailConfirmed { get; set; }
public bool AllowMonthlyEmail { get; set; }
}
}

View file

@ -1,13 +0,0 @@
using System.Collections.Generic;
using Microsoft.AspNet.Http.Authentication;
using Microsoft.AspNet.Identity;
namespace Yavsc.ViewModels.Manage
{
public class ManageLoginsViewModel
{
public IList<UserLoginInfo> CurrentLogins { get; set; }
public IList<AuthenticationDescription> OtherLogins { get; set; }
}
}

View file

@ -1,18 +0,0 @@
using Yavsc.Models;
namespace Yavsc.ViewModels.Manage
{
public class ProfileEMailUsageViewModel
{
public bool Allow { get; set; }
public ProfileEMailUsageViewModel()
{
}
public ProfileEMailUsageViewModel(ApplicationUser user=null)
{
Allow = user.AllowMonthlyEmail;
}
}
}

View file

@ -1,8 +0,0 @@
namespace Yavsc.ViewModels.Manage
{
public class RemoveLoginViewModel
{
public string LoginProvider { get; set; }
public string ProviderKey { get; set; }
}
}

View file

@ -1,9 +0,0 @@
using Yavsc.Models.Workflow;
namespace Yavsc.ViewModels.Manage
{
public class SetActivityViewModel : PerformerProfile
{
}
}

View file

@ -1,16 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Manage
{
public class SetAddressViewModel
{
[Required]
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
[Required]
public string PostalCode { get; set; }
}
}

View file

@ -1,18 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Manage
{
public class SetPasswordViewModel
{
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm new password")]
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
}

View file

@ -1,15 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Yavsc.ViewModels.Manage
{
public class VerifyPhoneNumberViewModel
{
[Required]
public string Code { get; set; }
[Required]
[Phone]
[Display(Name = "Phone number")]
public string PhoneNumber { get; set; }
}
}

View file

@ -1,9 +0,0 @@
namespace Yavsc.ViewModels
{
public enum OutputFormat {
Html,
LaTeX,
Pdf
}
}

View file

@ -1,14 +0,0 @@
using PayPal.PayPalAPIInterfaceService.Model;
using Yavsc.Models.Payment;
namespace Yavsc.ViewModels.PayPal
{
public class PaymentInfo
{
public PayPalPayment DbContent { get; set; }
public virtual GetExpressCheckoutDetailsResponseType DetailsFromPayPal { get; set; }
}
}

View file

@ -1,13 +0,0 @@
namespace Yavsc.ViewModels.Relationship
{
public class CirclesViewModel
{
public CirclesViewModel(ICircleAuthorized resource)
{
Target = resource;
TargetTypeName = resource.GetType().Name;
}
public ICircleAuthorized Target { get; set; }
public string TargetTypeName { get; set; }
}
}

View file

@ -0,0 +1,154 @@
using System.Threading.Tasks;
using MailKit.Net.Smtp;
using MimeKit;
using MailKit.Security;
using System;
using Yavsc.Models.Messaging;
using Microsoft.AspNet.Identity;
using Yavsc.Models;
using Yavsc.Models.Google.Messaging;
using System.Collections.Generic;
using Yavsc.Models.Haircut;
using Yavsc.Interfaces.Workflow;
using System.Linq;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Yavsc.Server.Helpers;
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
public class MessageSender : IEmailSender, IGoogleCloudMessageSender
{
private ILogger _logger;
SiteSettings siteSettings;
SmtpSettings smtpSettings;
GoogleAuthSettings googleSettings;
public MessageSender(
ILoggerFactory loggerFactory,
IOptions<SiteSettings> sitesOptions,
IOptions<SmtpSettings> smtpOptions,
IOptions<GoogleAuthSettings> googleOptions
)
{
_logger = loggerFactory.CreateLogger<MessageSender>();
siteSettings = sitesOptions.Value;
smtpSettings = smtpOptions.Value;
googleSettings = googleOptions.Value;
}
public async Task <MessageWithPayloadResponse> NotifyEvent<Event>
( IEnumerable<string> regids, Event ev)
where Event : IEvent
{
if (ev == null)
throw new Exception("Spécifier un évènement");
if (ev.Sender == null)
throw new Exception("Spécifier un expéditeur");
if (regids == null )
throw new NotImplementedException("Notify & No GCM reg ids");
var raa = regids.ToArray();
if (raa.Length<1)
throw new NotImplementedException("No GCM reg ids");
var msg = new MessageWithPayload<Event>()
{
data = ev,
registration_ids = regids.ToArray()
};
_logger.LogInformation("Sendding to Google : "+JsonConvert.SerializeObject(msg));
try {
using (var m = new SimpleJsonPostMethod("https://gcm-http.googleapis.com/gcm/send",$"key={googleSettings.ApiKey}")) {
return await m.Invoke<MessageWithPayloadResponse>(msg);
}
}
catch (Exception ex) {
throw new Exception ("Quelque chose s'est mal passé à l'envoi",ex);
}
}
/// <summary>
///
/// </summary>
/// <param name="googleSettings"></param>
/// <param name="registrationId"></param>
/// <param name="ev"></param>
/// <returns>a MessageWithPayloadResponse,
/// <c>bool somethingsent = (response.failure == 0 &amp;&amp; response.success > 0)</c>
/// </returns>
public async Task<MessageWithPayloadResponse> NotifyBookQueryAsync( IEnumerable<string> registrationIds, RdvQueryEvent ev)
{
return await NotifyEvent<RdvQueryEvent>(registrationIds, ev);
}
public async Task<MessageWithPayloadResponse> NotifyEstimateAsync(IEnumerable<string> registrationIds, EstimationEvent ev)
{
return await NotifyEvent<EstimationEvent>(registrationIds, ev);
}
public async Task<MessageWithPayloadResponse> NotifyHairCutQueryAsync(
IEnumerable<string> registrationIds, HairCutQueryEvent ev)
{
return await NotifyEvent<HairCutQueryEvent>(registrationIds, ev);
}
public Task<bool> SendEmailAsync(string username, string email, string subject, string message)
{
try
{
MimeMessage msg = new MimeMessage();
msg.From.Add(new MailboxAddress(
siteSettings.Owner.Name,
siteSettings.Owner.EMail));
msg.To.Add(new MailboxAddress(username, email));
msg.Body = new TextPart("plain")
{
Text = message
};
msg.Subject = subject;
using (SmtpClient sc = new SmtpClient())
{
sc.Connect(
smtpSettings.Host,
smtpSettings.Port,
SecureSocketOptions.None);
sc.Send(msg);
}
}
catch (Exception)
{
return Task.FromResult(false);
}
return Task.FromResult(true);
}
public Task<bool> ValidateAsync(string purpose, string token, UserManager<ApplicationUser> manager, ApplicationUser user)
{
throw new NotImplementedException();
}
public Task<MessageWithPayloadResponse> NotifyAsync(
IEnumerable<string> regids, IEvent yaev)
{
throw new NotImplementedException();
}
/* SMS with Twilio:
public Task SendSmsAsync(TwilioSettings twilioSettigns, string number, string message)
{
var Twilio = new TwilioRestClient(twilioSettigns.AccountSID, twilioSettigns.Token);
var result = Twilio.SendMessage( twilioSettigns.SMSAccountFrom, number, message);
// Status is one of Queued, Sending, Sent, Failed or null if the number is not valid
Trace.TraceInformation(result.Status);
// Twilio doesn't currently have an async API, so return success.
return Task.FromResult(result.Status != "Failed");
} */
}
}

View file

@ -0,0 +1,22 @@
using System.Net.Http;
using System.Threading.Tasks;
using Yavsc.Helpers;
namespace Yavsc.Services
{
using Models.societe.com;
public class SIRENChecker
{
private CompanyInfoSettings _settings;
public SIRENChecker(CompanyInfoSettings settings)
{
_settings = settings;
}
public async Task<CompanyInfoMessage> CheckAsync(string siren) {
using (var web = new HttpClient())
{
return await web.CheckSiren(siren, _settings);
}
}
}
}

View file

@ -1,9 +0,0 @@
using System;
namespace Yavsc.ViewModels.Test
{
public class CalendarViewModel
{
public DateTime EventDate { get; set;}
}
}

View file

@ -1,11 +0,0 @@
using Yavsc.Models.Billing;
namespace Yavsc.ViewModels.Workflow
{
public class EstimateEdition
{
public Estimate Data { get; set; }
}
}

View file

@ -1,11 +0,0 @@
using Yavsc.Models.Workflow;
namespace Yavsc.ViewModels.Workflow
{
public class UserActivityViewModel
{
public UserActivity Declaration { get; set; }
public bool NeedsSettings { get; set; }
public ISpecializationSettings Settings { get; set; }
}
}