refact
This commit is contained in:
parent
1aafb7cc7d
commit
e24208e77b
32 changed files with 96 additions and 94 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[Constants.SshHeaderKey] == "on";
|
||||
var isSecure = request.Headers[YavscConstants.SshHeaderKey] == "on";
|
||||
return (isSecure ? "https" : "http") + $"://{host}/{url}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace Yavsc
|
|||
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(Constants.AdminGroupName) ;
|
||||
isCop = Context.User.IsInMsRole(YavscConstants.AdminGroupName) ;
|
||||
if (isCop)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, ChatHubConstants.HubGroupCops);
|
||||
|
|
@ -353,7 +353,7 @@ namespace Yavsc
|
|||
var identityUserName = Context.User.GetUserName();
|
||||
|
||||
if (userName[0] != '?' && Context.User!=null)
|
||||
if (!Context.User.IsInMsRole(Constants.AdminGroupName))
|
||||
if (!Context.User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
{
|
||||
|
||||
var bl = _dbContext.BlackListed
|
||||
|
|
|
|||
|
|
@ -72,8 +72,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(Constants.DefaultAvatar);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.DiskQuota).HasDefaultValue(Constants.DefaultFSQ);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.Avatar).HasDefaultValue(YavscConstants.DefaultAvatar);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.DiskQuota).HasDefaultValue(YavscConstants.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[Constants.WebSocketsMaxBufLen];
|
||||
var buffer = new byte[YavscConstants.WebSocketsMaxBufLen];
|
||||
var sBuffer = new ArraySegment<byte>(buffer);
|
||||
_logger.LogInformation("Receiving bytes...");
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ namespace Yavsc.Services
|
|||
{
|
||||
_logger.LogInformation("try and receive new bytes");
|
||||
|
||||
buffer = new byte[Constants.WebSocketsMaxBufLen];
|
||||
buffer = new byte[YavscConstants.WebSocketsMaxBufLen];
|
||||
received = await liveHandler.Socket.ReceiveAsync(sBuffer, liveHandler.TokenSource.Token);
|
||||
|
||||
_logger.LogInformation($"Received bytes : {received.Count}");
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Yavsc.Services
|
|||
claimAdds.Remove("profile");
|
||||
claimAdds.Add(JwtClaimTypes.Name);
|
||||
claimAdds.Add(JwtClaimTypes.Email);
|
||||
claimAdds.Add(Constants.RoleClaimType);
|
||||
claimAdds.Add(YavscConstants.RoleClaimType);
|
||||
}
|
||||
|
||||
if (claimAdds.Contains(JwtClaimTypes.Name))
|
||||
|
|
@ -52,12 +52,12 @@ namespace Yavsc.Services
|
|||
if (claimAdds.Contains(JwtClaimTypes.Email))
|
||||
claims.Add(new Claim(JwtClaimTypes.Email, user.Email));
|
||||
|
||||
if (claimAdds.Contains(Constants.RoleClaimType))
|
||||
if (claimAdds.Contains(YavscConstants.RoleClaimType))
|
||||
{
|
||||
var roles = await this._userManager.GetRolesAsync(user);
|
||||
if (roles.Count()>0)
|
||||
{
|
||||
claims.AddRange(roles.Select(r => new Claim(Constants.RoleClaimType, r)));
|
||||
claims.AddRange(roles.Select(r => new Claim(YavscConstants.RoleClaimType, r)));
|
||||
}
|
||||
}
|
||||
return claims;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Yavsc.ViewModels.Account
|
|||
public class ExternalLoginConfirmationViewModel
|
||||
{
|
||||
[Required]
|
||||
[YaStringLength(2,Constants.MaxUserNameLength)]
|
||||
[YaRegularExpression(Constants.UserNameRegExp)]
|
||||
[YaStringLength(2,YavscConstants.MaxUserNameLength)]
|
||||
[YaRegularExpression(YavscConstants.UserNameRegExp)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue