Skip to content

Commit

Permalink
Merge pull request #6 from RicardoZambon/features/current-user-abstract
Browse files Browse the repository at this point in the history
feat: Add user service abstract class
  • Loading branch information
RicardoZambon authored Mar 4, 2024
2 parents 8ed8e7f + 67842c5 commit 74631a5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions ZWebAPI/Services/CurrentUserProviderAbstract.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using ZDatabase.Services.Interfaces;

namespace ZWebAPI.Services
{
/// <inheritdoc />
public abstract class CurrentUserProviderAbstract<TUserKey> : ICurrentUserProvider<TUserKey>
where TUserKey : struct
{
#region Variables
private bool serviceUserMode = false;
#endregion

#region Properties
/// <inheritdoc />
public TUserKey? CurrentUserID { get => serviceUserMode ? DefaultServiceUserID : UserID; }

/// <summary>
/// Gets the user identifier.
/// </summary>
/// <value>
/// The user identifier.
/// </value>
public abstract TUserKey? UserID { get; }

protected abstract TUserKey DefaultServiceUserID { get; }
#endregion

#region Constructor
#endregion

#region Public methods
/// <inheritdoc />
public void DisableServiceUserMode()
{
serviceUserMode = false;
}

/// <inheritdoc />
public void EnableServiceUserMode()
{
serviceUserMode = true;
}
#endregion

#region Private methods
#endregion
}
}
2 changes: 1 addition & 1 deletion ZWebAPI/ZWebAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="ZDatabase" Version="1.2.0" />
<PackageReference Include="ZDatabase" Version="1.3.0" />
<PackageReference Include="ZSecurity" Version="1.0.2" />
</ItemGroup>

Expand Down

0 comments on commit 74631a5

Please sign in to comment.