[REORG]
This commit is contained in:
34
src/Yavsc.Abstract/Authentication/RegisterViewModel.cs
Normal file
34
src/Yavsc.Abstract/Authentication/RegisterViewModel.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Yavsc.Attributes.Validation;
|
||||
using Yavsc.Abstract;
|
||||
using Yavsc;
|
||||
|
||||
namespace Yavsc.ViewModels.Account
|
||||
{
|
||||
public class RegisterModel
|
||||
{
|
||||
|
||||
[YaStringLength(2,Constants.MaxUserNameLength)]
|
||||
[YaRegularExpression(Constants.UserNameRegExp)]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[YaRequired()]
|
||||
[YaStringLength(2,102)]
|
||||
// [EmailAddress]
|
||||
[Display(Name = "Email")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[YaStringLength(6,100)]
|
||||
[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.")]
|
||||
|
||||
public string Password { get; set; }
|
||||
|
||||
[DataType(DataType.Password)]
|
||||
[Compare("Password")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
15
src/Yavsc.Abstract/Authentication/Scope.cs
Normal file
15
src/Yavsc.Abstract/Authentication/Scope.cs
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Yavsc.Models.Auth {
|
||||
public class Scope {
|
||||
|
||||
|
||||
[Key]
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
}
|
||||
}
|
90
src/Yavsc.Abstract/Chat/HubInputValidator.cs
Normal file
90
src/Yavsc.Abstract/Chat/HubInputValidator.cs
Normal file
@ -0,0 +1,90 @@
|
||||
//
|
||||
// ChatHub.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// Copyright (c) 2016-2019 GNU GPL
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Yavsc;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
public class HubInputValidator {
|
||||
|
||||
public Action<string,string,string> NotifyUser {get;set;}
|
||||
public bool ValidateRoomName (string roomName)
|
||||
{
|
||||
bool valid = ValidateStringLength(roomName,1,25);
|
||||
if (valid) valid = IsLetterOrDigit(roomName);
|
||||
if (!valid) NotifyUser(NotificationTypes.Error, "roomName", ChatHub.InvalidRoomName);
|
||||
return valid;
|
||||
}
|
||||
public bool ValidateUserName (string userName)
|
||||
{
|
||||
bool valid = true;
|
||||
|
||||
if (userName.Length<1 || userName[0] == '?' && userName.Length<2) valid = false;
|
||||
if (valid) {
|
||||
string suname = (userName[0] == '?') ? userName.Substring(1) : userName;
|
||||
if (valid) valid = ValidateStringLength(suname, 1,12);
|
||||
if (valid) valid = IsLetterOrDigit(userName);
|
||||
}
|
||||
if (!valid) NotifyUser(NotificationTypes.Error, "userName" , ChatHub.InvalidUserName);
|
||||
return valid;
|
||||
}
|
||||
public bool ValidateMessage (string message)
|
||||
{
|
||||
if (!ValidateStringLength(message, 1, 10240))
|
||||
{
|
||||
NotifyUser(NotificationTypes.Error, "message", ChatHub.InvalidMessage);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool ValidateReason (string reason)
|
||||
{
|
||||
if (!ValidateStringLength(reason, 1,240))
|
||||
{
|
||||
NotifyUser(NotificationTypes.Error, "reason", ChatHub.InvalidReason);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static bool ValidateStringLength(string str, int minLen, int maxLen)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
{
|
||||
if (minLen<=0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (str.Length>maxLen||str.Length<minLen) return false;
|
||||
return true;
|
||||
}
|
||||
static bool IsLetterOrDigit(string s)
|
||||
{
|
||||
foreach (var c in s)
|
||||
if (!char.IsLetterOrDigit(c))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
65
src/Yavsc.Abstract/Constants.cs
Normal file
65
src/Yavsc.Abstract/Constants.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using Yavsc.Models.Auth;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly Scope[] SiteScopes = {
|
||||
new Scope { Id = "profile", Description = "Your profile informations" },
|
||||
new Scope { Id = "book" , Description ="Your booking interface"},
|
||||
new Scope { Id = "blog" , Description ="Your blogging interface"},
|
||||
new Scope { Id = "estimate" , Description ="Your estimation interface"},
|
||||
new Scope { Id = "contract" , Description ="Your contract signature access"},
|
||||
new Scope { Id = "admin" , Description ="Your administration rights on this site"},
|
||||
new Scope { Id = "moderation" , Description ="Your moderator interface"},
|
||||
new Scope { Id = "frontoffice" , Description ="Your front office interface" }
|
||||
};
|
||||
|
||||
public const string CompanyClaimType = "https://schemas.pschneider.fr/identity/claims/Company";
|
||||
public const string UserNameRegExp = @"^[a-zA-Z][a-zA-Z0-9._-]*$";
|
||||
public const string UserFileNamePatternRegExp = @"^([a-zA-Z0-9._-]*/)*[a-zA-Z0-9._-]+$";
|
||||
public const string AuthorizePath = "/authorize";
|
||||
public const string TokenPath = "/token";
|
||||
public const string LoginPath = "/signin";
|
||||
public const string LogoutPath = "/signout";
|
||||
|
||||
public const string UserInfoPath = "/api/me";
|
||||
|
||||
public const string SignalRPath = "/api/signalr";
|
||||
public const string LiveUserPath = "live";
|
||||
|
||||
public const string ApplicationAuthenticationSheme = "ServerCookie";
|
||||
public const string ExternalAuthenticationSheme = "ExternalCookie";
|
||||
public const string DefaultFactor = "Default";
|
||||
public const string MobileAppFactor = "Mobile Application";
|
||||
public const string EMailFactor = "Email";
|
||||
public const string SMSFactor = "SMS";
|
||||
public const string AdminGroupName = "Administrator";
|
||||
public const string PerformerGroupName = "Performer";
|
||||
public const string StarGroupName = "Star";
|
||||
public const string StarHunterGroupName = "StarHunter";
|
||||
public const string BlogModeratorGroupName = "Moderator";
|
||||
public const string FrontOfficeGroupName = "FrontOffice";
|
||||
public const string UserFilesPath = "/files";
|
||||
public const string AvatarsPath = "/avatars";
|
||||
public const string GitPath = "/sources";
|
||||
public const string DefaultAvatar = "/images/Users/icon_user.png";
|
||||
public const string AnonAvatar = "/images/Users/icon_anon_user.png";
|
||||
public const string YavscConnectionStringEnvName = "YAVSC_DB_CONNECTION";
|
||||
|
||||
// at the end, let 4*4 bytes in peace
|
||||
public const int WebSocketsMaxBufLen = 4 * 1020;
|
||||
|
||||
public static readonly long DefaultFSQ = 1024 * 1024 * 500;
|
||||
|
||||
|
||||
public const string SshHeaderKey = "SSH";
|
||||
|
||||
public static readonly string NoneCode = "none";
|
||||
|
||||
public const int MaxUserNameLength = 26;
|
||||
|
||||
public const string LivePath = "/live/cast";
|
||||
}
|
||||
}
|
@ -2,7 +2,8 @@ SOURCE_DIR=$(HOME)/workspace/yavsc
|
||||
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/build/make
|
||||
BASERESX=Resources/Yavsc.Attributes.Validation.Resources.resx \
|
||||
Resources/Yavsc.Models.Messaging.Resources.resx \
|
||||
Resources/Yavsc.Models.IT.Fixing.Bug.resx
|
||||
Resources/Yavsc.Models.IT.Fixing.Bug.resx\
|
||||
Resources/Yavsc.ChatHub.resx
|
||||
BASERESXGEN=$(BASERESX:.resx=.Designer.cs)
|
||||
include $(MAKEFILE_DIR)/versioning.mk
|
||||
include $(MAKEFILE_DIR)/dnx.mk
|
||||
|
82
src/Yavsc.Abstract/Resources/Yavsc.ChatHub.Designer.cs
generated
Normal file
82
src/Yavsc.Abstract/Resources/Yavsc.ChatHub.Designer.cs
generated
Normal file
@ -0,0 +1,82 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
namespace Yavsc {
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public partial class ChatHub {
|
||||
|
||||
private static System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.Equals(null, resourceMan)) {
|
||||
System.Resources.ResourceManager temp = new System.Resources.ResourceManager(("Yavsc.Abstract.Resources." + "Yavsc.ChatHub"), typeof(ChatHub).GetTypeInfo().Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Authenticated_chat_user {
|
||||
get {
|
||||
return ResourceManager.GetString("Authenticated chat user", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string LabnoJoinNoSend {
|
||||
get {
|
||||
return ResourceManager.GetString("LabnoJoinNoSend", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string InvalidRoomName {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidRoomName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string InvalidUserName {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidUserName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string InvalidMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
public static string InvalidReason {
|
||||
get {
|
||||
return ResourceManager.GetString("InvalidReason", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
69
src/Yavsc.Abstract/Resources/Yavsc.ChatHub.en.resx
Normal file
69
src/Yavsc.Abstract/Resources/Yavsc.ChatHub.en.resx
Normal file
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<!--
|
||||
route name for the api controller used to tag the 'BlogPost' entity
|
||||
-->
|
||||
<data name="Authenticated chat user"><value>Authenticated chat user</value></data>
|
||||
<data name="LabnoJoinNoSend"><value>could not send to channel (not joint)</value></data>
|
||||
<data name="InvalidRoomName"><value>Invalid room name</value></data>
|
||||
<data name="InvalidUserName"><value>Invalid user name</value></data>
|
||||
<data name="InvalidReason"><value>invalid Reason</value></data>
|
||||
</root>
|
71
src/Yavsc.Abstract/Resources/Yavsc.ChatHub.resx
Normal file
71
src/Yavsc.Abstract/Resources/Yavsc.ChatHub.resx
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<!--
|
||||
route name for the api controller used to tag the 'BlogPost' entity
|
||||
-->
|
||||
<data name="Authenticated chat user"><value>Utilisateur de chat authentifié</value></data>
|
||||
<data name="LabnoJoinNoSend"><value>Envoi impossible: vous devez joindre le canal pour y contribuer.</value></data>
|
||||
<data name="InvalidRoomName"><value>Nom de salon invalide</value></data>
|
||||
<data name="InvalidUserName"><value>Nom d'utilisateur invalide</value></data>
|
||||
<data name="InvalidMessage"><value>Message invalide</value></data>
|
||||
<data name="InvalidReason"><value>Raison invalide</value></data>
|
||||
|
||||
</root>
|
Reference in New Issue
Block a user