Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ jobs:
- name: Docker build and push
run: |
echo ${{env.PRODUCTION_SETTINGS_FILE}}
sed -i 's/"__AUTH0_AUDIENCE",/"${{ vars.AUTH0_AUDIENCE }}",/g' ${{env.PRODUCTION_SETTINGS_FILE}}
sed -i 's/"__GOOGLE_CLIENT_ID",/"${{ vars.GOOGLE_CLIENT_ID }}",/g' ${{env.PRODUCTION_SETTINGS_FILE}}
sed -i 's/"__GOOGLE_CLIENT_SECRET",/"${{ vars.GOOGLE_CLIENT_SECRET }}",/g' ${{env.PRODUCTION_SETTINGS_FILE}}
sed -i 's/"__AUTH_GITHUB_CLIENT_ID",/"${{ vars.AUTH_GITHUB_CLIENT_ID }}",/g' ${{env.PRODUCTION_SETTINGS_FILE}}
sed -i 's/"__AUTH_GITHUB_CLIENT_SECRET",/"${{ vars.AUTH_GITHUB_CLIENT_SECRET }}",/g' ${{env.PRODUCTION_SETTINGS_FILE}}
sed -i 's/"__JWT_SECRET",/"${{ vars.JWT_SECRET }}",/g' ${{env.PRODUCTION_SETTINGS_FILE}}
sed -i 's/"__DATABASE_CONNECTION_STRING",/"${{ vars.DATABASE_CONNECTION_STRING }}",/g' ${{env.PRODUCTION_SETTINGS_FILE}}
sed -i 's/"__TELEGRAM_BOT_KEY",/"${{ secrets.TELEGRAM_BOT_KEY }}",/g' ${{env.PRODUCTION_SETTINGS_FILE}}
sed -i 's/"__PROFILE_GITHUB_BOT_KEY",/"${{ secrets.PROFILE_GITHUB_BOT_KEY }}",/g' ${{env.PRODUCTION_SETTINGS_FILE}}
Expand Down
2 changes: 1 addition & 1 deletion src/Domain.Tests/Entities/AiAnalysisRecordTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Domain.Entities.StatData;
using Domain.Entities.StatData;
using Domain.Entities.StatData.Salary;
using TestUtils.Fakes;
using Xunit;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain.Tests/Entities/Companies/CompanyReviewTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Domain.Entities.Companies;
using Domain.Enums;
using TestUtils.Fakes;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain.Tests/Entities/Companies/CompanyTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using Domain.Enums;
using Microsoft.EntityFrameworkCore;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain.Tests/Totp/TotpCodeTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Domain.Totp;
using Xunit;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain.Tests/ValueObjects/CompanySlugTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Domain.ValueObjects;
using Domain.ValueObjects;
using Xunit;

namespace Domain.Tests.ValueObjects;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain.Tests/ValueObjects/KebabCaseSlugTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Domain.ValueObjects;
using Domain.ValueObjects;
using Xunit;

namespace Domain.Tests.ValueObjects;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain.Tests/ValueObjects/SalaryGradeRangesTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Domain.Entities.Enums;
using Domain.Entities.StatData.Salary;
using Domain.ValueObjects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Domain.ValueObjects;
using Domain.ValueObjects;
using Xunit;

namespace Domain.Tests.ValueObjects;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Domain.ValueObjects;
using Domain.ValueObjects;
using Xunit;

namespace Domain.Tests.ValueObjects;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Attributes/CollectionNotEmptyBaseAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Attributes/GroupAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Domain.Entities.Enums;
using Domain.Enums;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Attributes/NotDefaultValueAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;

Expand Down
1 change: 1 addition & 0 deletions src/Domain/Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<ItemGroup>
<PackageReference Include="Otp.NET" Version="1.4.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.15.0" />
</ItemGroup>

</Project>
100 changes: 100 additions & 0 deletions src/Domain/Entities/Auth/M2mClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using Domain.Entities.Users;
using Domain.Validation;

namespace Domain.Entities.Auth;

public class M2mClient : BaseModel, IHasDeletedAt
{
protected M2mClient()
{
}

public M2mClient(
string name,
string description,
long createdByUserId)
{
Name = name.ThrowIfNullOrEmpty(nameof(name));
Description = description;
ClientId = Guid.NewGuid().ToString("N");
IsActive = true;
CreatedByUserId = createdByUserId;
Scopes = new List<M2mClientScope>();
}

public string Name { get; protected set; }

public string Description { get; protected set; }

public string ClientId { get; protected set; }

public string ClientSecretHash { get; protected set; }

public bool IsActive { get; protected set; }

public DateTimeOffset? DeletedAt { get; protected set; }

public virtual List<M2mClientScope> Scopes { get; protected set; }

public long CreatedByUserId { get; protected set; }

public virtual User CreatedByUser { get; protected set; }

public DateTimeOffset? LastUsedAt { get; protected set; }

public string LastUsedIpAddress { get; protected set; }

public int? RateLimitPerMinute { get; protected set; }

public int? RateLimitPerDay { get; protected set; }

public void SetClientSecret(string hashedSecret)
{
ClientSecretHash = hashedSecret;
}

public void Deactivate()
{
IsActive = false;
}

public void Activate()
{
IsActive = true;
}

public void RecordUsage(string ipAddress)
{
LastUsedAt = DateTimeOffset.UtcNow;
LastUsedIpAddress = ipAddress;
}

public void Update(
string name,
string description,
int? rateLimitPerMinute,
int? rateLimitPerDay)
{
if (!string.IsNullOrWhiteSpace(name))
{
Name = name;
}

Description = description;
RateLimitPerMinute = rateLimitPerMinute;
RateLimitPerDay = rateLimitPerDay;
}

public void Delete()
{
if (DeletedAt.HasValue)
{
throw new InvalidOperationException($"M2M Client Id:{Id} is already deleted");
}

DeletedAt = DateTimeOffset.UtcNow;
IsActive = false;
}
}
24 changes: 24 additions & 0 deletions src/Domain/Entities/Auth/M2mClientScope.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Domain.Validation;

namespace Domain.Entities.Auth;

public class M2mClientScope : BaseModel
{
protected M2mClientScope()
{
}

public M2mClientScope(
long m2mClientId,
string scope)
{
M2mClientId = m2mClientId;
Scope = scope.ThrowIfNullOrEmpty(nameof(scope));
}

public long M2mClientId { get; protected set; }

public virtual M2mClient M2mClient { get; protected set; }

public string Scope { get; protected set; }
}
46 changes: 46 additions & 0 deletions src/Domain/Entities/Auth/RefreshToken.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using Domain.Entities.Users;

namespace Domain.Entities.Auth;

public class RefreshToken : BaseModel
{
protected RefreshToken()
{
}

public RefreshToken(
long userId,
string token,
DateTimeOffset expiresAt,
string deviceInfo = null)
{
UserId = userId;
Token = token;
ExpiresAt = expiresAt;
DeviceInfo = deviceInfo;
IsRevoked = false;
}

public string Token { get; protected set; }

public long UserId { get; protected set; }

public virtual User User { get; protected set; }

public DateTimeOffset ExpiresAt { get; protected set; }

public bool IsRevoked { get; protected set; }

public string DeviceInfo { get; protected set; }

public void Revoke()
{
IsRevoked = true;
}

public bool IsValid()
{
return !IsRevoked && ExpiresAt > DateTimeOffset.UtcNow;
}
}
2 changes: 1 addition & 1 deletion src/Domain/Entities/BaseModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Domain.Entities;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/CSV/UserCsvDownload.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Domain.Entities.Users;
using Domain.Enums;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Companies/Company.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Domain.Validation.Exceptions;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Companies/CompanyEmploymentType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Domain.Entities.Companies
namespace Domain.Entities.Companies
{
public enum CompanyEmploymentType
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Companies/CompanyOpenAiAnalysis.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Companies/CompanyRatingHistory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace Domain.Entities.Companies;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Companies/CompanyReview.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Companies/CompanyReviewVote.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Domain.Entities.Users;

namespace Domain.Entities.Companies;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Companies/CompanyReviewVoteType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Domain.Entities.Companies;
namespace Domain.Entities.Companies;

public enum CompanyReviewVoteType
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Currencies/CurrenciesCollection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Domain.Entities.Salaries;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Currencies/CurrencyContent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Globalization;
using System.Xml.Linq;
using Domain.Entities.Salaries;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Currencies/KztCurrencyContent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Domain.Entities.Salaries;

namespace Domain.Entities.Currencies;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Enums/DeveloperGrade.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel;
using System.ComponentModel;
using Domain.Attributes;
using Domain.Enums;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Github/GithubPersonalUserToken.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace Domain.Entities.Github;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Github/GithubProfile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Github/GithubProfileBotChat.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;

namespace Domain.Entities.Github;
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Github/GithubProfileBotMessage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace Domain.Entities.Github;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Github/GithubProfileData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;

Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/Github/GithubProfileProcessingJob.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Domain.Entities.Github;
namespace Domain.Entities.Github;

public class GithubProfileProcessingJob : HasDatesBase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Entities/HasDatesBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Domain.ValueObjects.Dates.Interfaces;

namespace Domain.Entities;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Domain.Entities.StatData.Salary;

namespace Domain.Entities.HistoricalRecords;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Domain.Validation.Exceptions;

Expand Down
Loading