refacto API prefix + nav.back
This commit is contained in:
parent
bd6ca9d11f
commit
6825f74308
78 changed files with 770 additions and 222 deletions
|
|
@ -14,7 +14,7 @@ namespace Yavsc.Helpers
|
|||
public static string ToAbsolute(this HttpRequest request, string url)
|
||||
{
|
||||
var host = request.Host;
|
||||
var isSecure = request.Headers[YavscConstants.SshHeaderKey] == "on";
|
||||
var isSecure = request.Headers[Constants.SshHeaderKey] == "on";
|
||||
return (isSecure ? "https" : "http") + $"://{host}/{url}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ public static class ServiceExtensions
|
|||
{
|
||||
ValidateAudience = true,
|
||||
ValidAudiences = audiences,
|
||||
RoleClaimType = YavscConstants.RoleClaimType,
|
||||
NameClaimType = YavscConstants.NameClaimType,
|
||||
RoleClaimType = Constants.RoleClaimType,
|
||||
NameClaimType = Constants.NameClaimType,
|
||||
};
|
||||
options.MapInboundClaims = true;
|
||||
options.ClaimsIssuer = authority;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace Yavsc.Server.Hubs
|
|||
var userId = _dbContext.Users.First(u => u.UserName == Context.User.Identity.Name).Id;
|
||||
|
||||
await Clients.Group(ChatHubConstants.HubGroupFollowingPrefix + userId).SendAsync("notifyUser", NotificationTypes.Connected, userName, null);
|
||||
isCop = Context.User.IsInMsRole(YavscConstants.AdminGroupName) ;
|
||||
isCop = Context.User.IsInMsRole(Constants.AdminGroupName) ;
|
||||
if (isCop)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, ChatHubConstants.HubGroupCops);
|
||||
|
|
@ -351,7 +351,7 @@ namespace Yavsc.Server.Hubs
|
|||
var identityUserName = Context.User.GetUserName();
|
||||
|
||||
if (userName[0] != '?' && Context.User!=null)
|
||||
if (!Context.User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (!Context.User.IsInMsRole(Constants.AdminGroupName))
|
||||
{
|
||||
|
||||
var bl = _dbContext.BlackListed
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ namespace Yavsc.Models
|
|||
builder.Entity<ApplicationUser>().Property(u => u.FullName).IsRequired(false);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.DedicatedGoogleCalendar).IsRequired(false);
|
||||
builder.Entity<ApplicationUser>().HasMany<ChatConnection>(c => c.Connections);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.Avatar).HasDefaultValue(YavscConstants.DefaultAvatar);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.DiskQuota).HasDefaultValue(YavscConstants.DefaultFSQ);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.Avatar).HasDefaultValue(Constants.DefaultAvatar);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.DiskQuota).HasDefaultValue(Constants.DefaultFSQ);
|
||||
builder.Entity<ApplicationUser>().HasAlternateKey(u => u.Email);
|
||||
builder.Entity<BlackListed>().HasOne<ApplicationUser>(bl => bl.User);
|
||||
builder.Entity<BlackListed>().HasOne<ApplicationUser>(bl => bl.Owner);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace Yavsc.Services
|
|||
// TODO: Handle the socket here.
|
||||
// Find receivers: others in the chat room
|
||||
// send them the flow
|
||||
var buffer = new byte[YavscConstants.WebSocketsMaxBufLen];
|
||||
var buffer = new byte[Constants.WebSocketsMaxBufLen];
|
||||
var sBuffer = new ArraySegment<byte>(buffer);
|
||||
_logger.LogInformation("Receiving bytes...");
|
||||
|
||||
|
|
@ -69,16 +69,16 @@ namespace Yavsc.Services
|
|||
|
||||
_logger.LogInformation($"Received bytes : {received.Count}");
|
||||
_logger.LogInformation($"Is the end : {received.EndOfMessage}");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var fsInputQueue = new Queue<ArraySegment<byte>>();
|
||||
|
||||
bool endOfInput = false;
|
||||
sBuffer = new ArraySegment<byte>(buffer,0,received.Count);
|
||||
fsInputQueue.Enqueue(sBuffer);
|
||||
var taskWritingToFs = liveHandler.ReceiveUserFile(user, _logger, destDir, fsInputQueue, fileName, () => endOfInput);
|
||||
|
||||
|
||||
|
||||
Stack<string> ToClose = new Stack<string>();
|
||||
|
||||
|
|
@ -105,19 +105,19 @@ namespace Yavsc.Services
|
|||
}
|
||||
}
|
||||
|
||||
if (!received.CloseStatus.HasValue)
|
||||
if (!received.CloseStatus.HasValue)
|
||||
{
|
||||
_logger.LogInformation("try and receive new bytes");
|
||||
|
||||
buffer = new byte[YavscConstants.WebSocketsMaxBufLen];
|
||||
buffer = new byte[Constants.WebSocketsMaxBufLen];
|
||||
received = await liveHandler.Socket.ReceiveAsync(sBuffer, liveHandler.TokenSource.Token);
|
||||
|
||||
|
||||
_logger.LogInformation($"Received bytes : {received.Count}");
|
||||
|
||||
sBuffer = new ArraySegment<byte>(buffer,0,received.Count);
|
||||
_logger.LogInformation($"segment : offset: {sBuffer.Offset} count: {sBuffer.Count}");
|
||||
_logger.LogInformation($"Is the end : {received.EndOfMessage}");
|
||||
|
||||
|
||||
if (received.CloseStatus.HasValue)
|
||||
{
|
||||
endOfInput=true;
|
||||
|
|
@ -140,7 +140,7 @@ namespace Yavsc.Services
|
|||
}
|
||||
}
|
||||
while (liveHandler.Socket.State == WebSocketState.Open);
|
||||
|
||||
|
||||
_logger.LogInformation("Closing connection");
|
||||
taskWritingToFs.Wait();
|
||||
await liveHandler.Socket.CloseAsync(WebSocketCloseStatus.NormalClosure, received.CloseStatusDescription, liveHandler.TokenSource.Token);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ namespace Yavsc.Services
|
|||
{
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
public ProfileService(
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ILogger<DefaultProfileService> logger)
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ILogger<DefaultProfileService> logger)
|
||||
{
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace Yavsc.Services
|
|||
ProfileDataRequestContext context,
|
||||
ApplicationUser user)
|
||||
{
|
||||
|
||||
|
||||
var claims = new List<Claim> {
|
||||
new Claim(JwtClaimTypes.Subject,user.Id.ToString()),
|
||||
};
|
||||
|
|
@ -43,7 +43,7 @@ namespace Yavsc.Services
|
|||
claimAdds.Remove("profile");
|
||||
claimAdds.Add(JwtClaimTypes.Name);
|
||||
claimAdds.Add(JwtClaimTypes.Email);
|
||||
claimAdds.Add(YavscConstants.RoleClaimType);
|
||||
claimAdds.Add(Constants.RoleClaimType);
|
||||
}
|
||||
|
||||
if (claimAdds.Contains(JwtClaimTypes.Name))
|
||||
|
|
@ -51,13 +51,13 @@ namespace Yavsc.Services
|
|||
|
||||
if (claimAdds.Contains(JwtClaimTypes.Email))
|
||||
claims.Add(new Claim(JwtClaimTypes.Email, user.Email));
|
||||
|
||||
if (claimAdds.Contains(YavscConstants.RoleClaimType))
|
||||
|
||||
if (claimAdds.Contains(Constants.RoleClaimType))
|
||||
{
|
||||
var roles = await this._userManager.GetRolesAsync(user);
|
||||
if (roles.Count()>0)
|
||||
{
|
||||
claims.AddRange(roles.Select(r => new Claim(YavscConstants.RoleClaimType, r)));
|
||||
claims.AddRange(roles.Select(r => new Claim(Constants.RoleClaimType, r)));
|
||||
}
|
||||
}
|
||||
return claims;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Yavsc.ViewModels.Account
|
|||
public class ExternalLoginConfirmationViewModel
|
||||
{
|
||||
[Required]
|
||||
[YaStringLength(2,YavscConstants.MaxUserNameLength)]
|
||||
[YaRegularExpression(YavscConstants.UserNameRegExp)]
|
||||
[YaStringLength(2,Constants.MaxUserNameLength)]
|
||||
[YaRegularExpression(Constants.UserNameRegExp)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue