Skip to content

Commit

Permalink
Revert "Cleanup. (#34)"
Browse files Browse the repository at this point in the history
This reverts commit 933198c.
  • Loading branch information
Utar94 committed Oct 7, 2024
1 parent ca2ced8 commit c4d62be
Show file tree
Hide file tree
Showing 563 changed files with 45,636 additions and 0 deletions.
30 changes: 30 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
30 changes: 30 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Account/CurrentUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Logitar.Cms.Contracts.Sessions;
using Logitar.Cms.Contracts.Users;

namespace Logitar.Cms.Contracts.Account;

public record CurrentUser
{
public string DisplayName { get; set; }
public string? EmailAddress { get; set; }
public string? PictureUrl { get; set; }

public CurrentUser() : this(string.Empty)
{
}

public CurrentUser(Session session) : this(session.User)
{
}

public CurrentUser(User user) : this(user.FullName ?? user.UniqueName)
{
EmailAddress = user.Email?.Address;
PictureUrl = user.Picture;
}

public CurrentUser(string displayName)
{
DisplayName = displayName;
}
}
9 changes: 9 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Account/GetTokenPayload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Logitar.Cms.Contracts.Account;

public record GetTokenPayload
{
[JsonPropertyName("refresh_token")]
public string? RefreshToken { get; set; }

public SignInPayload? Credentials { get; set; }
}
17 changes: 17 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Account/SignInPayload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Logitar.Cms.Contracts.Account;

public record SignInPayload
{
public string Username { get; set; }
public string Password { get; set; }

public SignInPayload() : this(string.Empty, string.Empty)
{
}

public SignInPayload(string username, string password)
{
Username = username;
Password = password;
}
}
29 changes: 29 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Account/TokenResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Logitar.Cms.Contracts.Account;

public record TokenResponse
{
[JsonPropertyName("access_token")]
public string AccessToken { get; set; }

[JsonPropertyName("token_type")]
public string TokenType { get; set; }

[JsonPropertyName("expires_in")]
public int? ExpiresIn { get; set; }

[JsonPropertyName("refresh_token")]
public string? RefreshToken { get; set; }

[JsonPropertyName("scope")]
public string? Scope { get; set; }

public TokenResponse() : this(string.Empty, string.Empty)
{
}

public TokenResponse(string accessToken, string tokenType)
{
AccessToken = accessToken;
TokenType = tokenType;
}
}
54 changes: 54 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Account/UserProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Logitar.Cms.Contracts.Users;

namespace Logitar.Cms.Contracts.Account;

public record UserProfile
{
public string Username { get; set; }

public DateTime? PasswordChangedOn { get; set; }

public string? EmailAddress { get; set; }

public string? FirstName { get; set; }
public string? MiddleName { get; set; }
public string? LastName { get; set; }
public string? FullName { get; set; }

public Locale? Locale { get; set; }

public string? Picture { get; set; }

public DateTime CreatedOn { get; set; }
public DateTime UpdatedOn { get; set; }
public DateTime AuthenticatedOn { get; set; }

public UserProfile() : this(string.Empty)
{
}

public UserProfile(string username)
{
Username = username;
}

public UserProfile(User user) : this(user.UniqueName)
{
PasswordChangedOn = user.PasswordChangedOn;

EmailAddress = user.Email?.Address;

FirstName = user.FirstName;
MiddleName = user.MiddleName;
LastName = user.LastName;
FullName = user.FullName;

Locale = user.Locale;

Picture = user.Picture;

CreatedOn = user.CreatedOn;
UpdatedOn = user.UpdatedOn;
AuthenticatedOn = user.AuthenticatedOn ?? user.UpdatedOn;
}
}
57 changes: 57 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Actors/Actor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Logitar.Cms.Contracts.ApiKeys;
using Logitar.Cms.Contracts.Users;

namespace Logitar.Cms.Contracts.Actors;

public class Actor
{
public static Actor System => new(ActorType.System.ToString());

public Guid Id { get; set; }
public ActorType Type { get; set; }
public bool IsDeleted { get; set; }

public string DisplayName { get; set; }
public string? EmailAddress { get; set; }
public string? PictureUrl { get; set; }

public Actor() : this(string.Empty)
{
}

public Actor(ApiKey apiKey) : this(apiKey.DisplayName)
{
Id = apiKey.Id;
Type = ActorType.ApiKey;
}

public Actor(User user) : this(user.FullName ?? user.UniqueName)
{
Id = user.Id;
Type = ActorType.User;

EmailAddress = user.Email?.Address;
PictureUrl = user.Picture;
}

public Actor(string displayName)
{
DisplayName = displayName;
}

public override bool Equals(object obj) => obj is Actor actor && actor.Id == Id;
public override int GetHashCode() => Id.GetHashCode();
public override string ToString()
{
StringBuilder s = new();

s.Append(DisplayName);
if (EmailAddress != null)
{
s.Append(" <").Append(EmailAddress).Append('>');
}
s.Append(" (").Append(Type).Append(".Id=").Append(Id).Append(')');

return s.ToString();
}
}
8 changes: 8 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Actors/ActorType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Logitar.Cms.Contracts.Actors;

public enum ActorType
{
System = 0,
User = 1,
ApiKey = 2
}
19 changes: 19 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Aggregate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Logitar.Cms.Contracts.Actors;

namespace Logitar.Cms.Contracts;

public abstract class Aggregate
{
public Guid Id { get; set; }
public long Version { get; set; }

public Actor CreatedBy { get; set; } = new();
public DateTime CreatedOn { get; set; }

public Actor UpdatedBy { get; set; } = new();
public DateTime UpdatedOn { get; set; }

public override bool Equals(object obj) => obj is Aggregate aggregate && aggregate.GetType().Equals(GetType()) && aggregate.Id == Id;
public override int GetHashCode() => HashCode.Combine(GetType(), Id);
public override string ToString() => $"{GetType()} (Id={Id})";
}
31 changes: 31 additions & 0 deletions backend/src/Logitar.Cms.Contracts/ApiKeys/ApiKey.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Logitar.Cms.Contracts.Roles;

namespace Logitar.Cms.Contracts.ApiKeys;

public class ApiKey : Aggregate
{
public string? XApiKey { get; set; }

public string DisplayName { get; set; }
public string? Description { get; set; }
public DateTime? ExpiresOn { get; set; }

public DateTime? AuthenticatedOn { get; set; }

public List<CustomAttribute> CustomAttributes { get; set; }

public List<Role> Roles { get; set; }

public ApiKey() : this(string.Empty)
{
}

public ApiKey(string displayName)
{
DisplayName = displayName;
CustomAttributes = [];
Roles = [];
}

public override string ToString() => $"{DisplayName} | {base.ToString()}";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Logitar.Cms.Contracts.ApiKeys;

public record AuthenticateApiKeyPayload
{
public string XApiKey { get; set; }

public AuthenticateApiKeyPayload() : this(string.Empty)
{
}

public AuthenticateApiKeyPayload(string xApiKey)
{
XApiKey = xApiKey;
}
}
21 changes: 21 additions & 0 deletions backend/src/Logitar.Cms.Contracts/ApiKeys/CreateApiKeyPayload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Logitar.Cms.Contracts.ApiKeys;

public record CreateApiKeyPayload // ISSUE: https://github.com/Logitar/CMS/issues/11
{
public string DisplayName { get; set; }
public string? Description { get; set; }
public DateTime? ExpiresOn { get; set; }

public List<CustomAttribute> CustomAttributes { get; set; }

public CreateApiKeyPayload() : this(string.Empty)
{
}

public CreateApiKeyPayload(string displayName)
{
DisplayName = displayName;

CustomAttributes = [];
}
}
11 changes: 11 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Change.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Logitar.Cms.Contracts;

public record Change<T>
{
public T? Value { get; }

public Change(T? value = default)
{
Value = value;
}
}
26 changes: 26 additions & 0 deletions backend/src/Logitar.Cms.Contracts/Configurations/Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Logitar.Cms.Contracts.Configurations;

public class Configuration : Aggregate
{
public string Secret { get; set; }

public UniqueNameSettings UniqueNameSettings { get; set; }
public PasswordSettings PasswordSettings { get; set; }
public bool RequireUniqueEmail { get; set; }

public LoggingSettings LoggingSettings { get; set; }

public Configuration() : this(string.Empty)
{
}

public Configuration(string secret)
{
Secret = secret;

UniqueNameSettings = new();
PasswordSettings = new();

LoggingSettings = new();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Logitar.Cms.Contracts.Configurations;

public interface ILoggingSettings
{
LoggingExtent Extent { get; }
bool OnlyErrors { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Logitar.Cms.Contracts.Configurations;

public enum LoggingExtent
{
None = 0,
ActivityOnly = 1,
Full = 2
}
Loading

0 comments on commit c4d62be

Please sign in to comment.