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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/csharp-dotnet-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: C# Build with Dot Net - Linux

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x

- name: Restore dependencies
run: dotnet restore Upsilon.Apps.Passkey.Linux.slnx

- name: Build Debug
run: dotnet build Upsilon.Apps.Passkey.Linux.slnx --no-restore --configuration Debug

- name: Build Relesae
run: dotnet build Upsilon.Apps.Passkey.Linux.slnx --no-restore --configuration Release

- name: Test
run: dotnet test --no-build --verbosity normal Upsilon.Apps.Passkey.Linux.slnx


permissions:
contents: read
issues: write
pull-requests: write
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: C# Build with CMake
name: C# Build with Dot Net - Windows

on:
push:
Expand All @@ -15,19 +15,19 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: 10.0.x

- name: Restore dependencies
run: dotnet restore Upsilon.Apps.Passkey.sln
run: dotnet restore Upsilon.Apps.Passkey.Windows.slnx

- name: Build Debug
run: dotnet build Upsilon.Apps.Passkey.sln --no-restore --configuration Debug
run: dotnet build Upsilon.Apps.Passkey.Windows.slnx --no-restore --configuration Debug

- name: Build Relesae
run: dotnet build Upsilon.Apps.Passkey.sln --no-restore --configuration Release
run: dotnet build Upsilon.Apps.Passkey.Windows.slnx --no-restore --configuration Release

- name: Test
run: dotnet test --no-build --verbosity normal Upsilon.Apps.Passkey.sln
run: dotnet test --no-build --verbosity normal Upsilon.Apps.Passkey.Windows.slnx


permissions:
Expand Down
95 changes: 0 additions & 95 deletions Core/Internal/Models/AutoSave.cs

This file was deleted.

21 changes: 0 additions & 21 deletions Core/Internal/Utils/StaticMethods.cs

This file was deleted.

73 changes: 49 additions & 24 deletions Core/Internal/Models/Account.cs → Core/Models/Account.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using System.ComponentModel;
using Upsilon.Apps.PassKey.Core.Internal.Utils;
using Upsilon.Apps.PassKey.Core.Public.Enums;
using Upsilon.Apps.PassKey.Core.Public.Interfaces;
using Upsilon.Apps.Passkey.Core.Utils;
using Upsilon.Apps.Passkey.Interfaces;
using Upsilon.Apps.Passkey.Interfaces.Enums;

namespace Upsilon.Apps.PassKey.Core.Internal.Models
namespace Upsilon.Apps.Passkey.Core.Models
{
internal sealed class Account : IAccount
{
#region IAccount interface explicit Internal

string IItem.ItemId => Database.Get(ItemId);

IDatabase IItem.Database => Database;

IService IAccount.Service => Database.Get(Service);

string IAccount.Label
Expand All @@ -19,18 +22,20 @@ string IAccount.Label
itemName: ToString(),
fieldName: nameof(Label),
needsReview: false,
value: value,
oldValue: Label,
newValue: value,
readableValue: value);
}

string[] IAccount.Identifiants
string[] IAccount.Identifiers
{
get => Database.Get(Identifiants);
set => Identifiants = Database.AutoSave.UpdateValue(ItemId,
get => Database.Get(Identifiers);
set => Identifiers = Database.AutoSave.UpdateValue(ItemId,
itemName: ToString(),
fieldName: nameof(Identifiants),
fieldName: nameof(Identifiers),
needsReview: true,
value: value,
oldValue: Identifiers,
newValue: value,
readableValue: $"({string.Join(", ", value)})");
}

Expand All @@ -39,17 +44,34 @@ string IAccount.Password
get => Database.Get(Password);
set
{
if (!string.IsNullOrEmpty(value))
if (!string.IsNullOrEmpty(value)
&& Password != value)
{
Dictionary<DateTime, string> oldPasswords = Passwords.CloneWith(Database.SerializationCenter);
Passwords[DateTime.Now] = Password = value;

if (_service != null)
{
if (Service.User.NumberOfOldPasswordToKeep != 0)
{
DateTime[] datesToRemove = [.. Passwords.Keys
.OrderBy(x => x)
.Take(Passwords.Count > Service.User.NumberOfOldPasswordToKeep
? Passwords.Count - Service.User.NumberOfOldPasswordToKeep
: 0)];

foreach (DateTime dateToRemove in datesToRemove)
{
_ = Passwords.Remove(dateToRemove);
}
}

_ = Database.AutoSave.UpdateValue(ItemId,
itemName: ToString(),
fieldName: nameof(Password),
needsReview: true,
value: Passwords,
oldValue: oldPasswords,
newValue: Passwords,
readableValue: string.Empty);
}
}
Expand All @@ -65,7 +87,8 @@ string IAccount.Notes
itemName: ToString(),
fieldName: nameof(Notes),
needsReview: false,
value: value,
oldValue: Notes,
newValue: value,
readableValue: value);
}

Expand All @@ -76,7 +99,8 @@ int IAccount.PasswordUpdateReminderDelay
itemName: ToString(),
fieldName: nameof(PasswordUpdateReminderDelay),
needsReview: false,
value: value,
oldValue: PasswordUpdateReminderDelay,
newValue: value,
readableValue: value.ToString());
}

Expand All @@ -87,7 +111,8 @@ AccountOption IAccount.Options
itemName: ToString(),
fieldName: nameof(Options),
needsReview: false,
value: value,
oldValue: Options,
newValue: value,
readableValue: value.ToString());
}

Expand All @@ -105,7 +130,7 @@ internal Service Service
}

public string Label { get; set; } = string.Empty;
public string[] Identifiants { get; set; } = [];
public string[] Identifiers { get; set; } = [];
public string Password { get; set; } = string.Empty;
public Dictionary<DateTime, string> Passwords { get; set; } = [];
public string Notes { get; set; } = string.Empty;
Expand Down Expand Up @@ -136,23 +161,23 @@ public void Apply(Change change)
switch (change.FieldName)
{
case nameof(Label):
Label = Database.SerializationCenter.Deserialize<string>(change.Value);
Label = change.NewValue.DeserializeTo<string>(Database.SerializationCenter);
break;
case nameof(Identifiants):
Identifiants = Database.SerializationCenter.Deserialize<string[]>(change.Value);
case nameof(Identifiers):
Identifiers = change.NewValue.DeserializeTo<string[]>(Database.SerializationCenter);
break;
case nameof(Notes):
Notes = Database.SerializationCenter.Deserialize<string>(change.Value);
Notes = change.NewValue.DeserializeTo<string>(Database.SerializationCenter);
break;
case nameof(Password):
Passwords = Database.SerializationCenter.Deserialize<Dictionary<DateTime, string>>(change.Value);
Passwords = change.NewValue.DeserializeTo<Dictionary<DateTime, string>>(Database.SerializationCenter);
Password = Passwords.Count != 0 ? Passwords[Passwords.Keys.Max()] : string.Empty;
break;
case nameof(PasswordUpdateReminderDelay):
PasswordUpdateReminderDelay = Database.SerializationCenter.Deserialize<int>(change.Value);
PasswordUpdateReminderDelay = change.NewValue.DeserializeTo<int>(Database.SerializationCenter);
break;
case nameof(Options):
Options = Database.SerializationCenter.Deserialize<AccountOption>(change.Value);
Options = change.NewValue.DeserializeTo<AccountOption>(Database.SerializationCenter);
break;
default:
throw new InvalidDataException("FieldName not valid");
Expand All @@ -172,7 +197,7 @@ public override string ToString()
account += $"{Label} ";
}

return account + $"({string.Join(", ", Identifiants)})";
return account + $"({string.Join(", ", Identifiers)})";
}
}
}
Loading
Loading