1 Commits

Author SHA1 Message Date
8ce99cba13 encryption failed à la restauration depuis Nuget.org ++ 2020-09-11 03:31:45 +01:00
175 changed files with 990 additions and 1547 deletions

View File

@ -35,10 +35,3 @@ indent_style = space
indent_size = 2
dotnet_naming_rule.locals_should_be_camel_case.severity = none
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
dotnet_naming_style.camel_case_style.capitalization = camel_case

View File

@ -6,11 +6,11 @@ sudo: false
install:
- curl --insecure -sSL https://lua.pschneider.fr/files/Paul/pub/dnx-install.sh | bash
- DNX_USER_HOME=`pwd -P`/dnx . ./dnx/dnvm/dnvm.sh
- cd src/OAuth.AspNet.Token && dnu restore --ignore-failed-sources
- cd ../OAuth.AspNet.AuthServer && dnu restore --ignore-failed-sources
- cd ../Yavsc.Abstract && dnu restore --ignore-failed-sources
- cd ../Yavsc.Server && dnu restore --ignore-failed-sources
- cd ../Yavsc && dnu restore --ignore-failed-sources
- cd src/OAuth.AspNet.Token && dnu restore
- cd ../OAuth.AspNet.AuthServer && dnu restore
- cd ../Yavsc.Abstract && dnu restore
- cd ../Yavsc.Server && dnu restore
- cd ../Yavsc && dnu restore
script:
- "dnu build"

View File

@ -7,18 +7,12 @@ CONFIG=Debug
git_status := $(shell git status -s --porcelain |wc -l)
all: yavscd
clean:
rm -f src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/Yavsc.Abstract.dll src/OAuth.AspNet.Token/bin/$(CONFIG)/dnx451/OAuth.AspNet.Token.dll src/OAuth.AspNet.AuthServer/bin/$(CONFIG)/dnx451/OAuth.AspNet.AuthServer.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/Yavsc.Server.dll src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll
checklibs:
ls $(DNXLIBFP)
updatedeps:
cp src/Yavsc/bin/output/approot/packages/*/*/lib/*net451*/*.dll private/lib/
cp src/Yavsc/bin/output/approot/packages/*/*/lib/*dnx451*/*.dll private/lib/
test:
make -C src/test
@ -61,8 +55,4 @@ yavscd: src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll src/Yavsc.Server/bin/$(CONFIG)/
mkbundle --static $(DNXLIBS) src/Yavsc/bin/$(CONFIG)/dnx451/Yavsc.dll src/Yavsc/bin/$(CONFIG)/dnx451/pt/Yavsc.resources.dll src/Yavsc/bin/$(CONFIG)/dnx451/en/Yavsc.resources.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/Yavsc.Server.dll src/Yavsc.Server/bin/$(CONFIG)/dnx451/en/Yavsc.Server.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/Yavsc.Abstract.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/en/Yavsc.Abstract.resources.dll src/Yavsc.Abstract/bin/$(CONFIG)/dnx451/pt/Yavsc.Abstract.resources.dll src/OAuth.AspNet.AuthServer/bin/$(CONFIG)/dnx451/OAuth.AspNet.AuthServer.dll src/OAuth.AspNet.Token/bin/$(CONFIG)/dnx451/OAuth.AspNet.Token.dll $(LIBS) -L $(DNX_USER_HOME)/runtimes/dnx-mono.1.0.0-rc1-update2/bin --machine-config $(MONO_PREFIX)/etc/mono/4.5/machine.config -o yavscd
strip yavscd
version-increment-patch:
scripts/version.sh $$(cat version.txt) patch > version.txt
.PHONY: packages

View File

@ -8,7 +8,7 @@
"Dnx": {
"enabled": true,
"enablePackageRestore": false,
"projects": "src/*/project.json;*/project.json;project.json;test/*/project.json"
"projects": "src/*/project.json;*/project.json;project.json;test/*/project.json"
},
"Script": {
"enabled": false

View File

@ -1,44 +0,0 @@
#!/bin/bash
version="$1"
major=0
minor=0
build=0
# break down the version number into it's components
regex="([0-9]+).([0-9]+).([0-9]+)((-[A-Za-z]+)([0-9]+))?"
if [[ $version =~ $regex ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
build="${BASH_REMATCH[3]}"
patchtype="${BASH_REMATCH[5]}"
patchnum="${BASH_REMATCH[6]}"
fi
# check paramater to see which number to increment
if [[ "$2" == "feature" ]]; then
minor=$(echo $minor + 1 | bc)
build=0
patchtype=
patchnum=
elif [[ "$2" == "build" ]]; then
build=$(echo $build + 1 | bc)
patchtype=
patchnum=
elif [[ "$2" == "major" ]]; then
major=$(echo $major+1 | bc)
minor=0
build=0
patchtype=
patchnum=
elif [[ "$2" == "patch" ]]; then
patchnum=$(echo $patchnum + 1 | bc)
else
echo "usage: ./version.sh version_number [major/feature/build/patch]" >&2
exit -1
fi
# echo the new version number
echo "${major}.${minor}.${build}${patchtype}${patchnum}"

View File

@ -33,7 +33,7 @@ namespace OAuth.AspNet.AuthServer
MemoryStream stream, memoryStream = null;
StreamWriter streamWriter;
StreamWriter streamWriter = null;
try
{

View File

@ -26,7 +26,7 @@
"defaultNamespace": "Yavsc"
},
"dependencies": {
"Newtonsoft.Json": "7.0.1",
"Newtonsoft.Json": "6.0.1-beta1",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
"OAuth.AspNet.Token": {
"type": "build",

View File

@ -27,7 +27,7 @@ namespace OAuth.AspNet.Tokens
#region non-Public Members
private readonly TicketDataFormat _ticketDataFormat;
private TicketDataFormat _ticketDataFormat;
private const string _serializationRegex = @"^[A-Za-z0-9-_]*$";

View File

@ -26,7 +26,7 @@
"defaultNamespace": "Yavsc"
},
"dependencies": {
"Newtonsoft.Json": "7.0.1",
"Newtonsoft.Json": "6.0.1-beta1",
"Microsoft.AspNet.Authentication.JwtBearer": "1.0.0-rc1-final",
"Microsoft.AspNet.DataProtection": "1.0.0-rc1-final"
},

View File

@ -5,7 +5,7 @@ namespace Yavsc.Attributes.Validation
public partial class YaStringLength: YaValidationAttribute
{
public long MinimumLength { get; set; } = 0;
private readonly long maxLen;
private long maxLen;
public YaStringLength(long maxLen) : base( ()=> "BadStringLength")
{
this.maxLen = maxLen;
@ -50,4 +50,4 @@ namespace Yavsc.Attributes.Validation
}
}
}
}

View File

@ -16,15 +16,15 @@ namespace Yavsc.Authentication
{
}
string clientId;
string clientSecret;
string scope;
Uri authorizeUrl;
Uri accessTokenUrl;
Uri redirectUrl;
GetUsernameAsyncFunc getUsernameAsync;
readonly string clientId;
readonly string clientSecret;
readonly string scope;
readonly Uri authorizeUrl;
readonly Uri accessTokenUrl;
readonly Uri redirectUrl;
readonly GetUsernameAsyncFunc getUsernameAsync;
readonly string requestState;
string requestState;
bool reportedForgery = false;
/// <summary>

View File

@ -48,7 +48,7 @@ namespace Yavsc
public const string YavscConnectionStringEnvName = "YAVSC_DB_CONNECTION";
// at the end, let 4*4 bytes in peace
public const int WebSocketsMaxBufLen = 4096;
public const int WebSocketsMaxBufLen = 4 * 1020;
public static readonly long DefaultFSQ = 1024 * 1024 * 500;
@ -60,7 +60,5 @@ namespace Yavsc
public const int MaxUserNameLength = 26;
public const string LivePath = "/live/cast";
public const string StreamingPath = "/api/stream/put";
}
}

View File

@ -10,7 +10,7 @@ namespace Yavsc.Helpers
{
public static string UserBillsDirName { set; get; }
public static string UserFilesDirName { set; get; }
/// <summary>
/// Is Valid this Path?
/// Return true when given value is a valid user file sub-path,
@ -37,18 +37,7 @@ namespace Yavsc.Helpers
{
return !name.Any(c => !ValidFileNameChars.Contains(c));
}
public static bool IsValidShortFileName(this string name)
{
if (name.Any(c => !ValidFileNameChars.Contains(c)))
return false;
if (!name.Any(c => !AlfaNum.Contains(c)))
return false;
return true;
}
// Ensure this path is canonical,
// No "dirto/./this", neither "dirt/to/that/"
// no .. and each char must be listed as valid in constants
@ -60,11 +49,11 @@ namespace Yavsc.Helpers
{
if (ValidFileNameChars.Contains(c))
sb.Append(c);
else sb.Append("#" + ((int)c).ToString("D3"));
else sb.Append("#"+((int)c).ToString("D3"));
}
return sb.ToString();
return sb.ToString();
}
public static UserDirectoryInfo GetUserFiles(string userName, string subdir)
{
UserDirectoryInfo di = new UserDirectoryInfo(UserFilesDirName, userName, subdir);
@ -80,13 +69,12 @@ namespace Yavsc.Helpers
// Server side only supports POSIX file systems
public const char RemoteDirectorySeparator = '/';
public static char[] AlfaNum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray();
// Only accept descent remote file names
public static char[] ValidFileNameChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_~. %#".ToCharArray();
// Estimate signature file name format
public static Func<string, string, long, string>
SignFileNameFormat = new Func<string, string, long, string>((signType, billingCode, estimateId) => $"sign-{billingCode}-{signType}-{estimateId}.png");
public static Func<string,string,long,string>
SignFileNameFormat = new Func<string,string,long,string> ((signType,billingCode,estimateId) => $"sign-{billingCode}-{signType}-{estimateId}.png");
}
}

View File

@ -2,6 +2,7 @@ namespace Yavsc.Abstract.FileSystem
{
public interface IFileRecievedInfo
{
string MimeType { get; set; }
string DestDir { get; set; }
@ -11,4 +12,4 @@ namespace Yavsc.Abstract.FileSystem
bool QuotaOffensed { get; set; }
}
}
}

View File

@ -16,7 +16,7 @@ namespace Yavsc.ViewModels.UserFiles
public DirectoryShortInfo [] SubDirectories { 
get; set;
}
private readonly DirectoryInfo dInfo;
private DirectoryInfo dInfo;
// for deserialization
public UserDirectoryInfo()

View File

@ -3,7 +3,7 @@ namespace Yavsc.Models.Process
{
public class Negation<Exp> : IRequisition where Exp : IRequisition
{
readonly Exp _expression;
Exp _expression;
public Negation(Exp expression)
{
_expression = expression;

View File

@ -24,14 +24,11 @@
"Chat"
]
},
"buildOptions": {
"nowarn": ["IDE1006"]
},
"tooling": {
"defaultNamespace": "Yavsc"
},
"dependencies": {
"Newtonsoft.Json": "7.0.1"
"Newtonsoft.Json": "6.0.1-beta1"
},
"frameworks": {
"dnx451": {

View File

@ -31,7 +31,7 @@ namespace Yavsc.Server.Helpers
/// </summary>
public class SimpleJsonPostMethod : IDisposable
{
private readonly HttpWebRequest request=null;
private HttpWebRequest request=null;
/// <summary>
/// Initializes a new instance of the Yavsc.Helpers.SimpleJsonPostMethod class.

View File

@ -31,7 +31,7 @@ namespace Yavsc.Services
/// I calendar manager.
/// </summary>
public interface ICalendarManager {
Task<CalendarList> GetCalendarsAsync (string pageToken);
Task<CalendarList> GetCalendarsAsync (string userId, string pageToken);
Task<Events> GetCalendarAsync (string calid, DateTime minDate, DateTime maxDate, string pageToken);
Task<DateTimeChooserViewModel> CreateViewModelAsync(
string inputId,

View File

@ -1,4 +1,3 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
@ -9,7 +8,6 @@ using Yavsc.Models.Relationship;
namespace Yavsc.Server.Models.Access
{
[Obsolete]
public class CircleAuthorizationToFile : ICircleAuthorization
{

View File

@ -30,13 +30,14 @@ namespace Yavsc.Models.FileSystem
public FileRecievedInfo()
{
QuotaOffensed = Overriden = false;
DestDir = FileName = null;
MimeType = DestDir = FileName = null;
}
public string MimeType { get; set; }
public string DestDir { get; set; }
public string FileName { get; set; }
public bool Overriden { get; set; }
public bool QuotaOffensed { get; set; }
}
}
}

View File

@ -34,19 +34,19 @@ namespace Yavsc.Models.HairCut
public string Sender { get; set; }
readonly HairCutQuery query;
HairCutQuery query;
private readonly string invoiceId;
private readonly string payerName;
private readonly string phone;
private readonly string payerEmail;
private readonly string amount;
private readonly HairCutGenders gender;
private readonly string date;
private readonly string lieu;
private readonly string clientFinal;
private readonly string token;
private readonly string payerId;
private string invoiceId;
private string payerName;
private string phone;
private string payerEmail;
private string amount;
private HairCutGenders gender;
private string date;
private string lieu;
private string clientFinal;
private string token;
private string payerId;
public string CreateBody()
{
@ -73,4 +73,4 @@ Le client final: {clientFinal}
";
}
}
}
}

View File

@ -140,7 +140,7 @@ Prestation.Gender == HairCutGenders.Women ?
bill.Add(new CommandLine
{
Name = name,
Description = name + shorthairsuffix,
Description = name = name + shorthairsuffix,
UnitaryCost = multicolor ? SelectedProfile.ShortMultiColorPrice : SelectedProfile.ShortColorPrice
});

View File

@ -36,5 +36,6 @@ namespace Yavsc.Models.Haircut
private set;
}
HairCutQuery Data { get; set; }
}
}

View File

@ -39,7 +39,7 @@ namespace Yavsc.Server.Models.IT
[ForeignKey("GitId")]
public virtual GitRepositoryReference Repository { get; set; }
readonly List<IBillItem> bill = new List<IBillItem>();
List<IBillItem> bill = new List<IBillItem>();
public void AddBillItem(IBillItem item)
{
bill.Add(item);

View File

@ -47,7 +47,7 @@ namespace Yavsc.Server.Models.IT.SourceCode
writer.WriteLine(process.StandardOutput.ReadLine());
}
}
ResultHandler?.Invoke(true);
if (ResultHandler!=null) ResultHandler(true);
}
}
}

View File

@ -36,8 +36,8 @@ namespace Yavsc.Server.Models.IT.SourceCode
writer.WriteLine(process.StandardOutput.ReadLine());
}
}
ResultHandler?.Invoke(true);
if (ResultHandler!=null) ResultHandler(true);
}
}
}
}

View File

@ -21,7 +21,7 @@ public class Announce : BaseEvent, IAnnounce, IOwned
public string Message { get; set; }
public override string CreateBody()
{
return $"Annonce de {Owner.UserName}: {For}\n\n{Message}";
return $"Annonce de {Owner.UserName}: {For.ToString()}\n\n{Message}";
}
}
}

View File

@ -24,14 +24,13 @@ namespace Yavsc.Models.Messaging
Sender = perfer.Performer.UserName;
_localizer = SR;
}
// TODO via e-mail only: Message = string.Format(
// SR["EstimationMessageToClient"],perfer.Performer.UserName, estimate.Title,estimate.Bill.Addition());
// TODO via e-mail only: Message = string.Format(
// SR["EstimationMessageToClient"],perfer.Performer.UserName, estimate.Title,estimate.Bill.Addition());
//
ProviderClientInfo ProviderInfo { get; set; }
Estimate Estimation { get; set; }
private readonly PerformerProfile perfer;
private PerformerProfile perfer;
public string Topic
{
@ -47,7 +46,7 @@ namespace Yavsc.Models.Messaging
public string CreateBody()
{
return string.Format(_localizer["EstimationMessageToClient"], perfer.Performer.UserName, this.Estimation.Bill.Addition());
return string.Format( _localizer["EstimationMessageToClient"], perfer.Performer.UserName, this.Estimation.Bill.Addition());
}
}
}

View File

@ -65,17 +65,5 @@ namespace Yavsc
/// <returns>the supported activity code</returns>
public string OnlyOneActivityCode { get; set; }
/// <summary>
/// Disk usage user list maximum length in memory
/// </summary>
/// <value></value>
public int DUUserListLen { get; set; } = 256;
/// <summary>
/// Default acl file name
/// </summary>
/// <value></value>
public string AccessListFileName { get; set; } = ".access";
}
}

View File

@ -41,8 +41,7 @@
"Resources/**/*.resx"
],
"publicSign": false,
"keyFile": "../../../sgKey.snk",
"nowarn": ["IDE1006"]
"keyFile": "../../../sgKey.snk"
},
"tooling": {
"defaultNamespace": "Yavsc"

View File

@ -16,7 +16,7 @@ namespace Yavsc.Controllers
public class BlogApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public BlogApiController(ApplicationDbContext context)
{

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
[Route("api/blogtags")]
public class BlogTagsApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public BlogTagsApiController(ApplicationDbContext context)
{
@ -144,4 +144,4 @@ namespace Yavsc.Controllers
return _context.TagsDomain.Count(e => e.PostId == id) > 0;
}
}
}
}

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/blogcomments")]
public class CommentsApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public CommentsApiController(ApplicationDbContext context)
{
@ -158,4 +158,4 @@ namespace Yavsc.Controllers
return _context.Comment.Count(e => e.Id == id) > 0;
}
}
}
}

View File

@ -20,9 +20,9 @@ namespace Yavsc.ApiControllers
[Authorize,Route("api/fs")]
public partial class FileSystemApiController : Controller
{
readonly ApplicationDbContext dbContext;
private readonly IAuthorizationService AuthorizationService;
private readonly ILogger _logger;
ApplicationDbContext dbContext;
private IAuthorizationService AuthorizationService;
private ILogger _logger;
public FileSystemApiController(ApplicationDbContext context,
IAuthorizationService authorizationService,
@ -180,8 +180,6 @@ namespace Yavsc.ApiControllers
}
return Ok(new { deleted=id });
}
}
}

View File

@ -1,72 +0,0 @@
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Logging;
using Yavsc.Attributes.Validation;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Messaging;
using Yavsc.Services;
namespace Yavsc.ApiControllers
{
[Authorize, Route("api/stream")]
public partial class FileSystemStreamController : Controller
{
private readonly ILogger logger;
private readonly ILiveProcessor liveProcessor;
readonly ApplicationDbContext dbContext;
public FileSystemStreamController(ApplicationDbContext context, ILiveProcessor liveProcessor, ILoggerFactory loggerFactory)
{
this.dbContext = context;
this.logger = loggerFactory.CreateLogger<FileSystemStreamController>();
this.liveProcessor = liveProcessor;
}
[Authorize, Route("put/{filename}")]
public async Task<IActionResult> Put([ValidRemoteUserFilePath] string filename)
{
logger.LogInformation("Put : " + filename);
if (!HttpContext.WebSockets.IsWebSocketRequest)
return HttpBadRequest("not a web socket");
if (!HttpContext.User.Identity.IsAuthenticated)
return new HttpUnauthorizedResult();
var subdirs = filename.Split('/');
var filePath = subdirs.Length > 1 ? string.Join("/", subdirs.Take(subdirs.Length-1)) : null;
var shortFileName = subdirs[subdirs.Length-1];
if (!shortFileName.IsValidShortFileName())
{
logger.LogInformation("invalid file name : " + filename);
return HttpBadRequest("invalid file name");
}
logger.LogInformation("validated: api/stream/Put: "+filename);
var userName = User.GetUserName();
var hubContext = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
string url = string.Format(
"{0}/{1}/{2}",
Startup.UserFilesOptions.RequestPath.ToUriComponent(),
userName,
filename
);
hubContext.Clients.All.addPublicStream(new PublicStreamInfo
{
sender = userName,
url = url,
}, $"{userName} is starting a stream!");
string destDir = HttpContext.User.InitPostToFileSystem(filePath);
logger.LogInformation($"Saving flow to {destDir}");
var userId = User.GetUserId();
var user = await dbContext.Users.FirstAsync(u => u.Id == userId);
logger.LogInformation("Accepting stream ...");
await liveProcessor.AcceptStream(HttpContext, user, destDir, shortFileName);
return Ok();
}
}
}

View File

@ -25,15 +25,15 @@ namespace Yavsc.ApiControllers
[Route("api/bill"), Authorize]
public class BillingController : Controller
{
readonly ApplicationDbContext dbContext;
private readonly IStringLocalizer _localizer;
private readonly GoogleAuthSettings _googleSettings;
private readonly IYavscMessageSender _GCMSender;
private readonly IAuthorizationService authorizationService;
ApplicationDbContext dbContext;
private IStringLocalizer _localizer;
private GoogleAuthSettings _googleSettings;
private IYavscMessageSender _GCMSender;
private IAuthorizationService authorizationService;
private readonly ILogger logger;
private readonly IBillingService billingService;
private ILogger logger;
private IBillingService billingService;
public BillingController(
IAuthorizationService authorizationService,

View File

@ -13,11 +13,11 @@ using Yavsc.Models.Billing;
namespace Yavsc.Controllers
{
[Produces("application/json")]
[Route("api/estimate"), Authorize()]
[Route("api/estimate"),Authorize()]
public class EstimateApiController : Controller
{
private readonly ApplicationDbContext _context;
private readonly ILogger _logger;
private ApplicationDbContext _context;
private ILogger _logger;
public EstimateApiController(ApplicationDbContext context, ILoggerFactory loggerFactory)
{
_context = context;
@ -28,21 +28,21 @@ namespace Yavsc.Controllers
if (User.IsInRole(Constants.AdminGroupName)) return true;
return uid == User.GetUserId();
}
bool UserIsAdminOrInThese(string oid, string uid)
bool UserIsAdminOrInThese (string oid, string uid)
{
if (User.IsInRole(Constants.AdminGroupName)) return true;
var cuid = User.GetUserId();
return cuid == uid || cuid == oid;
return cuid == uid || cuid == oid;
}
// GET: api/Estimate{?ownerId=User.GetUserId()}
[HttpGet]
public IActionResult GetEstimates(string ownerId = null)
public IActionResult GetEstimates(string ownerId=null)
{
if (ownerId == null) ownerId = User.GetUserId();
if ( ownerId == null ) ownerId = User.GetUserId();
else if (!UserIsAdminOrThis(ownerId)) // throw new Exception("Not authorized") ;
// or just do nothing
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
return Ok(_context.Estimates.Include(e => e.Bill).Where(e => e.OwnerId == ownerId));
// or just do nothing
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
return Ok(_context.Estimates.Include(e=>e.Bill).Where(e=>e.OwnerId == ownerId));
}
// GET: api/Estimate/5
[HttpGet("{id}", Name = "GetEstimate")]
@ -53,20 +53,20 @@ namespace Yavsc.Controllers
return HttpBadRequest(ModelState);
}
Estimate estimate = _context.Estimates.Include(e => e.Bill).Single(m => m.Id == id);
Estimate estimate = _context.Estimates.Include(e=>e.Bill).Single(m => m.Id == id);
if (estimate == null)
{
return HttpNotFound();
}
if (UserIsAdminOrInThese(estimate.ClientId, estimate.OwnerId))
return Ok(estimate);
if (UserIsAdminOrInThese(estimate.ClientId,estimate.OwnerId))
return Ok(estimate);
return new HttpStatusCodeResult(StatusCodes.Status403Forbidden);
}
// PUT: api/Estimate/5
[HttpPut("{id}"), Produces("application/json")]
[HttpPut("{id}"),Produces("application/json")]
public IActionResult PutEstimate(long id, [FromBody] Estimate estimate)
{
@ -84,11 +84,11 @@ namespace Yavsc.Controllers
{
if (uid != estimate.OwnerId)
{
ModelState.AddModelError("OwnerId", "You can only modify your own estimates");
ModelState.AddModelError("OwnerId","You can only modify your own estimates");
return HttpBadRequest(ModelState);
}
}
var entry = _context.Attach(estimate);
try
{
@ -106,30 +106,27 @@ namespace Yavsc.Controllers
}
}
return Ok(new { estimate.Id });
return Ok( new { Id = estimate.Id });
}
// POST: api/Estimate
[HttpPost, Produces("application/json")]
[HttpPost,Produces("application/json")]
public IActionResult PostEstimate([FromBody] Estimate estimate)
{
var uid = User.GetUserId();
if (estimate.OwnerId == null) estimate.OwnerId = uid;
if (!User.IsInRole(Constants.AdminGroupName))
{
if (estimate.OwnerId==null) estimate.OwnerId = uid;
if (!User.IsInRole(Constants.AdminGroupName)) {
if (uid != estimate.OwnerId)
{
ModelState.AddModelError("OwnerId", "You can only create your own estimates");
ModelState.AddModelError("OwnerId","You can only create your own estimates");
return HttpBadRequest(ModelState);
}
}
if (estimate.CommandId != null)
{
if (estimate.CommandId!=null) {
var query = _context.RdvQueries.FirstOrDefault(q => q.Id == estimate.CommandId);
if (query == null)
{
if (query == null) {
return HttpBadRequest(ModelState);
}
query.ValidationDate = DateTime.Now;
@ -139,18 +136,18 @@ namespace Yavsc.Controllers
if (!ModelState.IsValid)
{
_logger.LogError(JsonConvert.SerializeObject(ModelState));
return Json(ModelState);
return Json(ModelState);
}
_context.Estimates.Add(estimate);
/* _context.AttachRange(estimate.Bill);
_context.Attach(estimate);
_context.Entry(estimate).State = EntityState.Added;
foreach (var line in estimate.Bill)
_context.Entry(line).State = EntityState.Added;
// foreach (var l in estimate.Bill) _context.Attach<CommandLine>(l);
*/
/* _context.AttachRange(estimate.Bill);
_context.Attach(estimate);
_context.Entry(estimate).State = EntityState.Added;
foreach (var line in estimate.Bill)
_context.Entry(line).State = EntityState.Added;
// foreach (var l in estimate.Bill) _context.Attach<CommandLine>(l);
*/
try
{
_context.SaveChanges(User.GetUserId());
@ -166,7 +163,7 @@ namespace Yavsc.Controllers
throw;
}
}
return Ok(new { estimate.Id, estimate.Bill });
return Ok( new { Id = estimate.Id, Bill = estimate.Bill });
}
// DELETE: api/Estimate/5
@ -178,8 +175,8 @@ namespace Yavsc.Controllers
return HttpBadRequest(ModelState);
}
Estimate estimate = _context.Estimates.Include(e => e.Bill).Single(m => m.Id == id);
Estimate estimate = _context.Estimates.Include(e=>e.Bill).Single(m => m.Id == id);
if (estimate == null)
{
return HttpNotFound();
@ -189,7 +186,7 @@ namespace Yavsc.Controllers
{
if (uid != estimate.OwnerId)
{
ModelState.AddModelError("OwnerId", "You can only create your own estimates");
ModelState.AddModelError("OwnerId","You can only create your own estimates");
return HttpBadRequest(ModelState);
}
}
@ -198,8 +195,8 @@ namespace Yavsc.Controllers
return Ok(estimate);
}
protected override void Dispose(bool disposing)
protected override void Dispose (bool disposing)
{
if (disposing)
{
@ -213,4 +210,4 @@ namespace Yavsc.Controllers
return _context.Estimates.Count(e => e.Id == id) > 0;
}
}
}
}

View File

@ -9,10 +9,9 @@ using Yavsc.ViewModels.FrontOffice;
namespace Yavsc.ApiControllers
{
[Route("api/front")]
public class FrontOfficeApiController : Controller
public class FrontOfficeApiController: Controller
{
ApplicationDbContext dbContext;
private IBillingService billing;
public FrontOfficeApiController(ApplicationDbContext context, IBillingService billing)
@ -21,19 +20,19 @@ namespace Yavsc.ApiControllers
this.billing = billing;
}
[HttpGet("profiles/{actCode}")]
IEnumerable<PerformerProfileViewModel> Profiles(string actCode)
[HttpGet("profiles/{actCode}")]
IEnumerable<PerformerProfileViewModel> Profiles (string actCode)
{
return dbContext.ListPerformers(billing, actCode);
}
[HttpPost("query/reject")]
public IActionResult RejectQuery(string billingCode, long queryId)
public IActionResult RejectQuery (string billingCode, long queryId)
{
if (billingCode == null) return HttpBadRequest("billingCode");
if (queryId == 0) return HttpBadRequest("queryId");
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
if (billing == null) return HttpBadRequest();
if (billingCode==null) return HttpBadRequest("billingCode");
if (queryId==0) return HttpBadRequest("queryId");
var billing = BillingService.GetBillable(dbContext, billingCode, queryId);
if (billing==null) return HttpBadRequest();
billing.Rejected = true;
billing.RejectedAt = DateTime.Now;
dbContext.SaveChanges();

View File

@ -11,8 +11,8 @@ namespace Yavsc.ApiControllers
[Route("api/payment")]
public class PaymentApiController : Controller
{
private readonly ApplicationDbContext dbContext;
private readonly SiteSettings siteSettings;
private ApplicationDbContext dbContext;
private SiteSettings siteSettings;
private readonly ILogger _logger;
public PaymentApiController(
ApplicationDbContext dbContext,

View File

@ -16,7 +16,7 @@ namespace Yavsc.Controllers
public class PerformersApiController : Controller
{
ApplicationDbContext dbContext;
private readonly IBillingService billing;
private IBillingService billing;
public PerformersApiController(ApplicationDbContext context, IBillingService billing)
{

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/ProductApi")]
public class ProductApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public ProductApiController(ApplicationDbContext context)
{
@ -146,4 +146,4 @@ namespace Yavsc.Controllers
return _context.Products.Count(e => e.Id == id) > 0;
}
}
}
}

View File

@ -15,7 +15,7 @@ namespace Yavsc.Controllers
[Route("api/dimiss")]
public class DimissClicksApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public DimissClicksApiController(ApplicationDbContext context)
{
@ -174,4 +174,4 @@ namespace Yavsc.Controllers
return _context.DimissClicked.Count(e => e.UserId == id) > 0;
}
}
}
}

View File

@ -16,7 +16,7 @@ namespace Yavsc.Controllers
[Authorize]
public class FileCircleApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public FileCircleApiController(ApplicationDbContext context)
{
@ -185,4 +185,4 @@ namespace Yavsc.Controllers
return _context.CircleAuthorizationToFile.Count(e => e.CircleId == id) > 0;
}
}
}
}

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/bursherprofiles")]
public class BursherProfilesApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public BursherProfilesApiController(ApplicationDbContext context)
{

View File

@ -26,12 +26,37 @@ namespace Yavsc.ApiControllers
[Route("api/haircut")]
public class HairCutController : Controller
{
private readonly ApplicationDbContext _context;
private readonly ILogger _logger;
private ApplicationDbContext _context;
private IEmailSender _emailSender;
private IYavscMessageSender _GCMSender;
private GoogleAuthSettings _googleSettings;
private IStringLocalizer<YavscLocalisation> _localizer;
private ILogger _logger;
private SiteSettings _siteSettings;
private SmtpSettings _smtpSettings;
private UserManager<ApplicationUser> _userManager;
PayPalSettings _paymentSettings;
public HairCutController(ApplicationDbContext context,
IOptions<GoogleAuthSettings> googleSettings,
IYavscMessageSender GCMSender,
UserManager<ApplicationUser> userManager,
IStringLocalizer<Yavsc.YavscLocalisation> localizer,
IEmailSender emailSender,
IOptions<SmtpSettings> smtpSettings,
IOptions<SiteSettings> siteSettings,
IOptions<PayPalSettings> payPalSettings,
ILoggerFactory loggerFactory)
{
_context = context;
_GCMSender = GCMSender;
_emailSender = emailSender;
_googleSettings = googleSettings.Value;
_userManager = userManager;
_smtpSettings = smtpSettings.Value;
_siteSettings = siteSettings.Value;
_paymentSettings = payPalSettings.Value;
_localizer = localizer;
_logger = loggerFactory.CreateLogger<HairCutController>();
}

View File

@ -1,12 +1,12 @@
namespace Yavsc.ApiControllers
{
using Models;
using Yavsc.Models.Musical.Profiles;
using Models.Musical.Profiles;
public class DjProfileApiController : ProfileApiController<DjSettings>
{
public DjProfileApiController() : base()
public DjProfileApiController(ApplicationDbContext context) : base(context)
{
}
}
}
}

View File

@ -13,7 +13,7 @@ namespace Yavsc.Controllers
[Route("api/museprefs")]
public class MusicalPreferencesApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public MusicalPreferencesApiController(ApplicationDbContext context)
{

View File

@ -13,7 +13,7 @@ namespace Yavsc.Controllers
[Route("api/MusicalTendenciesApi")]
public class MusicalTendenciesApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public MusicalTendenciesApiController(ApplicationDbContext context)
{
@ -145,4 +145,4 @@ namespace Yavsc.Controllers
return _context.MusicalTendency.Count(e => e.Id == id) > 0;
}
}
}
}

View File

@ -11,8 +11,8 @@ using Yavsc.Models.Identity;
[Authorize, Route("~/api/gcm")]
public class NativeConfidentialController : Controller
{
readonly ILogger _logger;
readonly ApplicationDbContext _context;
ILogger _logger;
ApplicationDbContext _context;
public NativeConfidentialController(ApplicationDbContext context,
ILoggerFactory loggerFactory)

View File

@ -10,7 +10,7 @@ namespace Yavsc.Controllers
[Route("~/api/PostRateApi")]
public class PostRateApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public PostRateApiController(ApplicationDbContext context)
{

View File

@ -9,9 +9,12 @@ namespace Yavsc.ApiControllers
/// </summary>
[Produces("application/json"),Route("api/profile")]
public abstract class ProfileApiController<T> : Controller
{ public ProfileApiController()
{
ApplicationDbContext dbContext;
public ProfileApiController(ApplicationDbContext context)
{
dbContext = context;
}
}
}
}

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/blacklist"), Authorize]
public class BlackListApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public BlackListApiController(ApplicationDbContext context)
{
@ -162,4 +162,4 @@ namespace Yavsc.Controllers
return _context.BlackListed.Count(e => e.Id == id) > 0;
}
}
}
}

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/blogacl")]
public class BlogAclApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public BlogAclApiController(ApplicationDbContext context)
{
@ -164,4 +164,4 @@ namespace Yavsc.Controllers
return _context.CircleAuthorizationToBlogPost.Count(e => e.CircleId == id) > 0;
}
}
}
}

View File

@ -15,9 +15,9 @@ namespace Yavsc.Controllers
[Route("api/chat")]
public class ChatApiController : Controller
{
readonly ApplicationDbContext dbContext;
readonly UserManager<ApplicationUser> userManager;
private readonly IConnexionManager _cxManager;
ApplicationDbContext dbContext;
UserManager<ApplicationUser> userManager;
private IConnexionManager _cxManager;
public ChatApiController(ApplicationDbContext dbContext,
UserManager<ApplicationUser> userManager,
IConnexionManager cxManager)

View File

@ -15,7 +15,7 @@ namespace Yavsc.Controllers
[Route("api/ChatRoomAccessApi")]
public class ChatRoomAccessApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public ChatRoomAccessApiController(ApplicationDbContext context)
{
@ -183,4 +183,4 @@ namespace Yavsc.Controllers
return _context.ChatRoomAccess.Count(e => e.ChannelName == id) > 0;
}
}
}
}

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/ChatRoomApi")]
public class ChatRoomApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public ChatRoomApiController(ApplicationDbContext context)
{
@ -164,4 +164,4 @@ namespace Yavsc.Controllers
return _context.ChatRoom.Count(e => e.Name == id) > 0;
}
}
}
}

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/cirle")]
public class CircleApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public CircleApiController(ApplicationDbContext context)
{
@ -146,4 +146,4 @@ namespace Yavsc.Controllers
return _context.Circle.Count(e => e.Id == id) > 0;
}
}
}
}

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
[Route("api/ContactsApi")]
public class ContactsApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public ContactsApiController(ApplicationDbContext context)
{
@ -125,4 +125,4 @@ namespace Yavsc.Controllers
return _context.ClientProviderInfo.Count(e => e.UserId == id) > 0;
}
}
}
}

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/ServiceApi")]
public class ServiceApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public ServiceApiController(ApplicationDbContext context)
{
@ -146,4 +146,4 @@ namespace Yavsc.Controllers
return _context.Services.Count(e => e.Id == id) > 0;
}
}
}
}

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent;
using System.Linq;
using System.Net.WebSockets;
using System.Security.Claims;
@ -7,17 +7,21 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Mvc;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Logging;
using Yavsc.Models;
using Yavsc.Models.Streaming;
using Yavsc.Services;
using Yavsc.ViewModels.Streaming;
namespace Yavsc.Controllers
{
[Route("api/live")]
public class LiveApiController : Controller
{
readonly ILiveProcessor _liveProcessor;
private readonly ApplicationDbContext _dbContext;
ILiveProcessor _liveProcessor;
private ApplicationDbContext _dbContext;
ILogger _logger;
/// <summary>
/// Live Api Controller
@ -26,11 +30,13 @@ namespace Yavsc.Controllers
/// <param name="context"></param>
public LiveApiController(
ILoggerFactory loggerFactory,
ApplicationDbContext context,
ILiveProcessor liveProcessor)
{
_liveProcessor = liveProcessor;
_dbContext = context;
_logger = loggerFactory.CreateLogger<LiveApiController>();
}
[HttpGet("filenamehint/{id}")]

View File

@ -16,8 +16,8 @@ namespace Yavsc.ApiControllers
[Route("~/api/bug")]
public class BugApiController : Controller
{
private readonly ApplicationDbContext _context;
readonly ILogger _logger;
private ApplicationDbContext _context;
ILogger _logger;
public BugApiController(ApplicationDbContext context, ILoggerFactory factory)
{

View File

@ -22,8 +22,9 @@ namespace Yavsc.WebApi.Controllers
private UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;
readonly ApplicationDbContext _dbContext;
private readonly ILogger _logger;
ApplicationDbContext _dbContext;
private ILogger _logger;
public ApiAccountController(UserManager<ApplicationUser> userManager,
SignInManager<ApplicationUser> signInManager, ILoggerFactory loggerFactory, ApplicationDbContext dbContext)

View File

@ -14,7 +14,7 @@ namespace Yavsc.Controllers
[Route("api/users")]
public class ApplicationUserApiController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public ApplicationUserApiController(ApplicationDbContext context)
{

View File

@ -11,8 +11,8 @@ namespace Yavsc.ApiControllers.accounting
[Route("~/api/profile")]
public class ProfileApiController: Controller
{
readonly UserManager<ApplicationUser> _userManager;
readonly ApplicationDbContext _dbContext;
UserManager<ApplicationUser> _userManager;
ApplicationDbContext _dbContext;
public ProfileApiController(ApplicationDbContext dbContext, UserManager<ApplicationUser> userManager)
{
_dbContext = dbContext;
@ -36,4 +36,4 @@ namespace Yavsc.ApiControllers.accounting
.Take(10).ToArray();
}
}
}
}

View File

@ -32,4 +32,4 @@ namespace Yavsc.AuthorizationHandlers
}
}
}
}
}

View File

@ -8,7 +8,7 @@ namespace Yavsc.AuthorizationHandlers
{
public class SendMessageHandler : AuthorizationHandler<PrivateChatEntryRequirement, string>
{
readonly ApplicationDbContext _dbContext ;
ApplicationDbContext _dbContext ;
public SendMessageHandler(ApplicationDbContext dbContext)
{

View File

@ -1,38 +1,31 @@
using Microsoft.AspNet.Authorization;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Yavsc.Services;
using Yavsc.ViewModels.Auth;
namespace Yavsc.AuthorizationHandlers
{
namespace Yavsc.AuthorizationHandlers {
public class ViewFileHandler : AuthorizationHandler<ViewRequirement, ViewFileContext>
{
readonly IFileSystemAuthManager _authManager;
private readonly ILogger _logger;
public class ViewFileHandler : AuthorizationHandler<ViewRequirement, ViewFileContext> {
public ViewFileHandler(IFileSystemAuthManager authManager, ILoggerFactory logFactory)
{
IFileSystemAuthManager _authManager;
public ViewFileHandler (IFileSystemAuthManager authManager) {
_authManager = authManager;
_logger = logFactory.CreateLogger<ViewFileHandler>();
}
protected override void Handle(AuthorizationContext context, ViewRequirement requirement, ViewFileContext fileContext)
{
var rights = _authManager.GetFilePathAccess(context.User, fileContext.File);
_logger.LogInformation("Got access value : " + rights);
if ((rights & FileAccessRight.Read) > 0)
{
_logger.LogInformation("Allowing access");
context.Succeed(requirement);
}
else
{
_logger.LogInformation("Denying access");
context.Fail();
protected override void Handle (AuthorizationContext context, ViewRequirement requirement, ViewFileContext fileContext) {
// TODO file access rules
if (fileContext.Path.StartsWith ("/pub/"))
context.Succeed (requirement);
else {
if (!fileContext.Path.StartsWith ("/"))
context.Fail ();
else {
var rights = _authManager.GetFilePathAccess (context.User, fileContext.Path);
if ((rights & FileAccessRight.Read) > 0)
context.Succeed (requirement);
else context.Fail ();
}
}
}
}
}
}

View File

@ -15,7 +15,7 @@ namespace Yavsc.Auth
{
internal class GoogleHandler : OAuthHandler<YavscGoogleOptions>
{
private readonly ILogger _logger;
private ILogger _logger;
public GoogleHandler(HttpClient httpClient,ILogger logger)
: base(httpClient)
{
@ -92,11 +92,9 @@ namespace Yavsc.Auth
{
var scope = FormatScope();
var queryStrings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ "response_type", "code" },
{ "client_id", Options.ClientId }
};
var queryStrings = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
queryStrings.Add("response_type", "code");
queryStrings.Add("client_id", Options.ClientId);
// this runtime may not known this value,
// it should be get from config,
// And always be using a secure sheme ... since Google won't support anymore insecure ones.

View File

@ -16,7 +16,8 @@ namespace Yavsc.Auth
/// </summary>
public class GoogleMiddleware : OAuthMiddleware<YavscGoogleOptions>
{
private readonly ILogger _logger;
private RequestDelegate _next;
private ILogger _logger;
/// <summary>
/// Initializes a new <see cref="GoogleMiddleware"/>.
@ -36,6 +37,11 @@ namespace Yavsc.Auth
YavscGoogleOptions options)
: base(next, dataProtectionProvider, loggerFactory, encoder, sharedOptions, options)
{
if (next == null)
{
throw new ArgumentNullException(nameof(next));
}
_next = next;
if (dataProtectionProvider == null)
{

View File

@ -15,9 +15,8 @@ namespace Yavsc.Auth {
_googleUserId = googleUserId;
Principal = ticket.Principal;
}
readonly AuthenticationTicket _ticket;
readonly string _googleUserId;
AuthenticationTicket _ticket;
string _googleUserId;
public AuthenticationTicket Ticket { get { return _ticket; } }
@ -25,4 +24,4 @@ namespace Yavsc.Auth {
}
}
}

View File

@ -12,8 +12,10 @@ namespace Yavsc.Auth
public class MonoJwtSecurityTokenHandler : JwtSecurityTokenHandler
{
public MonoJwtSecurityTokenHandler()
MonoDataProtectionProvider protectionProvider;
public MonoJwtSecurityTokenHandler(MonoDataProtectionProvider prpro)
{
protectionProvider = prpro;
}
public override JwtSecurityToken CreateToken(
string issuer,
@ -37,4 +39,4 @@ namespace Yavsc.Auth
}
}
}
}

View File

@ -10,6 +10,11 @@ namespace Yavsc.Auth {
public class UserTokenProvider : Microsoft.AspNet.Identity.IUserTokenProvider<ApplicationUser>
{
private MonoDataProtector protector=null;
public MonoDataProtector Protector {
get { return protector; }
}
public Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<ApplicationUser> manager, ApplicationUser user)
{
return Task.FromResult(true);

View File

@ -9,7 +9,7 @@ namespace Yavsc.Auth {
public class MonoXmlEncryptor : IXmlEncryptor
{
public MonoXmlEncryptor ()
public MonoXmlEncryptor (IServiceProvider serviceProvider)
{
}
public EncryptedXmlInfo Encrypt(XElement plaintextElement)
@ -20,4 +20,4 @@ namespace Yavsc.Auth {
}
}
}
}

View File

@ -69,8 +69,9 @@ namespace Yavsc.Controllers
[Authorize(Roles = Constants.AdminGroupName)]
public IActionResult Index()
public IActionResult Index(string page, string len)
{
return View();
}
@ -261,7 +262,7 @@ namespace Yavsc.Controllers
// For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
// Send an email with this link
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code }, protocol: "https", host: Startup.Authority);
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: "https", host: Startup.Authority);
var emailSent = await _emailSender.SendEmailAsync(model.UserName, model.Email, _localizer["ConfirmYourAccountTitle"],
string.Format(_localizer["ConfirmYourAccountBody"], _siteSettings.Title, callbackUrl, _siteSettings.Slogan, _siteSettings.Audience));
// No, wait for more than a login pass submission:
@ -316,7 +317,7 @@ namespace Yavsc.Controllers
{
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Action("ConfirmEmail", "Account",
new { userId = user.Id, code }, protocol: "https", host: Startup.Authority);
new { userId = user.Id, code = code }, protocol: "https", host: Startup.Authority);
var res = await _emailSender.SendEmailAsync(user.UserName, user.Email,
this._localizer["ConfirmYourAccountTitle"],
string.Format(this._localizer["ConfirmYourAccountBody"],
@ -591,7 +592,7 @@ namespace Yavsc.Controllers
// GET: /Account/ResetPassword
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ResetPassword(string UserId)
public async Task<IActionResult> ResetPassword(string UserId, string code = null)
{
var user = await _userManager.FindByIdAsync(UserId);
if (user==null) return new BadRequestResult();

View File

@ -29,18 +29,18 @@ namespace Yavsc.Controllers
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly IEmailSender _emailSender;
private readonly ILogger _logger;
private readonly SiteSettings _siteSettings;
private SiteSettings _siteSettings;
private readonly ApplicationDbContext _dbContext;
private ApplicationDbContext _dbContext;
private readonly GoogleAuthSettings _googleSettings;
private GoogleAuthSettings _googleSettings;
private readonly PayPalSettings _payPalSettings;
private readonly IYavscMessageSender _GCMSender;
private readonly SIRENChecker _cchecker;
private readonly IStringLocalizer _SR;
private readonly CompanyInfoSettings _cinfoSettings;
readonly ICalendarManager _calendarManager;
private PayPalSettings _payPalSettings;
private IYavscMessageSender _GCMSender;
private SIRENChecker _cchecker;
private IStringLocalizer _SR;
private CompanyInfoSettings _cinfoSettings;
ICalendarManager _calendarManager;
public ManageController(
@ -195,9 +195,9 @@ namespace Yavsc.Controllers
// Generate the token and send it
var user = await GetCurrentUserAsync();
var code = await _userManager.GenerateChangePhoneNumberTokenAsync(user, model.PhoneNumber);
// TODO ? await _smsSender.SendSmsAsync(_twilioSettings, model.PhoneNumber, "Your security code is: " + code);
// TODO await _smsSender.SendSmsAsync(_twilioSettings, model.PhoneNumber, "Your security code is: " + code);
return RedirectToAction(nameof(VerifyPhoneNumber), new { model.PhoneNumber });
return RedirectToAction(nameof(VerifyPhoneNumber), new { PhoneNumber = model.PhoneNumber });
}
//
@ -300,7 +300,7 @@ namespace Yavsc.Controllers
{
var uid = User.GetUserId();
var calendars = await _calendarManager.GetCalendarsAsync(pageToken);
var calendars = await _calendarManager.GetCalendarsAsync(uid, pageToken);
return View(new SetGoogleCalendarViewModel {
ReturnUrl = returnUrl,
Calendars = calendars

View File

@ -20,12 +20,27 @@ namespace Yavsc.Controllers
[AllowAnonymous]
public class OAuthController : Controller
{
readonly ILogger _logger;
ApplicationDbContext _context;
UserManager<ApplicationUser> _userManager;
public OAuthController(ILoggerFactory loggerFactory)
SiteSettings _siteSettings;
ILogger _logger;
private readonly SignInManager<ApplicationUser> _signInManager;
public OAuthController(ApplicationDbContext context, SignInManager<ApplicationUser> signInManager, IKeyManager keyManager,
UserManager<ApplicationUser> userManager,
IOptions<SiteSettings> siteSettings,
ILoggerFactory loggerFactory
)
{
_siteSettings = siteSettings.Value;
_context = context;
_signInManager = signInManager;
_userManager = userManager;
_logger = loggerFactory.CreateLogger<OAuthController>();
}
[HttpGet("~/api/getclaims"), Produces("application/json")]

View File

@ -10,7 +10,7 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")]
public class UsersController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public UsersController(ApplicationDbContext context)
{

View File

@ -16,7 +16,7 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")]
public class MailingTemplateController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public MailingTemplateController(ApplicationDbContext context)
{

View File

@ -13,9 +13,10 @@ namespace Yavsc.Controllers
{
public class AnnouncesController : Controller
{
private readonly ApplicationDbContext _context;
readonly IStringLocalizer<AnnouncesController> _localizer;
readonly IAuthorizationService _authorizationService;
private ApplicationDbContext _context;
IStringLocalizer<AnnouncesController> _localizer;
IAuthorizationService _authorizationService;
public AnnouncesController(ApplicationDbContext context,
IAuthorizationService authorizationService,
@ -60,7 +61,9 @@ namespace Yavsc.Controllers
{
ViewBag.IsAdmin = User.IsInRole(Constants.AdminGroupName);
ViewBag.IsPerformer = User.IsInRole(Constants.PerformerGroupName);
ViewBag.AllowEdit = announce==null || announce.Id<=0 || await _authorizationService.AuthorizeAsync(User,announce,new EditRequirement());
ViewBag.AllowEdit = (announce!=null && announce.Id>0) ?
await _authorizationService.AuthorizeAsync(User,announce,new EditRequirement()) :
true;
List<SelectListItem> dl = new List<SelectListItem>();
var rnames = System.Enum.GetNames(typeof(Reason));
var rvalues = System.Enum.GetValues(typeof(Reason));

View File

@ -21,10 +21,11 @@ namespace Yavsc.Controllers
{
public class BlogspotController : Controller
{
readonly ILogger _logger;
private readonly ApplicationDbContext _context;
private readonly IAuthorizationService _authorizationService;
readonly RequestLocalizationOptions _localisationOptions;
ILogger _logger;
private ApplicationDbContext _context;
private IAuthorizationService _authorizationService;
RequestLocalizationOptions _localisationOptions;
public BlogspotController(
ApplicationDbContext context,
@ -40,7 +41,7 @@ namespace Yavsc.Controllers
// GET: Blog
[AllowAnonymous]
public async Task<IActionResult> Index(string id)
public async Task<IActionResult> Index(string id, int skip=0, int maxLen=25)
{
if (!string.IsNullOrEmpty(id)) {
return await UserPosts(id);

View File

@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{
public class CircleController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public CircleController(ApplicationDbContext context)
{

View File

@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{
public class CircleMembersController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public CircleMembersController(ApplicationDbContext context)
{

View File

@ -13,7 +13,7 @@ namespace Yavsc.Controllers
/// </summary>
public class CommentsController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public CommentsController(ApplicationDbContext context)
{

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
using Models.Identity;
public class DevicesController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public DevicesController(ApplicationDbContext context)
{

View File

@ -10,7 +10,7 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")]
public class HyperLinkController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public HyperLinkController(ApplicationDbContext context)
{

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
{
public class LiveFlowController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public LiveFlowController(ApplicationDbContext context)
{

View File

@ -14,8 +14,8 @@ namespace Yavsc.Controllers
[Authorize()]
public class MyFSRulesController : Controller
{
private readonly ApplicationDbContext _context;
private readonly ILogger _logger;
private ApplicationDbContext _context;
private ILogger _logger;
public MyFSRulesController(ApplicationDbContext context,
ILoggerFactory loggerFactory)

View File

@ -9,7 +9,7 @@ namespace Yavsc.Controllers
{
public class NotificationsController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public NotificationsController(ApplicationDbContext context)
{

View File

@ -16,9 +16,9 @@ namespace Yavsc.Controllers
[Authorize("AdministratorOnly")]
public class ActivityController : Controller
{
private readonly ApplicationDbContext _context;
readonly IStringLocalizer<Yavsc.YavscLocalisation> SR;
readonly ILogger logger;
private ApplicationDbContext _context;
IStringLocalizer<Yavsc.YavscLocalisation> SR;
ILogger logger;
public ActivityController(ApplicationDbContext context,
IStringLocalizer<Yavsc.YavscLocalisation> SR,

View File

@ -12,7 +12,7 @@ namespace Yavsc.Controllers
{
public class ClientController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public ClientController(ApplicationDbContext context)
{

View File

@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{
public class CoWorkingController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public CoWorkingController(ApplicationDbContext context)
{

View File

@ -90,7 +90,7 @@ namespace Yavsc.Controllers
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
public IActionResult Create(string proId, string activityCode)
public IActionResult Create(string proId, string activityCode, string billingCode)
{
if (string.IsNullOrWhiteSpace(proId))
throw new InvalidOperationException(
@ -159,7 +159,7 @@ namespace Yavsc.Controllers
_context.RdvQueries.Add(command, GraphBehavior.IncludeDependents);
_context.SaveChanges(User.GetUserId());
var yaev = command.CreateEvent("NewCommand");
var yaev = command.CreateEvent(_localizer, "NewCommand");
MessageWithPayloadResponse nrep = null;

View File

@ -11,7 +11,7 @@ namespace Yavsc.Controllers
{
public class CommandFormsController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public CommandFormsController(ApplicationDbContext context)
{

View File

@ -8,7 +8,7 @@ namespace Yavsc.Controllers
{
public class DjSettingsController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public DjSettingsController(ApplicationDbContext context)
{

View File

@ -17,9 +17,9 @@ namespace Yavsc.Controllers
[Authorize]
public class DoController : Controller
{
private readonly ApplicationDbContext dbContext;
readonly ILogger logger;
readonly IBillingService billing;
private ApplicationDbContext dbContext;
ILogger logger;
IBillingService billing;
public DoController(
ApplicationDbContext context,
IBillingService billing,

View File

@ -21,9 +21,10 @@ namespace Yavsc.Controllers
[Authorize]
public class EstimateController : Controller
{
private readonly ApplicationDbContext _context;
private readonly SiteSettings _site;
readonly IAuthorizationService authorizationService;
private ApplicationDbContext _context;
private SiteSettings _site;
IAuthorizationService authorizationService;
public EstimateController(ApplicationDbContext context, IAuthorizationService authorizationService, IOptions<SiteSettings> siteSettings)
{
@ -142,6 +143,10 @@ namespace Yavsc.Controllers
}
private void Save(ICollection<IFormFile> newGraphics,
ICollection<IFormFile> newFiles) {
}
// GET: Estimate/Edit/5
public IActionResult Edit(long? id)
{

View File

@ -9,7 +9,7 @@ namespace Yavsc.Controllers
{
public class FormsController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public FormsController(ApplicationDbContext context)
{

View File

@ -18,11 +18,13 @@ namespace Yavsc.Controllers
public class FrontOfficeController : Controller
{
readonly ApplicationDbContext _context;
readonly UserManager<ApplicationUser> _userManager;
readonly ILogger _logger;
readonly IStringLocalizer _SR;
private readonly IBillingService _billing;
ApplicationDbContext _context;
UserManager<ApplicationUser> _userManager;
ILogger _logger;
IStringLocalizer _SR;
private IBillingService _billing;
public FrontOfficeController(ApplicationDbContext context,
UserManager<ApplicationUser> userManager,

View File

@ -8,7 +8,7 @@ namespace Yavsc.Controllers
{
public class GeneralSettingsController : Controller
{
private readonly ApplicationDbContext _context;
private ApplicationDbContext _context;
public GeneralSettingsController(ApplicationDbContext context)
{

Some files were not shown because too many files have changed in this diff Show More