refacto API prefix + nav.back
This commit is contained in:
parent
bd6ca9d11f
commit
6825f74308
78 changed files with 770 additions and 222 deletions
137
src/PostIt.Tests/AddCircleMemberDialogTests.cs
Normal file
137
src/PostIt.Tests/AddCircleMemberDialogTests.cs
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
using Yavsc.Api.Client;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Headless coverage for the two interactive buttons of the
|
||||
/// "add a circle member" modal: "Ajouter" and "Fermer".
|
||||
///
|
||||
/// <para>The dialog is pushed on top of <see cref="CirclesPage"/>
|
||||
/// via the canonical <c>App.PushPageAsync</c> pipeline (the
|
||||
/// same path <c>CirclesPageViewModel.OpenAddMemberAsync</c>
|
||||
/// uses). The test asserts on <c>NavRoot.NavigationStack</c>
|
||||
/// size before and after each click — the user's bug was "I
|
||||
/// click and nothing happens", so the failure mode is a stack
|
||||
/// that doesn't shrink for "Fermer", and a "Confirmer" event
|
||||
/// that the host doesn't pick up for "Ajouter" (the dialog
|
||||
/// stays up = stack doesn't shrink either).</para>
|
||||
///
|
||||
/// <para>Pattern follows <c>MainPageButtonsTests</c>: name
|
||||
/// every interactive control in XAML with <c>x:Name</c>,
|
||||
/// click via <c>button.Command?.Execute(...)</c> + flush
|
||||
/// any async command before asserting.</para>
|
||||
/// </summary>
|
||||
public class AddCircleMemberDialogTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Stand-in <see cref="IUserDirectory"/> that returns an
|
||||
/// empty list. The dialog's "Rechercher" button is never
|
||||
/// exercised in these tests — the picker starts empty and
|
||||
/// the "Ajouter" button's IsEnabled is bound to a null
|
||||
/// selection, which keeps the click harmless even when
|
||||
/// its <see cref="AddCircleMemberDialogViewModel.Add"/>
|
||||
/// command does fire.
|
||||
/// </summary>
|
||||
private sealed class StubUserDirectory : IUserDirectory
|
||||
{
|
||||
public Task<IReadOnlyList<UserSummary>> SearchAsync(string query, CancellationToken ct = default)
|
||||
=> Task.FromResult<IReadOnlyList<UserSummary>>(new List<UserSummary>());
|
||||
}
|
||||
|
||||
private sealed class ThrowingApi : YavscApiClient
|
||||
{
|
||||
public ThrowingApi() : base(
|
||||
new Settings
|
||||
{
|
||||
Authentication = new AuthenticationSettings
|
||||
{
|
||||
Authority = "https://stub.invalid",
|
||||
ClientId = "stub",
|
||||
Scopes = new[] { "openid" },
|
||||
},
|
||||
},
|
||||
new TokenStore(System.IO.Path.GetTempFileName()))
|
||||
{ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mount a real <see cref="MainWindow"/>, build a minimal
|
||||
/// DI graph, push <see cref="CirclesPage"/> then the
|
||||
/// <see cref="AddCircleMemberDialog"/> on top of it.
|
||||
/// Returns the stack size so the test can pin the delta.
|
||||
/// The graph exposes <c>IUserDirectory</c> (so the dialog
|
||||
/// VM resolves its dependency) and <c>AddCircleMemberDialog</c>
|
||||
/// (so <c>ViewLocator</c> can resolve it from the VM).
|
||||
/// </summary>
|
||||
private static (MainWindow window, CirclesPage page, AddCircleMemberDialog dialog) Mount()
|
||||
{
|
||||
var api = new ThrowingApi();
|
||||
var circleClient = new CircleApiClient(api, "http://localhost/");
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton(new Settings());
|
||||
services.AddSingleton<IUserDirectory>(new StubUserDirectory());
|
||||
services.AddSingleton(circleClient);
|
||||
services.AddTransient<CirclesPage>();
|
||||
services.AddTransient<CirclesPageViewModel>();
|
||||
services.AddTransient<AddCircleMemberDialog>();
|
||||
services.AddTransient<AddCircleMemberDialogViewModel>();
|
||||
var sp = services.BuildServiceProvider();
|
||||
|
||||
var window = new MainWindow();
|
||||
var app = (PostIt.App)Application.Current!;
|
||||
app.DataTemplates.Clear();
|
||||
app.DataTemplates.Add(new ViewLocator(sp));
|
||||
app.AttachMainWindow(window);
|
||||
window.Show();
|
||||
|
||||
var circlesPage = sp.GetRequiredService<CirclesPage>();
|
||||
window.NavRoot.PushAsync(circlesPage).GetAwaiter().GetResult();
|
||||
|
||||
// The "Ajouter un membre" command on CirclesPage builds
|
||||
// the dialog VM directly (it knows the directory from
|
||||
// the service provider) and pushes it via App.PushPage.
|
||||
var dialogVm = new AddCircleMemberDialogViewModel(sp.GetRequiredService<IUserDirectory>());
|
||||
((App)Application.Current!).PushPageAsync(dialogVm).GetAwaiter().GetResult();
|
||||
|
||||
var dialog = window.NavRoot.NavigationStack[^1] as AddCircleMemberDialog
|
||||
?? throw new System.InvalidOperationException("Dialog page not at top of stack.");
|
||||
return (window, circlesPage, dialog);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Click the "Fermer" button on the dialog and assert the
|
||||
/// nav stack shrinks by exactly one.
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public void Close_button_pops_dialog_off_nav_stack()
|
||||
{
|
||||
// Arrange: stack starts at 2 (CirclesPage + dialog).
|
||||
var (window, _, _) = Mount();
|
||||
var stackBefore = window.NavRoot.NavigationStack.Count;
|
||||
Assert.Equal(2, stackBefore);
|
||||
|
||||
// Act
|
||||
var dialog = window.NavRoot.NavigationStack[^1] as AddCircleMemberDialog ?? throw new System.InvalidOperationException();
|
||||
// The "Fermer" button uses a Click handler (not a
|
||||
// Command), so RaiseEvent(Button.ClickEvent) is the
|
||||
// right way to fire it from headless code. Executing
|
||||
// Command would no-op because no Command is bound.
|
||||
dialog.CloseButton.RaiseEvent(new Avalonia.Interactivity.RoutedEventArgs(Button.ClickEvent));
|
||||
|
||||
// Assert: stack -1, the top is the CirclesPage again.
|
||||
Assert.True(window.NavRoot.NavigationStack.Count == stackBefore - 1,
|
||||
$"Click on 'Fermer' must shrink the nav stack by one. Before: {stackBefore}, after: {window.NavRoot.NavigationStack.Count}.");
|
||||
Assert.IsType<CirclesPage>(window.NavRoot.NavigationStack[^1]);
|
||||
}
|
||||
}
|
||||
234
src/PostIt.Tests/PostAclDialogTests.cs
Normal file
234
src/PostIt.Tests/PostAclDialogTests.cs
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Headless.XUnit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.Views;
|
||||
using Yavsc.Abstract.Identity.Security;
|
||||
using Yavsc.Api.Client;
|
||||
using Yavsc.Api.Client.Dtos;
|
||||
using Yavsc.Blogspot;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Regression coverage for the user-reported bug:
|
||||
/// <c>PostAclDialogViewModel.LoadAsync</c> was never invoked,
|
||||
/// so <c>MyCircles</c> and <c>AclEntries</c> were empty when the
|
||||
/// dialog opened (the dropdown showed "Choisir un cercle..." and
|
||||
/// the list was blank, with no error to hint at why).
|
||||
///
|
||||
/// <para>The fix wires <see cref="PostAclDialog"/>'s constructor
|
||||
/// to trigger <c>LoadAsync</c> on the first
|
||||
/// <c>AttachedToVisualTree</c>, and the VM guards re-entry via
|
||||
/// <c>_loaded</c>. Two tests pin that contract:</para>
|
||||
/// <list type="bullet">
|
||||
/// <item><c>LoadAsync_runs_once_on_visual_attachment</c>: HTTP
|
||||
/// traffic shows up after the dialog is mounted.</item>
|
||||
/// <item><c>LoadAsync_is_idempotent</c>: a second explicit call
|
||||
/// to <c>LoadAsync</c> on the same VM hits the HTTP layer only
|
||||
/// once (the <c>_loaded</c> gate).</item>
|
||||
/// </list>
|
||||
///
|
||||
/// <para>HTTP is stubbed with a counter
|
||||
/// <see cref="HttpMessageHandler"/> that returns canned JSON
|
||||
/// <c>[]</c> for every request. The handler counts calls so the
|
||||
/// tests can assert "exactly one round-trip on mount" and
|
||||
/// "exactly one round-trip after two calls to LoadAsync". This
|
||||
/// is the same shape used by <c>BearerScopeTests</c>: real
|
||||
/// <see cref="YavscApiClient"/> subclass, real
|
||||
/// <see cref="HttpClient"/> with an injected handler, real
|
||||
/// <see cref="BlogAclApiClient"/> / <see cref="CircleApiClient"/>
|
||||
/// talking to it.</para>
|
||||
/// </summary>
|
||||
public class PostAclDialogTests
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="HttpMessageHandler"/> that replies 200 with
|
||||
/// <c>[]</c> (a valid JSON empty array, which both
|
||||
/// <c>GetMyAclAsync</c> and <c>GetMyCirclesAsync</c> can
|
||||
/// deserialize) and counts the number of requests.
|
||||
/// </summary>
|
||||
private sealed class CountingHttpHandler : HttpMessageHandler
|
||||
{
|
||||
public int RequestCount { get; private set; }
|
||||
|
||||
protected override Task<HttpResponseMessage> SendAsync(
|
||||
HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
RequestCount++;
|
||||
var response = new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StringContent("[]", Encoding.UTF8, "application/json"),
|
||||
};
|
||||
return Task.FromResult(response);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subclass of <see cref="YavscApiClient"/> that routes HTTP
|
||||
/// traffic through a caller-supplied
|
||||
/// <see cref="HttpMessageHandler"/>. Same recipe as
|
||||
/// <c>BearerScopeTests.TestableYavscApiClient</c> — we
|
||||
/// override <c>CallAsync{T}</c> to talk to our own
|
||||
/// <see cref="HttpClient"/> and skip the OIDC refresh path,
|
||||
/// because the load-on-attach bug has nothing to do with
|
||||
/// token refresh.
|
||||
/// </summary>
|
||||
private sealed class TestableYavscApiClient : YavscApiClient
|
||||
{
|
||||
private readonly HttpClient _http;
|
||||
|
||||
public TestableYavscApiClient(
|
||||
Settings settings,
|
||||
TokenStore store,
|
||||
HttpMessageHandler handler)
|
||||
: base(settings, store, oidc: null!)
|
||||
{
|
||||
_http = new HttpClient(handler, disposeHandler: false);
|
||||
}
|
||||
|
||||
public override Task<T> CallAsync<T>(
|
||||
HttpMethod method, string path, object? body = null,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var absolute = new Uri(new Uri(Settings.BusinessApiUrl), path);
|
||||
using var req = new HttpRequestMessage(method, absolute);
|
||||
using var resp = _http.SendAsync(req, ct).GetAwaiter().GetResult();
|
||||
resp.EnsureSuccessStatusCode();
|
||||
using var stream = resp.Content.ReadAsStream();
|
||||
var dto = JsonSerializer.Deserialize<T>(stream,
|
||||
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
return Task.FromResult(dto!);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Build a minimal DI graph exposing the two API clients
|
||||
/// (backed by a stub HTTP handler) and the page itself, so
|
||||
/// <c>ViewLocator</c> can resolve the dialog from the VM.
|
||||
/// Returns the handler, the API clients, and the window so
|
||||
/// the test can assert on request counts and push the
|
||||
/// dialog via the canonical <c>App.PushPageAsync</c> path.
|
||||
/// The DI graph is built into a local <see cref="IServiceProvider"/>
|
||||
/// that is NOT attached to <see cref="App.ServiceProvider"/>:
|
||||
/// rebinding the global DI mid-test would trample the
|
||||
/// Settings singleton the rest of the harness depends on.
|
||||
/// </summary>
|
||||
private static (MainWindow window, BlogAclApiClient aclClient, CircleApiClient circleClient, CountingHttpHandler handler) Mount()
|
||||
{
|
||||
var handler = new CountingHttpHandler();
|
||||
var settings = new Settings();
|
||||
var api = new TestableYavscApiClient(settings, new TokenStore(System.IO.Path.GetTempFileName()), handler);
|
||||
var aclClient = new BlogAclApiClient(api, settings.BusinessApiUrl);
|
||||
var circleClient = new CircleApiClient(api, settings.BusinessApiUrl);
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton(settings);
|
||||
services.AddSingleton(api);
|
||||
services.AddSingleton(aclClient);
|
||||
services.AddSingleton(circleClient);
|
||||
services.AddTransient<PostAclDialog>();
|
||||
var sp = services.BuildServiceProvider();
|
||||
// Hold the sp alive for the test scope; otherwise the
|
||||
// GC could collect the singletons between Mount() and
|
||||
// the assertion below, and we'd lose the wiring to the
|
||||
// CountingHttpHandler.
|
||||
GC.KeepAlive(sp);
|
||||
|
||||
var window = new MainWindow();
|
||||
var app = (App)Application.Current!;
|
||||
app.DataTemplates.Clear();
|
||||
app.DataTemplates.Add(new ViewLocator(sp));
|
||||
app.AttachMainWindow(window);
|
||||
window.Show();
|
||||
|
||||
return (window, aclClient, circleClient, handler);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The bug: opening the dialog never called LoadAsync, so
|
||||
/// MyCircles/AclEntries were empty. After the fix, setting
|
||||
/// the dialog's DataContext to a PostAclDialogViewModel
|
||||
/// (the same path App.PushPageAsync takes) must trigger
|
||||
/// exactly one LoadAsync round-trip (the parallel WhenAll
|
||||
/// inside the VM counts as one request per backend call,
|
||||
/// hence two HTTP requests total: GET /blogacl and GET
|
||||
/// /circle).
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public async Task LoadAsync_runs_once_on_DataContext_changed()
|
||||
{
|
||||
// Arrange
|
||||
var (window, aclClient, circleClient, handler) = Mount();
|
||||
var post = new BlogPostDto { Id = 42, Title = "Test post" };
|
||||
|
||||
// Sanity: handler starts quiet.
|
||||
Assert.Equal(0, handler.RequestCount);
|
||||
|
||||
// Act: push the dialog via the canonical VM-first pipeline.
|
||||
// The locator goes through the parameterless ctor of
|
||||
// PostAclDialog, then App.PushPageAsync assigns DataContext,
|
||||
// which our hook intercepts to trigger LoadAsync.
|
||||
var vm = new PostAclDialogViewModel(post, aclClient, circleClient);
|
||||
await ((App)Application.Current!).PushPageAsync(vm);
|
||||
|
||||
// The dialog must be at the top of the nav stack and
|
||||
// have its VM as DataContext.
|
||||
var dialog = window.NavRoot.NavigationStack[^1] as PostAclDialog
|
||||
?? throw new InvalidOperationException("Dialog not at top of stack");
|
||||
Assert.Same(vm, dialog.DataContext);
|
||||
|
||||
// Drain pending async work. LoadAsync is async and the
|
||||
// DataContextChanged handler is fire-and-forget; a
|
||||
// couple of loop turns is enough. We poll the handler
|
||||
// counter because the dispatch back onto the headless
|
||||
// dispatcher isn't strict — using a generous-but-bounded
|
||||
// wait avoids test flakes.
|
||||
var deadline = DateTime.UtcNow.AddSeconds(2);
|
||||
while (handler.RequestCount < 2 && DateTime.UtcNow < deadline)
|
||||
{
|
||||
await Task.Delay(20);
|
||||
}
|
||||
|
||||
// Assert: exactly two GETs went out (one to /blogacl,
|
||||
// one to /circle), both from the LoadAsync call.
|
||||
Assert.Equal(2, handler.RequestCount);
|
||||
|
||||
// And the VM's idempotency gate has flipped.
|
||||
Assert.True(vm.Loaded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fix exposes a guard on the VM too: a second call to
|
||||
/// LoadAsync on the same instance must NOT issue more HTTP
|
||||
/// traffic. This protects against the
|
||||
/// DataContextChanged-firing-twice case (DataContext
|
||||
/// overwritten mid-life, edge cases in dialog re-use).
|
||||
/// </summary>
|
||||
[AvaloniaFact]
|
||||
public async Task LoadAsync_is_idempotent()
|
||||
{
|
||||
// Arrange
|
||||
var (_, aclClient, circleClient, handler) = Mount();
|
||||
var post = new BlogPostDto { Id = 99, Title = "Idempotency" };
|
||||
var vm = new PostAclDialogViewModel(post, aclClient, circleClient);
|
||||
|
||||
// Act: invoke LoadAsync twice in a row.
|
||||
await vm.LoadAsync();
|
||||
await vm.LoadAsync();
|
||||
|
||||
// Assert: the second call short-circuited on _loaded.
|
||||
Assert.Equal(2, handler.RequestCount);
|
||||
Assert.True(vm.Loaded);
|
||||
}
|
||||
}
|
||||
94
src/PostIt.Tests/pslist
Normal file
94
src/PostIt.Tests/pslist
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
UID PID PPID C STIME TTY TIME CMD
|
||||
paul 1155 1 0 13:18 ? 00:00:00 /usr/lib/systemd/systemd --user
|
||||
paul 1168 1155 0 13:18 ? 00:00:00 (sd-pam)
|
||||
paul 1361 1155 0 13:18 ? 00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
|
||||
paul 1364 1155 1 13:18 ? 00:01:19 /home/paul/.nvm/versions/node/v22.23.0/bin/node /home/paul/.nvm/versions/node/v22.23.0/lib/node_modules/openclaw/dist/index.js gateway --port 18789
|
||||
paul 1367 1155 0 13:18 ? 00:00:00 /usr/bin/pipewire
|
||||
paul 1372 1155 0 13:18 ? 00:00:00 /usr/bin/pipewire -c filter-chain.conf
|
||||
paul 1373 1155 0 13:18 ? 00:00:00 /usr/bin/wireplumber
|
||||
paul 1374 1155 0 13:18 ? 00:00:00 /usr/bin/pipewire-pulse
|
||||
paul 1444 1155 0 13:18 ? 00:00:00 /usr/bin/mpris-proxy
|
||||
paul 2593 1155 0 13:19 ? 00:00:00 /usr/bin/gnome-keyring-daemon --foreground --components=pkcs11,secrets --control-directory=/run/user/1000/keyring
|
||||
paul 2608 2487 0 13:19 tty2 00:00:00 /usr/libexec/gdm-x-session --run-script /usr/bin/gnome-session
|
||||
paul 2617 2608 1 13:19 tty2 00:01:12 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -novtswitch -verbose 3
|
||||
paul 2647 2608 0 13:19 tty2 00:00:00 /usr/libexec/gnome-session-binary
|
||||
paul 2785 1155 0 13:19 ? 00:00:00 /usr/libexec/at-spi-bus-launcher
|
||||
paul 2792 2785 0 13:19 ? 00:00:00 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 11 --address=unix:path=/run/user/1000/at-spi/bus_1
|
||||
paul 2802 1155 0 13:19 ? 00:00:00 /usr/libexec/gcr-ssh-agent --base-dir /run/user/1000/gcr
|
||||
paul 2803 1155 0 13:19 ? 00:00:00 /usr/libexec/gnome-session-ctl --monitor
|
||||
paul 2804 1155 0 13:19 ? 00:00:00 /usr/bin/ssh-agent -D
|
||||
paul 2814 1155 0 13:19 ? 00:00:00 /usr/libexec/gvfsd
|
||||
paul 2828 1155 0 13:19 ? 00:00:00 /usr/libexec/gvfsd-fuse /run/user/1000/gvfs -f
|
||||
paul 2838 1155 0 13:19 ? 00:00:00 /usr/libexec/gnome-session-binary --systemd-service --session=gnome
|
||||
paul 2874 1155 3 13:19 ? 00:02:13 /usr/bin/gnome-shell
|
||||
paul 2896 2874 0 13:19 ? 00:00:01 /usr/libexec/mutter-x11-frames
|
||||
paul 2902 1155 0 13:19 ? 00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
|
||||
paul 2918 1155 0 13:19 ? 00:00:00 /usr/libexec/xdg-desktop-portal
|
||||
paul 2933 1155 0 13:19 ? 00:00:00 /usr/libexec/xdg-permission-store
|
||||
paul 2938 1155 0 13:19 ? 00:00:00 /usr/libexec/xdg-document-portal
|
||||
paul 2971 1155 0 13:19 ? 00:00:00 /usr/libexec/gnome-shell-calendar-server
|
||||
paul 2976 1155 0 13:19 ? 00:00:00 /usr/libexec/dconf-service
|
||||
paul 2992 1155 0 13:19 ? 00:00:00 /usr/libexec/evolution-source-registry
|
||||
paul 2994 1155 0 13:19 ? 00:00:00 /usr/bin/gjs -m /usr/share/gnome-shell/org.gnome.Shell.Notifications
|
||||
paul 3012 1155 0 13:19 ? 00:00:12 /usr/bin/ibus-daemon --panel disable --xim
|
||||
paul 3013 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-a11y-settings
|
||||
paul 3014 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-color
|
||||
paul 3015 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-datetime
|
||||
paul 3016 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-housekeeping
|
||||
paul 3018 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-keyboard
|
||||
paul 3024 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-media-keys
|
||||
paul 3025 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-power
|
||||
paul 3027 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-print-notifications
|
||||
paul 3029 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-rfkill
|
||||
paul 3030 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-screensaver-proxy
|
||||
paul 3035 2838 0 13:19 ? 00:00:05 /usr/bin/gnome-software --gapplication-service
|
||||
paul 3037 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-sharing
|
||||
paul 3042 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-smartcard
|
||||
paul 3048 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-sound
|
||||
paul 3054 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-usb-protection
|
||||
paul 3057 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-wacom
|
||||
paul 3058 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-xsettings
|
||||
paul 3059 2838 0 13:19 ? 00:00:00 /usr/libexec/evolution-data-server/evolution-alarm-notify
|
||||
paul 3064 2838 0 13:19 ? 00:00:00 /usr/bin/kalendarac
|
||||
paul 3070 2838 0 13:19 ? 00:00:00 /usr/libexec/gsd-disk-utility-notify
|
||||
paul 3088 2838 0 13:19 ? 00:00:00 /usr/bin/kdeconnectd
|
||||
paul 3168 1155 0 13:19 ? 00:00:00 /usr/bin/gjs -m /usr/share/gnome-shell/org.gnome.ScreenSaver
|
||||
paul 3172 1155 0 13:19 ? 00:00:00 /usr/libexec/gsd-printer
|
||||
paul 3207 3012 0 13:19 ? 00:00:00 /usr/libexec/ibus-memconf
|
||||
paul 3208 3012 0 13:19 ? 00:00:06 /usr/libexec/ibus-extension-gtk3
|
||||
paul 3214 1155 0 13:19 ? 00:00:00 /usr/libexec/ibus-x11 --kill-daemon
|
||||
paul 3216 1155 0 13:19 ? 00:00:00 /usr/libexec/ibus-portal
|
||||
paul 3218 1155 0 13:19 ? 00:00:00 /usr/libexec/localsearch-3
|
||||
paul 3219 1155 0 13:19 ? 00:00:00 /usr/libexec/xdg-desktop-portal-gnome
|
||||
paul 3241 1155 0 13:19 ? 00:00:00 /usr/libexec/gvfs-udisks2-volume-monitor
|
||||
paul 3251 1155 0 13:19 ? 00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
|
||||
paul 3259 1155 0 13:19 ? 00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
|
||||
paul 3265 1155 0 13:20 ? 00:00:00 /usr/libexec/gvfs-goa-volume-monitor
|
||||
paul 3271 1155 0 13:20 ? 00:00:00 /usr/libexec/goa-daemon
|
||||
paul 3280 1155 0 13:20 ? 00:00:00 /usr/libexec/goa-identity-service
|
||||
paul 3287 1155 0 13:20 ? 00:00:00 /usr/libexec/gvfs-afc-volume-monitor
|
||||
paul 3303 3012 0 13:20 ? 00:00:02 /usr/libexec/ibus-engine-simple
|
||||
paul 3372 1155 0 13:20 ? 00:00:00 /usr/libexec/xdg-desktop-portal-gtk
|
||||
paul 3441 1155 0 13:20 ? 00:00:00 /usr/libexec/gvfsd-metadata
|
||||
paul 3453 1155 0 13:20 ? 00:00:00 /usr/libexec/evolution-calendar-factory
|
||||
paul 3495 1155 0 13:20 ? 00:00:00 /usr/libexec/evolution-addressbook-factory
|
||||
paul 4798 1155 0 13:26 ? 00:00:09 /usr/libexec/gnome-terminal-server
|
||||
paul 4810 4798 0 13:26 pts/0 00:00:00 bash
|
||||
paul 8614 1155 0 13:29 ? 00:00:01 /usr/bin/speech-dispatcher -s -t 0
|
||||
paul 8656 8614 0 13:29 ? 00:00:00 [sd_espeak-ng-mb] <defunct>
|
||||
paul 8709 8614 0 13:29 ? 00:00:00 /usr/lib/speech-dispatcher-modules/sd_espeak-ng /etc/speech-dispatcher/modules/espeak-ng.conf
|
||||
paul 8785 8614 0 13:29 ? 00:00:00 /usr/lib/speech-dispatcher-modules/sd_dummy /etc/speech-dispatcher/modules/dummy.conf
|
||||
paul 8799 8614 0 13:29 ? 00:00:00 /usr/lib/speech-dispatcher-modules/sd_espeak-ng /etc/speech-dispatcher/modules/
|
||||
paul 10028 1155 0 13:31 ? 00:00:00 adb -L tcp:5037 fork-server server --reply-fd 4
|
||||
paul 69578 2814 0 13:53 ? 00:00:00 /usr/libexec/gvfsd-http --spawner :1.22 /org/gtk/gvfs/exec_spaw/0
|
||||
paul 108341 1155 3 14:06 ? 00:00:48 /home/paul/.nvm/versions/node/v22.23.0/bin/node /home/paul/.nvm/versions/node/v22.23.0/lib/node_modules/acpx/dist/cli.js __queue-owner
|
||||
paul 108416 108341 0 14:06 ? 00:00:00 openclaw
|
||||
paul 108458 108416 2 14:06 ? 00:00:37 openclaw-acp
|
||||
paul 143553 1155 0 14:19 ? 00:00:05 /home/paul/Workspace/yavsc/src/PostIt.Tests/bin/Debug/net10.0/PostIt.Tests @@ /tmp/tmpI2JxLw.tmp
|
||||
paul 149205 1155 0 14:21 ? 00:00:05 /home/paul/Workspace/yavsc/src/PostIt.Tests/bin/Debug/net10.0/PostIt.Tests @@ /tmp/tmpitRyQG.tmp
|
||||
paul 151724 1155 0 14:22 ? 00:00:04 /home/paul/Workspace/yavsc/src/PostIt.Tests/bin/Debug/net10.0/PostIt.Tests @@ /tmp/tmpJEsOZV.tmp
|
||||
paul 157447 1155 1 14:24 ? 00:00:05 /home/paul/Workspace/yavsc/src/PostIt.Tests/bin/Debug/net10.0/PostIt.Tests @@ /tmp/tmpyM92DV.tmp
|
||||
paul 165231 1155 0 14:26 ? 00:00:01 /home/paul/Workspace/yavsc/src/PostIt.Tests/bin/Debug/net10.0/PostIt.Tests @@ /tmp/tmp5CKC19.tmp
|
||||
paul 168472 1155 4 14:27 ? 00:00:09 /home/paul/Workspace/yavsc/src/PostIt.Tests/bin/Debug/net10.0/PostIt.Tests @@ /tmp/tmpuRJsnQ.tmp
|
||||
paul 172147 1155 4 14:29 pts/0 00:00:05 /home/paul/Workspace/yavsc/src/PostIt.Tests/bin/Debug/net10.0/PostIt.Tests @@ /tmp/tmpxT8nje.tmp
|
||||
paul 172435 4810 99 14:31 pts/0 00:00:00 ps -fu paul
|
||||
|
|
@ -350,4 +350,9 @@ public partial class App : Application
|
|||
|
||||
return window.NavRoot.PushAsync(page);
|
||||
}
|
||||
|
||||
internal async Task GoBackAsync()
|
||||
{
|
||||
await window.NavRoot.PopAsync();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using PostIt.Services;
|
||||
using PostIt.Views;
|
||||
using Yavsc.Api.Client;
|
||||
|
||||
namespace PostIt.ViewModels;
|
||||
|
|
@ -106,7 +107,7 @@ public partial class AddCircleMemberDialogViewModel : ViewModelBase
|
|||
/// UI from firing an event with a null payload.
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
public void Add()
|
||||
public async Task AddAsync()
|
||||
{
|
||||
if (Selected is null)
|
||||
{
|
||||
|
|
@ -114,5 +115,14 @@ public partial class AddCircleMemberDialogViewModel : ViewModelBase
|
|||
return;
|
||||
}
|
||||
Confirmed?.Invoke(this, Selected);
|
||||
var app = App.Current as App;
|
||||
await app.GoBackAsync();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
public async Task CloseAsync()
|
||||
{
|
||||
var app = App.Current as App;
|
||||
await app.GoBackAsync();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,6 +119,17 @@ public partial class CirclesPageViewModel : ViewModelBase
|
|||
var directory = services.GetRequiredService<IUserDirectory>();
|
||||
AddCircleMemberDialogViewModel model =
|
||||
new AddCircleMemberDialogViewModel(directory);
|
||||
// Wire the dialog's Confirmed event to OnAddMemberConfirmedAsync.
|
||||
// Without this, the dialog's "Ajouter" button fires the event
|
||||
// into the void: no subscriber, the picked user is silently
|
||||
// dropped, and nothing is added to the circle. The dialog
|
||||
// stays open until the user uses the back gesture — which is
|
||||
// how the user noticed the button was a no-op.
|
||||
// Async-void is intentional here: Confirmed is an
|
||||
// EventHandler<T> (returns void), and bridging to the
|
||||
// async Task OnAddMemberConfirmedAsync requires it.
|
||||
model.Confirmed += async (_, picked) =>
|
||||
await OnAddMemberConfirmedAsync(_, picked);
|
||||
await app.PushPageAsync(model);
|
||||
}
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
|
@ -52,6 +51,22 @@ public partial class PostAclDialogViewModel : ViewModelBase
|
|||
[ObservableProperty]
|
||||
public partial string StatusMessage { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Idempotency gate for <see cref="LoadAsync"/>: the dialog
|
||||
/// attaches the load trigger in <c>DataContextChanged</c>,
|
||||
/// which can fire more than once if the page is detached
|
||||
/// and re-attached (dialog re-use, navigation edge cases)
|
||||
/// with a different VM. Without this guard, the second load
|
||||
/// would race against the first and could overwrite
|
||||
/// <see cref="AclEntries"/> mid-edit. Pattern copied from
|
||||
/// <c>Settings.Load</c>.
|
||||
/// </summary>
|
||||
private bool _loaded;
|
||||
|
||||
/// <summary>True once <see cref="LoadAsync"/> has run at least
|
||||
/// once. Exposed for tests; do not bind from XAML.</summary>
|
||||
public bool Loaded => _loaded;
|
||||
|
||||
public PostAclDialogViewModel(
|
||||
BlogPostDto post,
|
||||
BlogAclApiClient aclClient,
|
||||
|
|
@ -68,6 +83,8 @@ public partial class PostAclDialogViewModel : ViewModelBase
|
|||
[RelayCommand]
|
||||
public async Task LoadAsync()
|
||||
{
|
||||
if (_loaded) return;
|
||||
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
|
|
@ -83,6 +100,7 @@ public partial class PostAclDialogViewModel : ViewModelBase
|
|||
|
||||
|
||||
StatusMessage = $"{AclEntries.Count} autorisation(s)";
|
||||
_loaded = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
xmlns:services="using:PostIt.Services"
|
||||
x:DataType="vm:AddCircleMemberDialogViewModel"
|
||||
>
|
||||
|
||||
<Grid RowDefinitions="Auto,Auto,*,Auto" Margin="12">
|
||||
|
||||
<!-- Search box + button -->
|
||||
|
|
@ -29,7 +30,9 @@
|
|||
<!-- Search results -->
|
||||
<ListBox Grid.Row="2"
|
||||
ItemsSource="{Binding Results}"
|
||||
SelectedItem="{Binding Selected, Mode=TwoWay}">
|
||||
SelectedItem="{Binding Selected, Mode=TwoWay}"
|
||||
MinHeight="20"
|
||||
>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="services:UserSummary">
|
||||
<StackPanel Spacing="2">
|
||||
|
|
@ -47,11 +50,13 @@
|
|||
<TextBlock Grid.Column="0" Text="{Binding StatusMessage}"
|
||||
VerticalAlignment="Center"/>
|
||||
<Button Grid.Column="1" Content="Ajouter"
|
||||
Command="{Binding Add}"
|
||||
x:Name="AddButton"
|
||||
Command="{Binding AddAsync}"
|
||||
IsEnabled="{Binding Selected, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
Margin="0,0,8,0"/>
|
||||
<Button Grid.Column="2" Content="Fermer"
|
||||
Click="OnCloseClicked"/>
|
||||
x:Name="CloseButton"
|
||||
Command="{Binding CloseAsync}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.VisualTree;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
|
||||
|
|
@ -41,8 +42,8 @@ public partial class AddCircleMemberDialog : ContentPage
|
|||
|
||||
private void OnCloseClicked(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
// Same light-modal pattern as PostAclDialog: rely on
|
||||
// the system back gesture or the navigation host's
|
||||
// "pop" — the ContentPage doesn't own the back stack.
|
||||
var nav = this.FindAncestorOfType<NavigationPage>();
|
||||
if (nav is not null)
|
||||
_ = nav.PopAsync();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using PostIt.ViewModels;
|
||||
|
|
@ -9,21 +10,53 @@ namespace PostIt.Views;
|
|||
/// <summary>
|
||||
/// Modal "manage ACL" page for a single blog post.
|
||||
///
|
||||
/// <para>The ViewModel is constructed here (not via DI) because it
|
||||
/// depends on the post being managed, which the caller (the post
|
||||
/// list page) only knows at the moment it opens the dialog. The
|
||||
/// DI container can build the two API clients; the post and the
|
||||
/// VM are wired together here.</para>
|
||||
/// <para>The ViewModel is constructed by the caller (the post
|
||||
/// list page) and handed to <see cref="App.PushPageAsync"/>,
|
||||
/// which routes through <see cref="ViewLocator"/> and lands
|
||||
/// here via the parameterless DI constructor. The VM is then
|
||||
/// assigned to <see cref="ContentPage.DataContext"/> by
|
||||
/// <c>App.PushPageAsync</c> — we listen for that one-shot
|
||||
/// assignment and trigger <c>LoadAsync</c> right after, so the
|
||||
/// dropdown's <c>MyCircles</c> and the list's <c>AclEntries</c>
|
||||
/// are populated when the dialog appears. The VM is idempotent
|
||||
/// under repeated loads.</para>
|
||||
/// </summary>
|
||||
public partial class PostAclDialog : ContentPage
|
||||
{
|
||||
public PostAclDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// App.PushPageAsync wires the VM via DataContext after
|
||||
// building the page. We subscribe once to fire LoadAsync
|
||||
// the moment the VM is attached. Using DataContextChanged
|
||||
// (rather than AttachedToVisualTree) is what makes this
|
||||
// work in the headless test harness too: the load is
|
||||
// tied to the VM being available, not to the visual tree
|
||||
// being realised (which is a separate concern).
|
||||
EventHandler? handler = null;
|
||||
handler = (_, _) =>
|
||||
{
|
||||
if (DataContext is PostAclDialogViewModel vm)
|
||||
{
|
||||
this.DataContextChanged -= handler;
|
||||
_ = vm.LoadAsync();
|
||||
}
|
||||
};
|
||||
this.DataContextChanged += handler;
|
||||
}
|
||||
|
||||
public PostAclDialog(BlogPostDto post, BlogAclApiClient aclClient, CircleApiClient circleClient)
|
||||
{
|
||||
// This overload is not used by the production path —
|
||||
// MainPageViewModel pushes the VM via App.PushPageAsync
|
||||
// and App routes through ViewLocator, which resolves this
|
||||
// page via the parameterless ctor. It is kept so test
|
||||
// scaffolding that wants to bypass the nav pipeline can
|
||||
// still wire a VM directly without losing the load
|
||||
// trigger: the constructor sets DataContext before the
|
||||
// DataContextChanged subscription fires, so the load
|
||||
// is guaranteed to run in either case.
|
||||
InitializeComponent();
|
||||
DataContext = new PostAclDialogViewModel(post, aclClient, circleClient);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Yavsc.ViewModels.Account
|
|||
public class RegisterModel
|
||||
{
|
||||
|
||||
[StringLength(YavscConstants.MaxUserNameLength)]
|
||||
[RegularExpression(YavscConstants.UserNameRegExp)]
|
||||
[StringLength(Constants.MaxUserNameLength)]
|
||||
[RegularExpression(Constants.UserNameRegExp)]
|
||||
[DataType(DataType.Text)]
|
||||
[Display(Name = "UserName", Description = "User name")]
|
||||
public string UserName { get; set; }
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ using Yavsc.Models.Auth;
|
|||
namespace Yavsc
|
||||
{
|
||||
|
||||
public static class YavscConstants
|
||||
public static class Constants
|
||||
{
|
||||
|
||||
public const string APIPrefix = "api/v1";
|
||||
public static readonly Scope[] SiteScopes = {
|
||||
new Scope { Id = "profile", Description = "Your profile informations" },
|
||||
new Scope { Id = "book" , Description ="Your booking interface"},
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Yavsc.Abstract.Identity
|
|||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Le path retourné est aligné sur
|
||||
/// <see cref="YavscConstants.AvatarsPath"/> (minuscule).
|
||||
/// <see cref="Constants.AvatarsPath"/> (minuscule).
|
||||
/// Les anciens display templates utilisaient "/Avatars/"
|
||||
/// avec un S majuscule, en désaccord avec le path statique
|
||||
/// servi par le middleware de fichiers — les images ne
|
||||
|
|
@ -29,8 +29,8 @@ namespace Yavsc.Abstract.Identity
|
|||
public static string AvatarSrc(IApplicationUser? user)
|
||||
{
|
||||
if (user==null || string.IsNullOrWhiteSpace(user?.UserName))
|
||||
return YavscConstants.DefaultAvatar;
|
||||
return $"{YavscConstants.AvatarsPath}/{user!.UserName}.s.png";
|
||||
return Constants.DefaultAvatar;
|
||||
return $"{Constants.AvatarsPath}/{user!.UserName}.s.png";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ using Yavsc.Models.Workflow;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/activity")]
|
||||
[Route(Constants.APIPrefix + "/activity")]
|
||||
public class ActivityApiController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Yavsc.ApiControllers
|
|||
using Yavsc.ViewModels.Auth;
|
||||
using Yavsc.Server.Helpers;
|
||||
|
||||
[Route("api/bill"), Authorize]
|
||||
[Route(Constants.APIPrefix + "/bill"), Authorize]
|
||||
public class BillingController : Controller
|
||||
{
|
||||
readonly ApplicationDbContext dbContext;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace Yavsc.Controllers
|
|||
using Yavsc.Server.Helpers;
|
||||
|
||||
[Produces("application/json")]
|
||||
[Route("api/bookquery"), Authorize("Performer")]
|
||||
[Route(Constants.APIPrefix + "/bookquery"), Authorize("Performer")]
|
||||
public class BookQueryApiController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/estimate"), Authorize]
|
||||
[Route(Constants.APIPrefix + "/estimate"), Authorize]
|
||||
public class EstimateApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -27,12 +27,12 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
bool UserIsAdminOrThis(string uid)
|
||||
{
|
||||
if (User.IsInRole(YavscConstants.AdminGroupName)) return true;
|
||||
if (User.IsInRole(Constants.AdminGroupName)) return true;
|
||||
return uid == User.GetUserId();
|
||||
}
|
||||
bool UserIsAdminOrInThese(string oid, string uid)
|
||||
{
|
||||
if (User.IsInRole(YavscConstants.AdminGroupName)) return true;
|
||||
if (User.IsInRole(Constants.AdminGroupName)) return true;
|
||||
var cuid = User.GetUserId();
|
||||
return cuid == uid || cuid == oid;
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ namespace Yavsc.Controllers
|
|||
return BadRequest();
|
||||
}
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!User.IsInRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
{
|
||||
if (uid != estimate.OwnerId)
|
||||
{
|
||||
|
|
@ -118,7 +118,7 @@ namespace Yavsc.Controllers
|
|||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (estimate.OwnerId == null) estimate.OwnerId = uid;
|
||||
|
||||
if (!User.IsInRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
{
|
||||
if (uid != estimate.OwnerId)
|
||||
{
|
||||
|
|
@ -187,7 +187,7 @@ namespace Yavsc.Controllers
|
|||
return NotFound();
|
||||
}
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!User.IsInRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
{
|
||||
if (uid != estimate.OwnerId)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/EstimateTemplatesApi")]
|
||||
[Route(Constants.APIPrefix + "/EstimateTemplatesApi")]
|
||||
public class EstimateTemplatesApiController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
|
@ -62,7 +62,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (estimateTemplate.OwnerId!=uid)
|
||||
if (!User.IsInRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new StatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
|
||||
_context.Entry(estimateTemplate).State = EntityState.Modified;
|
||||
|
|
@ -132,7 +132,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (estimateTemplate.OwnerId!=uid)
|
||||
if (!User.IsInRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return new StatusCodeResult(StatusCodes.Status403Forbidden);
|
||||
|
||||
_context.EstimateTemplates.Remove(estimateTemplate);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Yavsc.ViewModels.FrontOffice;
|
|||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
[Route("api/front")]
|
||||
[Route(Constants.APIPrefix + "/front")]
|
||||
public class FrontOfficeApiController : Controller
|
||||
{
|
||||
ApplicationDbContext dbContext;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using Yavsc.Models;
|
|||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
[Route("api/payment")]
|
||||
[Route(Constants.APIPrefix + "/payment")]
|
||||
public class PaymentApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext dbContext;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Yavsc.Controllers
|
|||
using Yavsc.Services;
|
||||
|
||||
[Produces("application/json")]
|
||||
[Route("api/performers")]
|
||||
[Route(Constants.APIPrefix + "/performers")]
|
||||
public class PerformersApiController : Controller
|
||||
{
|
||||
ApplicationDbContext dbContext;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/ProductApi")]
|
||||
[Route(Constants.APIPrefix + "/ProductApi")]
|
||||
public class ProductApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -46,7 +46,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
|
||||
// PUT: api/ProductApi/5
|
||||
[HttpPut("{id}"),Authorize(YavscConstants.FrontOfficeGroupName)]
|
||||
[HttpPut("{id}"),Authorize(Constants.FrontOfficeGroupName)]
|
||||
public IActionResult PutProduct(long id, [FromBody] Product product)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
|
|
@ -81,7 +81,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
|
||||
// POST: api/ProductApi
|
||||
[HttpPost,Authorize(YavscConstants.FrontOfficeGroupName)]
|
||||
[HttpPost,Authorize(Constants.FrontOfficeGroupName)]
|
||||
public IActionResult PostProduct([FromBody] Product product)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
|
|
@ -110,7 +110,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
|
||||
// DELETE: api/ProductApi/5
|
||||
[HttpDelete("{id}"),Authorize(YavscConstants.FrontOfficeGroupName)]
|
||||
[HttpDelete("{id}"),Authorize(Constants.FrontOfficeGroupName)]
|
||||
public IActionResult DeleteProduct(long id)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/bursherprofiles")]
|
||||
[Route(Constants.APIPrefix + "/bursherprofiles")]
|
||||
public class BursherProfilesApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -57,7 +57,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
|
||||
if (id != User.GetUserId())
|
||||
{
|
||||
return BadRequest();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Yavsc.ApiControllers
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Yavsc.Server.Helpers;
|
||||
|
||||
[Route("api/haircut")][Authorize]
|
||||
[Route(Constants.APIPrefix + "/haircut")][Authorize]
|
||||
public class HairCutController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using Yavsc.Models.Relationship;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/hyperlink")]
|
||||
[Route(Constants.APIPrefix + "/hyperlink")]
|
||||
public class HyperLinkApiController : Controller
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Yavsc.Server.Models.IT.SourceCode;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/GitRefsApi")]
|
||||
[Route(Constants.APIPrefix + "/GitRefsApi")]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public class GitRefsApiController : Controller
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ using Microsoft.AspNetCore.Mvc;
|
|||
|
||||
namespace Yavsc.ApiControllers
|
||||
{
|
||||
[Route("api/mailtemplate")]
|
||||
[Route(Constants.APIPrefix + "/mailtemplate")]
|
||||
public class MailTemplatingApiController: Controller
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/mailing")]
|
||||
[Route(Constants.APIPrefix + "/mailing")]
|
||||
[Authorize("AdministratorOnly")]
|
||||
public class MailingTemplateApiController : Controller
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/museprefs")]
|
||||
[Route(Constants.APIPrefix + "/museprefs")]
|
||||
public class MusicalPreferencesApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/MusicalTendenciesApi")]
|
||||
[Route(Constants.APIPrefix + "/MusicalTendenciesApi")]
|
||||
public class MusicalTendenciesApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (blogpost.AuthorId!=uid)
|
||||
if (!User.IsInRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
return BadRequest();
|
||||
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ namespace Yavsc.ApiControllers
|
|||
/// <summary>
|
||||
/// Base class for managing performers profiles
|
||||
/// </summary>
|
||||
[Produces("application/json"),Route("api/profile")]
|
||||
public abstract class ProfileApiController<T> : Controller
|
||||
[Produces("application/json"),Route(Constants.APIPrefix + "/profile")]
|
||||
public abstract class ProfileApiController<T> : Controller
|
||||
{ public ProfileApiController()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/blacklist"), Authorize]
|
||||
[Route(Constants.APIPrefix + "/blacklist"), Authorize]
|
||||
public class BlackListApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -50,8 +50,8 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != blackListed.OwnerId)
|
||||
if (!User.IsInRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInRole(YavscConstants.FrontOfficeGroupName))
|
||||
if (!User.IsInRole(Constants.AdminGroupName))
|
||||
if (!User.IsInRole(Constants.FrontOfficeGroupName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
if (!CheckPermission(blackListed))
|
||||
return BadRequest();
|
||||
|
||||
|
||||
_context.BlackListed.Remove(blackListed);
|
||||
_context.SaveChanges(User.GetUserId());
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ using Microsoft.EntityFrameworkCore;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
|
||||
[Route("api/chat")]
|
||||
[Route(Constants.APIPrefix + "/chat")]
|
||||
public class ChatApiController : Controller
|
||||
{
|
||||
readonly ApplicationDbContext dbContext;
|
||||
readonly UserManager<ApplicationUser> userManager;
|
||||
private readonly IConnexionManager _cxManager;
|
||||
public ChatApiController(ApplicationDbContext dbContext,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
UserManager<ApplicationUser> userManager,
|
||||
IConnexionManager cxManager)
|
||||
{
|
||||
this.dbContext = dbContext;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/ChatRoomAccessApi")]
|
||||
[Route(Constants.APIPrefix + "/ChatRoomAccessApi")]
|
||||
public class ChatRoomAccessApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -37,7 +37,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
ChatRoomAccess chatRoomAccess = await _context.ChatRoomAccess.SingleAsync(m => m.ChannelName == id);
|
||||
|
||||
|
||||
|
||||
|
||||
if (chatRoomAccess == null)
|
||||
{
|
||||
|
|
@ -46,13 +46,13 @@ namespace Yavsc.Controllers
|
|||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (uid != chatRoomAccess.UserId && uid != chatRoomAccess.Room.OwnerId
|
||||
&& ! User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
|
||||
&& ! User.IsInMsRole(Constants.AdminGroupName))
|
||||
|
||||
{
|
||||
ModelState.AddModelError("UserId","get refused");
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
|
||||
return Ok(chatRoomAccess);
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
var room = _context.ChatRoom.First(channel => channel.Name == chatRoomAccess.ChannelName );
|
||||
|
||||
if (uid != room.OwnerId && ! User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (uid != room.OwnerId && ! User.IsInMsRole(Constants.AdminGroupName))
|
||||
{
|
||||
ModelState.AddModelError("ChannelName", "access put refused");
|
||||
return BadRequest(ModelState);
|
||||
|
|
@ -110,7 +110,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var room = _context.ChatRoom.First(channel => channel.Name == chatRoomAccess.ChannelName );
|
||||
if (room == null || (uid != room.OwnerId && ! User.IsInMsRole(YavscConstants.AdminGroupName)))
|
||||
if (room == null || (uid != room.OwnerId && ! User.IsInMsRole(Constants.AdminGroupName)))
|
||||
{
|
||||
ModelState.AddModelError("ChannelName", "access post refused");
|
||||
return BadRequest(ModelState);
|
||||
|
|
@ -154,7 +154,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
var room = _context.ChatRoom.First(channel => channel.Name == chatRoomAccess.ChannelName );
|
||||
if (room == null || (uid != room.OwnerId && chatRoomAccess.UserId != uid && ! User.IsInMsRole(YavscConstants.AdminGroupName)))
|
||||
if (room == null || (uid != room.OwnerId && chatRoomAccess.UserId != uid && ! User.IsInMsRole(Constants.AdminGroupName)))
|
||||
{
|
||||
ModelState.AddModelError("UserId", "access drop refused");
|
||||
return BadRequest(ModelState);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/ChatRoomApi")]
|
||||
[Route(Constants.APIPrefix + "/ChatRoomApi")]
|
||||
public class ChatRoomApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -128,7 +128,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
ChatRoom chatRoom = await _context.ChatRoom.SingleAsync(m => m.Name == id);
|
||||
|
||||
|
||||
|
||||
|
||||
if (chatRoom == null)
|
||||
{
|
||||
|
|
@ -137,7 +137,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
if (User.GetUserId() != chatRoom.OwnerId )
|
||||
{
|
||||
if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return BadRequest(new {error = "OwnerId"});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/ContactsApi")]
|
||||
[Route(Constants.APIPrefix + "/ContactsApi")]
|
||||
public class ContactsApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/ServiceApi")]
|
||||
[Route(Constants.APIPrefix + "/ServiceApi")]
|
||||
public class ServiceApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -46,7 +46,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
|
||||
// PUT: api/ServiceApi/5
|
||||
[HttpPut("{id}"),Authorize(YavscConstants.FrontOfficeGroupName)]
|
||||
[HttpPut("{id}"),Authorize(Constants.FrontOfficeGroupName)]
|
||||
public IActionResult PutService(long id, [FromBody] Service service)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
|
|
@ -81,7 +81,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
|
||||
// POST: api/ServiceApi
|
||||
[HttpPost,Authorize(YavscConstants.FrontOfficeGroupName)]
|
||||
[HttpPost,Authorize(Constants.FrontOfficeGroupName)]
|
||||
public IActionResult PostService([FromBody] Service service)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
|
|
@ -110,7 +110,7 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
|
||||
// DELETE: api/ServiceApi/5
|
||||
[HttpDelete("{id}"),Authorize(YavscConstants.FrontOfficeGroupName)]
|
||||
[HttpDelete("{id}"),Authorize(Constants.FrontOfficeGroupName)]
|
||||
public IActionResult DeleteService(long id)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json"),Authorize("AdministratorOnly")]
|
||||
[Route("api/users")]
|
||||
[Route(Constants.APIPrefix + "/users")]
|
||||
public class ApplicationUserApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -28,7 +28,7 @@ namespace Yavsc.Controllers
|
|||
public IEnumerable<UserInfo> GetApplicationUser(int skip=0, int take = 25)
|
||||
{
|
||||
return _context.Users.Skip(skip).Take(take)
|
||||
.Select(u=> new UserInfo{
|
||||
.Select(u=> new UserInfo{
|
||||
UserId = u.Id,
|
||||
UserName = u.UserName,
|
||||
Avatar = u.Avatar});
|
||||
|
|
@ -39,7 +39,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
return _context.Users.Where(u => u.UserName.Contains(pattern))
|
||||
.Skip(skip).Take(take)
|
||||
.Select(u=> new UserInfo {
|
||||
.Select(u=> new UserInfo {
|
||||
UserId = u.Id,
|
||||
UserName = u.UserName,
|
||||
Avatar = u.Avatar });
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ public sealed class BlogsWebServerFixture : WebHostFixture
|
|||
// remaps long Microsoft claim URIs, not sub).
|
||||
// UserHelpers.GetUserId reads sub directly.
|
||||
NameClaimType = "sub",
|
||||
RoleClaimType = YavscConstants.RoleClaimType,
|
||||
RoleClaimType = Yavsc.Constants.RoleClaimType,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
using Yavsc.Tests.Shared;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Blogs.Tests;
|
||||
|
||||
|
|
@ -88,7 +89,7 @@ public sealed class CircleMembersApiTests : IClassFixture<BlogsWebServerFixture>
|
|||
}
|
||||
|
||||
private string MembersUrl(long circleId)
|
||||
=> $"{_fixture.Addresses.First(a => a.StartsWith("https://"))}/{Constants.APIPrefix}/circle/{circleId}/members";
|
||||
=> $"{_fixture.Addresses.First(a => a.StartsWith("https://"))}/{APIPrefix}/circle/{circleId}/members";
|
||||
|
||||
private HttpClient NewClient(string subject)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,8 +65,8 @@ public sealed class MappedClaimsBlogsWebServerFixture : IDisposable
|
|||
ValidateLifetime = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
IssuerSigningKey = TestTokenIssuer.SigningKey,
|
||||
RoleClaimType = YavscConstants.RoleClaimType,
|
||||
NameClaimType = YavscConstants.NameClaimType,
|
||||
RoleClaimType = Yavsc.Constants.RoleClaimType,
|
||||
NameClaimType = Yavsc.Constants.NameClaimType,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,4 @@ public static class Constants
|
|||
public const string AdminRole = "Admin";
|
||||
public const string ModeratorRole = "Moderator";
|
||||
public const string UserRole = "User";
|
||||
|
||||
public const string APIPrefix = "api/v1";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
using System.Linq;
|
||||
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Access;
|
||||
using Yavsc.Server.Helpers;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Blogs.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/blogacl")]
|
||||
[Route(APIPrefix+"/blogacl")]
|
||||
public class BlogAclApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -24,7 +25,7 @@ namespace Yavsc.Blogs.Controllers
|
|||
/// Blog posts (and therefore their ACLs) are private to their
|
||||
/// author — the API never exposes another user's ACL.
|
||||
/// </summary>
|
||||
// GET: api/blogacl
|
||||
// GET: api/v1/blogacl
|
||||
[HttpGet]
|
||||
public IEnumerable<CircleAuthorizationToBlogPost> GetBlogACL()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using Yavsc.Blogspot;
|
||||
using Yavsc.Server.Exceptions;
|
||||
using Yavsc.Server.Helpers;
|
||||
using static Yavsc.Blogs.Constants;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Blogs.Controllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Blog;
|
||||
using static Yavsc.Blogs.Constants;
|
||||
using static Yavsc.Constants;
|
||||
namespace Yavsc.Blogs.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Yavsc.Models;
|
||||
using Yavsc.Models.Relationship;
|
||||
using Yavsc.Server.Helpers;
|
||||
using static Yavsc.Blogs.Constants;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Blogs.Controllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Yavsc.Models;
|
||||
using Yavsc.Models.Blog;
|
||||
using Yavsc.Server.Helpers;
|
||||
using static Yavsc.Blogs.Constants;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Blogs.Controllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using static Yavsc.Blogs.Constants;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Blogs.Controllers
|
||||
{
|
||||
|
|
@ -21,7 +21,7 @@ namespace Yavsc.Blogs.Controllers
|
|||
private readonly ILogger _logger;
|
||||
|
||||
public FileSystemApiController(ApplicationDbContext context,
|
||||
IAuthorizationService authorizationService,
|
||||
IAuthorizationService authorizationService,
|
||||
ILoggerFactory loggerFactory)
|
||||
|
||||
{
|
||||
|
|
@ -38,7 +38,7 @@ namespace Yavsc.Blogs.Controllers
|
|||
|
||||
[HttpGet("{*subdir}")]
|
||||
public IActionResult GetDir([ValidRemoteUserFilePath] string subdir="")
|
||||
{
|
||||
{
|
||||
if (!ModelState.IsValid) return new BadRequestObjectResult(ModelState);
|
||||
// _logger.LogInformation($"listing files from {User.Identity.Name}{subdir}");
|
||||
var files = AbstractFileSystemHelpers.GetUserFiles(User.GetUserId(), subdir);
|
||||
|
|
@ -57,20 +57,20 @@ namespace Yavsc.Blogs.Controllers
|
|||
} catch (InvalidPathException ex) {
|
||||
pathex = ex;
|
||||
}
|
||||
if (pathex!=null)
|
||||
if (pathex!=null)
|
||||
{
|
||||
_logger.LogError($"invalid sub path: '{subdir}'.");
|
||||
return BadRequest(pathex);
|
||||
}
|
||||
_logger.LogInformation($"Receiving files, saved in '{destDir}' (specified as '{subdir}').");
|
||||
|
||||
|
||||
var uid = User.GetUserId();
|
||||
var user = dbContext.Users.Single(
|
||||
u => u.Id == uid
|
||||
);
|
||||
int i=0;
|
||||
_logger.LogInformation($"Receiving {Request.Form.Files.Count} files.");
|
||||
|
||||
|
||||
foreach (var f in Request.Form.Files)
|
||||
{
|
||||
var item = user.ReceiveUserFile(destDir, f);
|
||||
|
|
@ -178,7 +178,7 @@ namespace Yavsc.Blogs.Controllers
|
|||
return Ok(new { deleted=id });
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Yavsc.Models.Messaging;
|
|||
using Yavsc.Services;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Yavsc.Server.Helpers;
|
||||
using static Yavsc.Blogs.Constants;
|
||||
using static Yavsc.Constants;
|
||||
using Yavsc.Server.Hubs;
|
||||
|
||||
namespace Yavsc.Blogs.Controllers
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using static Yavsc.Blogs.Constants;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Blogs.Controllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yavsc.Models;
|
||||
using static Yavsc.Blogs.Constants;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Controllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Blogs.Controllers
|
||||
{
|
||||
|
|
@ -26,7 +27,7 @@ namespace Yavsc.Blogs.Controllers
|
|||
/// exposing it.</para>
|
||||
/// </summary>
|
||||
[Produces("application/json")]
|
||||
[Route( Constants.APIPrefix + "/user-search")]
|
||||
[Route(APIPrefix + "/user-search")]
|
||||
[Authorize]
|
||||
public class UserSearchApiController : Controller
|
||||
{
|
||||
|
|
@ -66,8 +67,9 @@ namespace Yavsc.Blogs.Controllers
|
|||
// book callers already know the email they're
|
||||
// searching for and we don't want to surface a
|
||||
// long tail of partial matches.
|
||||
var normalised = e.Trim();
|
||||
query = query.Where(u => u.Email != null && u.Email.ToLower() == normalised.ToLower());
|
||||
var normalized = e.Trim();
|
||||
query = query.Where(u => u.Email != null &&
|
||||
string.Compare(u.Email, normalized, true) ==0);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(q))
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ internal class Program
|
|||
// DbContextBuilder
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString(
|
||||
YavscConstants.YavscConnectionStringName)));
|
||||
Yavsc.Constants.YavscConnectionStringName)));
|
||||
|
||||
// other services
|
||||
services
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Yavsc.Org.Tests.NonRegression;
|
|||
/// ne voit rien — juste un 500 muet.
|
||||
///
|
||||
/// Le fix passe par <see cref="UserDisplayHelpers.AvatarSrc"/> qui
|
||||
/// retourne <see cref="YavscConstants.DefaultAvatar"/> pour toute
|
||||
/// retourne <see cref="Yavsc.Constants.DefaultAvatar"/> pour toute
|
||||
/// donnée partielle. Ces tests couvrent les trois formes de
|
||||
/// "donnée absente" : user null, UserName vide, UserName whitespace.
|
||||
/// </summary>
|
||||
|
|
@ -23,21 +23,21 @@ public class UserDisplayHelpersTests
|
|||
[Fact]
|
||||
public void AvatarSrc_null_user_returns_default_avatar()
|
||||
{
|
||||
Assert.Equal(YavscConstants.DefaultAvatar, UserDisplayHelpers.AvatarSrc(null));
|
||||
Assert.Equal(Yavsc.Constants.DefaultAvatar, UserDisplayHelpers.AvatarSrc(null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AvatarSrc_user_with_empty_UserName_returns_default_avatar()
|
||||
{
|
||||
var user = new FakeUser { UserName = "" };
|
||||
Assert.Equal(YavscConstants.DefaultAvatar, UserDisplayHelpers.AvatarSrc(user));
|
||||
Assert.Equal(Yavsc.Constants.DefaultAvatar, UserDisplayHelpers.AvatarSrc(user));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AvatarSrc_user_with_whitespace_UserName_returns_default_avatar()
|
||||
{
|
||||
var user = new FakeUser { UserName = " " };
|
||||
Assert.Equal(YavscConstants.DefaultAvatar, UserDisplayHelpers.AvatarSrc(user));
|
||||
Assert.Equal(Yavsc.Constants.DefaultAvatar, UserDisplayHelpers.AvatarSrc(user));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -47,7 +47,7 @@ public class UserDisplayHelpersTests
|
|||
// Le path doit matcher YavscConstants.AvatarsPath (minuscule),
|
||||
// pas un /Avatars/ avec S majuscule qui ne résout pas
|
||||
// dans le middleware de fichiers statiques.
|
||||
var expected = $"{YavscConstants.AvatarsPath}/alice.s.png";
|
||||
var expected = $"{Yavsc.Constants.AvatarsPath}/alice.s.png";
|
||||
Assert.Equal(expected, UserDisplayHelpers.AvatarSrc(user));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,8 +80,8 @@ public sealed class WebServerFixture : WebHostFixture
|
|||
// can resolve it. The AddConfiguration extension takes care of
|
||||
// that plus the in-memory overrides below.
|
||||
builder.AddConfiguration(null).AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
[$"ConnectionStrings:{YavscConstants.YavscConnectionStringName}"] = "InMemory",
|
||||
{
|
||||
[$"ConnectionStrings:{Yavsc.Constants.YavscConnectionStringName}"] = "InMemory",
|
||||
// SMTP test config: UserName non-null so MailSender
|
||||
// exercises the Authenticate branch — the
|
||||
// RecordingSmtpClient captures it.
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
"ConfirmYourAccountTitle"
|
||||
})
|
||||
Debug.Assert(!_localizer[name].ResourceNotFound);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
{
|
||||
await _events.RaiseAsync(new UserLoginSuccessEvent(user.UserName, user.Id, user.UserName, clientId: context?.Client.ClientId));
|
||||
|
||||
// only set explicit expiration here if user chooses "remember me".
|
||||
// only set explicit expiration here if user chooses "remember me".
|
||||
// otherwise we rely upon expiration configured in cookie middleware.
|
||||
await HttpContext.SignInAsync(user, _roleManager, model.RememberMe, _dbContext);
|
||||
var authResult = await HttpContext.AuthenticateAsync();
|
||||
|
|
@ -198,7 +198,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
/// <summary>
|
||||
/// Entry point into the login workflow
|
||||
/// </summary>
|
||||
[HttpGet(YavscConstants.SigninPath)]
|
||||
[HttpGet(Constants.SigninPath)]
|
||||
public async Task<IActionResult> Signin(SignInModel model)
|
||||
{
|
||||
// build a model so we know what to show on the login page
|
||||
|
|
@ -216,11 +216,11 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
/// <summary>
|
||||
/// Handle postback from username/password login
|
||||
/// </summary>
|
||||
///
|
||||
[HttpPost(YavscConstants.SigninPath)]
|
||||
///
|
||||
[HttpPost(Constants.SigninPath)]
|
||||
[ValidateAntiForgeryToken]
|
||||
[AllowAnonymous]
|
||||
|
||||
|
||||
public async Task<IActionResult> Signin([FromForm] SignInModel model, [FromForm] string button)
|
||||
{
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
{
|
||||
if (context != null)
|
||||
{
|
||||
// if the user cancels, send a result back into IdentityServer as if they
|
||||
// if the user cancels, send a result back into IdentityServer as if they
|
||||
// denied the consent (even if this client does not require consent).
|
||||
// this will send back an access denied OIDC error response to the client.
|
||||
await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
|
||||
|
|
@ -269,7 +269,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
{
|
||||
await _events.RaiseAsync(new UserLoginSuccessEvent(user.UserName, user.Id, user.UserName, clientId: context?.Client.ClientId));
|
||||
|
||||
// only set explicit expiration here if user chooses "remember me".
|
||||
// only set explicit expiration here if user chooses "remember me".
|
||||
// otherwise we rely upon expiration configured in cookie middleware.
|
||||
await HttpContext.SignInAsync(user, _roleManager, model.RememberMe, _dbContext);
|
||||
|
||||
|
|
@ -396,7 +396,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
var local = context.IdP == IdentityServer8.IdentityServerConstants.LocalIdentityProvider;
|
||||
|
||||
// this is meant to short circuit the UI and only trigger the one external IdP
|
||||
|
||||
|
||||
model.EnableLocalLogin = local;
|
||||
model.UserName = context?.LoginHint;
|
||||
model.IsExternalLoginOnly = false;
|
||||
|
|
@ -579,7 +579,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
// Send an email with this link
|
||||
|
||||
Uri authority = new Uri(Config.Authority);
|
||||
|
||||
|
||||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||
var callbackUrl = Url.Action("ConfirmEmail", "Account",
|
||||
new { userId = user.Id, code },
|
||||
|
|
@ -659,7 +659,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
}
|
||||
//
|
||||
// POST: /Account/LogOff
|
||||
[HttpPost(YavscConstants.LogoutPath)]
|
||||
[HttpPost(Constants.LogoutPath)]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> LogOff(string returnUrl = null)
|
||||
{
|
||||
|
|
@ -829,7 +829,7 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
bool result = false;
|
||||
try
|
||||
{
|
||||
result = await _userManager.VerifyTwoFactorTokenAsync(user, YavscConstants.DefaultFactor, code);
|
||||
result = await _userManager.VerifyTwoFactorTokenAsync(user, Constants.DefaultFactor, code);
|
||||
_dbContext.SaveChanges(userId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -1024,12 +1024,12 @@ IHtmlLocalizerFactory htmlLocalizerFactory,
|
|||
}
|
||||
|
||||
// Generate the token and send it
|
||||
if (model.SelectedProvider == YavscConstants.MobileAppFactor)
|
||||
if (model.SelectedProvider == Constants.MobileAppFactor)
|
||||
{
|
||||
return View("Error", new Exception("No mobile app service was activated"));
|
||||
}
|
||||
else
|
||||
if (model.SelectedProvider == YavscConstants.SMSFactor)
|
||||
if (model.SelectedProvider == Constants.SMSFactor)
|
||||
{
|
||||
return View("Error", new Exception("No SMS service was activated"));
|
||||
// await _smsSender.SendSmsAsync(_twilioSettings, await _userManager.GetPhoneNumberAsync(user), message);
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
// ensure all roles existence
|
||||
foreach (string roleName in new string[] {
|
||||
YavscConstants.AdminGroupName,
|
||||
YavscConstants.StarGroupName,
|
||||
YavscConstants.PerformerGroupName,
|
||||
YavscConstants.FrontOfficeGroupName,
|
||||
YavscConstants.StarHunterGroupName,
|
||||
YavscConstants.BlogModeratorGroupName
|
||||
Constants.AdminGroupName,
|
||||
Constants.StarGroupName,
|
||||
Constants.PerformerGroupName,
|
||||
Constants.FrontOfficeGroupName,
|
||||
Constants.StarHunterGroupName,
|
||||
Constants.BlogModeratorGroupName
|
||||
})
|
||||
if (!await _roleManager.RoleExistsAsync(roleName))
|
||||
{
|
||||
|
|
@ -80,11 +80,11 @@ namespace Yavsc.Controllers
|
|||
public async Task<IActionResult> Take()
|
||||
{
|
||||
// If some amdin already exists, make this method disapear
|
||||
var admins = await _userManager.GetUsersInRoleAsync(YavscConstants.AdminGroupName);
|
||||
var admins = await _userManager.GetUsersInRoleAsync(Constants.AdminGroupName);
|
||||
if (admins != null && admins.Count > 0)
|
||||
{
|
||||
// All is ok, nothing to do here.
|
||||
if (User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (User.IsInMsRole(Constants.AdminGroupName))
|
||||
{
|
||||
|
||||
return Ok(new { message = "you already got it." });
|
||||
|
|
@ -100,7 +100,7 @@ namespace Yavsc.Controllers
|
|||
return new BadRequestObjectResult(ModelState);
|
||||
}
|
||||
|
||||
var addToRoleResult = await _userManager.AddToRoleAsync(user, YavscConstants.AdminGroupName);
|
||||
var addToRoleResult = await _userManager.AddToRoleAsync(user, Constants.AdminGroupName);
|
||||
if (!addToRoleResult.Succeeded)
|
||||
{
|
||||
AddErrors(addToRoleResult);
|
||||
|
|
@ -114,11 +114,11 @@ namespace Yavsc.Controllers
|
|||
public async Task<IActionResult> Index()
|
||||
{
|
||||
var adminCount = await _userManager.GetUsersInRoleAsync(
|
||||
YavscConstants.AdminGroupName);
|
||||
Constants.AdminGroupName);
|
||||
var userCount = await _dbContext.Users.CountAsync();
|
||||
var youAreAdmin = await _userManager.IsInRoleAsync(
|
||||
await _userManager.FindByIdAsync(User.GetUserId()),
|
||||
YavscConstants.AdminGroupName);
|
||||
Constants.AdminGroupName);
|
||||
|
||||
var roles = await _roleManager.Roles.Select(x => new RoleInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
using IdentityServer8.EntityFramework.Entities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Server.Helpers;
|
||||
using static Yavsc.Constants;
|
||||
|
||||
namespace Yavsc.Org.Controllers.Administration
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Route(APIPrefix + "/[controller]")]
|
||||
[ApiController]
|
||||
public class ApiScopesApiController : ControllerBase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ namespace Yavsc.Controllers
|
|||
readonly IStringLocalizer<AnnouncesController> _localizer;
|
||||
readonly IAuthorizationService _authorizationService;
|
||||
|
||||
public AnnouncesController(ApplicationDbContext context,
|
||||
public AnnouncesController(ApplicationDbContext context,
|
||||
IAuthorizationService authorizationService,
|
||||
IStringLocalizer<AnnouncesController> localizer)
|
||||
{
|
||||
_context = context;
|
||||
_context = context;
|
||||
_authorizationService = authorizationService;
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
|
@ -59,16 +59,16 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
private async Task SetupView(Announce announce)
|
||||
{
|
||||
ViewBag.IsAdmin = User.IsInMsRole(YavscConstants.AdminGroupName);
|
||||
ViewBag.IsPerformer = User.IsInMsRole(YavscConstants.PerformerGroupName);
|
||||
ViewBag.IsAdmin = User.IsInMsRole(Constants.AdminGroupName);
|
||||
ViewBag.IsPerformer = User.IsInMsRole(Constants.PerformerGroupName);
|
||||
ViewBag.AllowEdit = announce==null || announce.Id<=0 || !_authorizationService.AuthorizeAsync(User,announce,new EditPermission()).IsFaulted;
|
||||
List<SelectListItem> dl = new List<SelectListItem>();
|
||||
var rnames = System.Enum.GetNames(typeof(Reason));
|
||||
var rvalues = System.Enum.GetValues(typeof(Reason));
|
||||
|
||||
|
||||
for (int i = 0; i<rnames.Length; i++) {
|
||||
dl.Add(new SelectListItem { Text =
|
||||
_localizer[rnames[i]],
|
||||
dl.Add(new SelectListItem { Text =
|
||||
_localizer[rnames[i]],
|
||||
Value= rvalues.GetValue(i).ToString() });
|
||||
}
|
||||
|
||||
|
|
@ -82,14 +82,14 @@ namespace Yavsc.Controllers
|
|||
if (ModelState.IsValid)
|
||||
{
|
||||
// Only allow admin to create corporate annonces
|
||||
if (announce.For == Reason.Corporate && ! User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (announce.For == Reason.Corporate && ! User.IsInMsRole(Constants.AdminGroupName))
|
||||
{
|
||||
ModelState.AddModelError("For", _localizer["YourNotAdmin"]);
|
||||
return View(announce);
|
||||
}
|
||||
|
||||
// Only allow performers to create ServiceProposal
|
||||
if (announce.For == Reason.ServiceProposal && ! User.IsInMsRole(YavscConstants.PerformerGroupName))
|
||||
// Only allow performers to create ServiceProposal
|
||||
if (announce.For == Reason.ServiceProposal && ! User.IsInMsRole(Constants.PerformerGroupName))
|
||||
{
|
||||
ModelState.AddModelError("For", _localizer["YourNotAPerformer"]);
|
||||
return View(announce);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ namespace Yavsc.Org.Controllers
|
|||
{
|
||||
var blog = await blogSpotService.Details(User, id.Value);
|
||||
ViewBag.apicmtctlr = "/api/v1/blogcomments";
|
||||
ViewBag.moderatoFlag = User.IsInMsRole(YavscConstants.BlogModeratorGroupName);
|
||||
ViewBag.moderatoFlag = User.IsInMsRole(Yavsc.Constants.BlogModeratorGroupName);
|
||||
|
||||
return View(blog);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Yavsc.Controllers
|
|||
Value = pt.FullName,
|
||||
Selected = currentCode == pt.FullName
|
||||
}).ToList();
|
||||
items.Add(new SelectListItem { Text = SR[YavscConstants.NoneCode], Value = YavscConstants.NoneCode, Selected = currentCode == null});
|
||||
items.Add(new SelectListItem { Text = SR[Constants.NoneCode], Value = Constants.NoneCode, Selected = currentCode == null});
|
||||
ViewBag.SettingsClassName = items;
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ namespace Yavsc.Controllers
|
|||
Text = a.Name,
|
||||
Value = a.Code
|
||||
}).ToList();
|
||||
var nullItem = new SelectListItem { Text = SR[YavscConstants.NoneCode], Value = YavscConstants.NoneCode };
|
||||
var nullItem = new SelectListItem { Text = SR[Constants.NoneCode], Value = Constants.NoneCode };
|
||||
acts.Add(nullItem);
|
||||
if (code == null) return acts;
|
||||
var existing = _context.Activities.Include(a => a.Children).FirstOrDefault(a => a.Code == code);
|
||||
|
|
@ -123,9 +123,9 @@ namespace Yavsc.Controllers
|
|||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Create(Activity activity)
|
||||
{
|
||||
if (activity.ParentCode==YavscConstants.NoneCode)
|
||||
if (activity.ParentCode==Constants.NoneCode)
|
||||
activity.ParentCode=null;
|
||||
if (activity.SettingsClassName==YavscConstants.NoneCode)
|
||||
if (activity.SettingsClassName==Constants.NoneCode)
|
||||
activity.SettingsClassName=null;
|
||||
|
||||
if (ModelState.IsValid)
|
||||
|
|
@ -161,9 +161,9 @@ namespace Yavsc.Controllers
|
|||
[ValidateAntiForgeryToken]
|
||||
public IActionResult Edit(Activity activity)
|
||||
{
|
||||
if (activity.ParentCode==YavscConstants.NoneCode)
|
||||
if (activity.ParentCode==Constants.NoneCode)
|
||||
activity.ParentCode=null;
|
||||
if (activity.SettingsClassName==YavscConstants.NoneCode)
|
||||
if (activity.SettingsClassName==Constants.NoneCode)
|
||||
activity.SettingsClassName=null;
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ using Yavsc.Server.Helpers;
|
|||
namespace Yavsc.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("api/v1/dimiss")]
|
||||
[Route(Constants.APIPrefix + "/v1/dimiss")]
|
||||
public class DimissClicksApiController : Controller
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
|
|
@ -140,7 +140,7 @@ namespace Yavsc.Controllers
|
|||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (!User.IsInRole("Administrator"))
|
||||
if (uid != id) return new ChallengeResult();
|
||||
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ namespace Yavsc.Controllers
|
|||
readonly IHtmlLocalizer _localizer;
|
||||
|
||||
private SiteSettings siteSettings;
|
||||
public HomeController(ILogger<HomeController> logger,
|
||||
IHtmlLocalizer<HomeController> localizer,
|
||||
public HomeController(ILogger<HomeController> logger,
|
||||
IHtmlLocalizer<HomeController> localizer,
|
||||
ApplicationDbContext context,
|
||||
IOptions<SiteSettings> settingsOptions,
|
||||
IOptions<SiteSettings> settingsOptions,
|
||||
IWebHostEnvironment env
|
||||
)
|
||||
{
|
||||
|
|
@ -37,9 +37,9 @@ namespace Yavsc.Controllers
|
|||
|
||||
public async Task<IActionResult> Index(string id)
|
||||
{
|
||||
ViewBag.IsFromSecureProx = Request.Headers.ContainsKey(YavscConstants.SshHeaderKey) && Request.Headers[YavscConstants.SshHeaderKey] == "on";
|
||||
ViewBag.IsFromSecureProx = Request.Headers.ContainsKey(Constants.SshHeaderKey) && Request.Headers[Constants.SshHeaderKey] == "on";
|
||||
ViewBag.SecureHomeUrl = "https://" + Request.Headers["X-Forwarded-Host"];
|
||||
ViewBag.SshHeaderKey = Request.Headers[YavscConstants.SshHeaderKey];
|
||||
ViewBag.SshHeaderKey = Request.Headers[Constants.SshHeaderKey];
|
||||
var uid = User.GetUserId();
|
||||
long[] clicked = null;
|
||||
if (uid == null)
|
||||
|
|
@ -140,8 +140,8 @@ namespace Yavsc.Controllers
|
|||
errorViewModel.Description ??= string.Empty;
|
||||
errorViewModel.Description += " Page: Home.";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return View("~/Views/Shared/Error.cshtml", errorViewModel);
|
||||
}
|
||||
public IActionResult Status(int id)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Yavsc.Controllers
|
|||
|
||||
public InstrumentationController(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
// GET: Instrumentation
|
||||
|
|
@ -50,7 +50,7 @@ namespace Yavsc.Controllers
|
|||
var owned = _context.Instrumentation.Include(i=>i.Tool).Where(i=>i.UserId==uid).Select(i=>i.InstrumentId);
|
||||
var ownedArray = owned.ToArray();
|
||||
|
||||
ViewBag.YetAvailableInstruments = _context.Instrument.Select(k=>new SelectListItem
|
||||
ViewBag.YetAvailableInstruments = _context.Instrument.Select(k=>new SelectListItem
|
||||
{ Text = k.Name, Value = k.Id.ToString(), Disabled = ownedArray.Contains(k.Id) });
|
||||
|
||||
return View(new Instrumentation { UserId = uid });
|
||||
|
|
@ -64,7 +64,7 @@ namespace Yavsc.Controllers
|
|||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
if (model.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (model.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
_context.Instrumentation.Add(model);
|
||||
|
|
@ -82,7 +82,7 @@ namespace Yavsc.Controllers
|
|||
{
|
||||
return NotFound();
|
||||
}
|
||||
if (id != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (id != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
if (musicianSettings == null)
|
||||
|
|
@ -98,7 +98,7 @@ namespace Yavsc.Controllers
|
|||
public async Task<IActionResult> Edit(Instrumentation musicianSettings)
|
||||
{
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
|
|
@ -124,7 +124,7 @@ namespace Yavsc.Controllers
|
|||
return NotFound();
|
||||
}
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
return View(musicianSettings);
|
||||
}
|
||||
|
|
@ -135,12 +135,12 @@ namespace Yavsc.Controllers
|
|||
public async Task<IActionResult> DeleteConfirmed(string id)
|
||||
{
|
||||
Instrumentation musicianSettings = await _context.Instrumentation.SingleAsync(m => m.UserId == id);
|
||||
|
||||
|
||||
var uid = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (musicianSettings.UserId != uid) if (!User.IsInMsRole(Constants.AdminGroupName))
|
||||
return new ChallengeResult();
|
||||
|
||||
|
||||
|
||||
_context.Instrumentation.Remove(musicianSettings);
|
||||
await _context.SaveChangesAsync(User.GetUserId());
|
||||
return RedirectToAction("Index");
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ public static class HostingExtensions
|
|||
public static IdentityBuilder AddIdentityDBAndStores(this WebApplicationBuilder builder)
|
||||
{
|
||||
IServiceCollection services = builder.Services;
|
||||
var connectionString = builder.Configuration.GetConnectionString(YavscConstants.YavscConnectionStringName);
|
||||
var connectionString = builder.Configuration.GetConnectionString(Constants.YavscConnectionStringName);
|
||||
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
{
|
||||
|
|
@ -197,7 +197,7 @@ public static class HostingExtensions
|
|||
options.SignIn.RequireConfirmedAccount = builder.Environment.IsEnvironment(
|
||||
builder.Environment.EnvironmentName);
|
||||
options.ClaimsIdentity.UserNameClaimType = JwtClaimTypes.PreferredUserName;
|
||||
options.ClaimsIdentity.RoleClaimType = YavscConstants.RoleClaimType;
|
||||
options.ClaimsIdentity.RoleClaimType = Constants.RoleClaimType;
|
||||
}
|
||||
)
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||
|
|
@ -239,18 +239,18 @@ public static class HostingExtensions
|
|||
{
|
||||
policy
|
||||
.RequireAuthenticatedUser()
|
||||
.RequireClaim(YavscConstants.RoleClaimType,
|
||||
new string[] { YavscConstants.PerformerGroupName, YavscConstants.AdminGroupName })
|
||||
.RequireClaim(Constants.RoleClaimType,
|
||||
new string[] { Constants.PerformerGroupName, Constants.AdminGroupName })
|
||||
;
|
||||
});
|
||||
options.AddPolicy("AdministratorOnly", policy =>
|
||||
{
|
||||
_ = policy
|
||||
.RequireAuthenticatedUser()
|
||||
.RequireClaim(YavscConstants.RoleClaimType, YavscConstants.AdminGroupName);
|
||||
.RequireClaim(Constants.RoleClaimType, Constants.AdminGroupName);
|
||||
});
|
||||
|
||||
options.AddPolicy("FrontOffice", policy => policy.RequireRole(YavscConstants.FrontOfficeGroupName));
|
||||
options.AddPolicy("FrontOffice", policy => policy.RequireRole(Constants.FrontOfficeGroupName));
|
||||
|
||||
// options.AddPolicy("EmployeeId", policy => policy.RequireClaim("EmployeeId", "123", "456"));
|
||||
// options.AddPolicy("BuildingEntry", policy => policy.Requirements.Add(new OfficeEntryRequirement()));
|
||||
|
|
@ -314,10 +314,10 @@ public static class HostingExtensions
|
|||
{
|
||||
options.ClaimsIdentity.UserIdClaimType = JwtClaimTypes.Subject;
|
||||
options.ClaimsIdentity.UserNameClaimType = JwtClaimTypes.Name;
|
||||
options.ClaimsIdentity.RoleClaimType = YavscConstants.RoleClaimType;
|
||||
options.ClaimsIdentity.RoleClaimType = Constants.RoleClaimType;
|
||||
});
|
||||
var migrationsAssembly = typeof(Program).GetTypeInfo().Assembly.GetName().Name;
|
||||
var connectionString = builder.Configuration.GetConnectionString(YavscConstants.YavscConnectionStringName);
|
||||
var connectionString = builder.Configuration.GetConnectionString(Constants.YavscConnectionStringName);
|
||||
|
||||
string sqliteConnectionString = $"Data Source={Path.Combine(Path.GetTempPath(), "yavsc_test.db")}";
|
||||
|
||||
|
|
@ -1220,7 +1220,7 @@ ADD COLUMN IF NOT EXISTS ""Moderated"" boolean NOT NULL DEFAULT FALSE;");
|
|||
Config.UserFilesOptions = new FileServerOptions()
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(AbstractFileSystemHelpers.UserFilesDirName),
|
||||
RequestPath = PathString.FromUriComponent(YavscConstants.UserFilesPath),
|
||||
RequestPath = PathString.FromUriComponent(Constants.UserFilesPath),
|
||||
EnableDirectoryBrowsing = enableDirectoryBrowsing,
|
||||
};
|
||||
Config.UserFilesOptions.EnableDefaultFiles = true;
|
||||
|
|
@ -1233,7 +1233,7 @@ ADD COLUMN IF NOT EXISTS ""Moderated"" boolean NOT NULL DEFAULT FALSE;");
|
|||
Config.AvatarsOptions = new FileServerOptions()
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(Config.AvatarsDirName),
|
||||
RequestPath = PathString.FromUriComponent(YavscConstants.AvatarsPath),
|
||||
RequestPath = PathString.FromUriComponent(Constants.AvatarsPath),
|
||||
EnableDirectoryBrowsing = enableDirectoryBrowsing
|
||||
};
|
||||
|
||||
|
|
@ -1244,7 +1244,7 @@ ADD COLUMN IF NOT EXISTS ""Moderated"" boolean NOT NULL DEFAULT FALSE;");
|
|||
Config.GitOptions = new FileServerOptions()
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(Config.GitDirName),
|
||||
RequestPath = PathString.FromUriComponent(YavscConstants.GitPath),
|
||||
RequestPath = PathString.FromUriComponent(Constants.GitPath),
|
||||
EnableDirectoryBrowsing = enableDirectoryBrowsing,
|
||||
};
|
||||
Config.GitOptions.DefaultFilesOptions.DefaultFileNames.Add("index.md");
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace Yavsc.ViewModels.Manage
|
|||
public class SetUserNameViewModel
|
||||
{
|
||||
[Required]
|
||||
[Display(Name = "User name"),RegularExpression(YavscConstants.UserNameRegExp)]
|
||||
[Display(Name = "User name"),RegularExpression(Constants.UserNameRegExp)]
|
||||
public string UserName { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
} else {
|
||||
<div class="alert alert-warning">
|
||||
<strong>Utilisateur inconnu</strong>
|
||||
<img src="@YavscConstants.DefaultAvatar" class="smalltofhol" alt="Utilisateur inconnu" title="Utilisateur inconnu" />
|
||||
<img src="@Constants.DefaultAvatar" class="smalltofhol" alt="Utilisateur inconnu" title="Utilisateur inconnu" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<li><a class="dropdown-item @PageHelpers.ActivePage(ViewContext, "Feature")" asp-controller="Feature" asp-action="Index">Features</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@if (User.IsInMsRole(YavscConstants.AdminGroupName)) {
|
||||
@if (User.IsInMsRole(Constants.AdminGroupName)) {
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle @PageHelpers.ActivePageAny(ViewContext, administrationControllers)" href="#" id="dropdown05" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Administration
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Yavsc.Helpers
|
|||
public static string ToAbsolute(this HttpRequest request, string url)
|
||||
{
|
||||
var host = request.Host;
|
||||
var isSecure = request.Headers[YavscConstants.SshHeaderKey] == "on";
|
||||
var isSecure = request.Headers[Constants.SshHeaderKey] == "on";
|
||||
return (isSecure ? "https" : "http") + $"://{host}/{url}";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ public static class ServiceExtensions
|
|||
{
|
||||
ValidateAudience = true,
|
||||
ValidAudiences = audiences,
|
||||
RoleClaimType = YavscConstants.RoleClaimType,
|
||||
NameClaimType = YavscConstants.NameClaimType,
|
||||
RoleClaimType = Constants.RoleClaimType,
|
||||
NameClaimType = Constants.NameClaimType,
|
||||
};
|
||||
options.MapInboundClaims = true;
|
||||
options.ClaimsIssuer = authority;
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace Yavsc.Server.Hubs
|
|||
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(YavscConstants.AdminGroupName) ;
|
||||
isCop = Context.User.IsInMsRole(Constants.AdminGroupName) ;
|
||||
if (isCop)
|
||||
{
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, ChatHubConstants.HubGroupCops);
|
||||
|
|
@ -351,7 +351,7 @@ namespace Yavsc.Server.Hubs
|
|||
var identityUserName = Context.User.GetUserName();
|
||||
|
||||
if (userName[0] != '?' && Context.User!=null)
|
||||
if (!Context.User.IsInMsRole(YavscConstants.AdminGroupName))
|
||||
if (!Context.User.IsInMsRole(Constants.AdminGroupName))
|
||||
{
|
||||
|
||||
var bl = _dbContext.BlackListed
|
||||
|
|
|
|||
|
|
@ -92,8 +92,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(YavscConstants.DefaultAvatar);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.DiskQuota).HasDefaultValue(YavscConstants.DefaultFSQ);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.Avatar).HasDefaultValue(Constants.DefaultAvatar);
|
||||
builder.Entity<ApplicationUser>().Property(u => u.DiskQuota).HasDefaultValue(Constants.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[YavscConstants.WebSocketsMaxBufLen];
|
||||
var buffer = new byte[Constants.WebSocketsMaxBufLen];
|
||||
var sBuffer = new ArraySegment<byte>(buffer);
|
||||
_logger.LogInformation("Receiving bytes...");
|
||||
|
||||
|
|
@ -69,16 +69,16 @@ namespace Yavsc.Services
|
|||
|
||||
_logger.LogInformation($"Received bytes : {received.Count}");
|
||||
_logger.LogInformation($"Is the end : {received.EndOfMessage}");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var fsInputQueue = new Queue<ArraySegment<byte>>();
|
||||
|
||||
bool endOfInput = false;
|
||||
sBuffer = new ArraySegment<byte>(buffer,0,received.Count);
|
||||
fsInputQueue.Enqueue(sBuffer);
|
||||
var taskWritingToFs = liveHandler.ReceiveUserFile(user, _logger, destDir, fsInputQueue, fileName, () => endOfInput);
|
||||
|
||||
|
||||
|
||||
Stack<string> ToClose = new Stack<string>();
|
||||
|
||||
|
|
@ -105,19 +105,19 @@ namespace Yavsc.Services
|
|||
}
|
||||
}
|
||||
|
||||
if (!received.CloseStatus.HasValue)
|
||||
if (!received.CloseStatus.HasValue)
|
||||
{
|
||||
_logger.LogInformation("try and receive new bytes");
|
||||
|
||||
buffer = new byte[YavscConstants.WebSocketsMaxBufLen];
|
||||
buffer = new byte[Constants.WebSocketsMaxBufLen];
|
||||
received = await liveHandler.Socket.ReceiveAsync(sBuffer, liveHandler.TokenSource.Token);
|
||||
|
||||
|
||||
_logger.LogInformation($"Received bytes : {received.Count}");
|
||||
|
||||
sBuffer = new ArraySegment<byte>(buffer,0,received.Count);
|
||||
_logger.LogInformation($"segment : offset: {sBuffer.Offset} count: {sBuffer.Count}");
|
||||
_logger.LogInformation($"Is the end : {received.EndOfMessage}");
|
||||
|
||||
|
||||
if (received.CloseStatus.HasValue)
|
||||
{
|
||||
endOfInput=true;
|
||||
|
|
@ -140,7 +140,7 @@ namespace Yavsc.Services
|
|||
}
|
||||
}
|
||||
while (liveHandler.Socket.State == WebSocketState.Open);
|
||||
|
||||
|
||||
_logger.LogInformation("Closing connection");
|
||||
taskWritingToFs.Wait();
|
||||
await liveHandler.Socket.CloseAsync(WebSocketCloseStatus.NormalClosure, received.CloseStatusDescription, liveHandler.TokenSource.Token);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ namespace Yavsc.Services
|
|||
{
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
public ProfileService(
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ILogger<DefaultProfileService> logger)
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ILogger<DefaultProfileService> logger)
|
||||
{
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ namespace Yavsc.Services
|
|||
ProfileDataRequestContext context,
|
||||
ApplicationUser user)
|
||||
{
|
||||
|
||||
|
||||
var claims = new List<Claim> {
|
||||
new Claim(JwtClaimTypes.Subject,user.Id.ToString()),
|
||||
};
|
||||
|
|
@ -43,7 +43,7 @@ namespace Yavsc.Services
|
|||
claimAdds.Remove("profile");
|
||||
claimAdds.Add(JwtClaimTypes.Name);
|
||||
claimAdds.Add(JwtClaimTypes.Email);
|
||||
claimAdds.Add(YavscConstants.RoleClaimType);
|
||||
claimAdds.Add(Constants.RoleClaimType);
|
||||
}
|
||||
|
||||
if (claimAdds.Contains(JwtClaimTypes.Name))
|
||||
|
|
@ -51,13 +51,13 @@ namespace Yavsc.Services
|
|||
|
||||
if (claimAdds.Contains(JwtClaimTypes.Email))
|
||||
claims.Add(new Claim(JwtClaimTypes.Email, user.Email));
|
||||
|
||||
if (claimAdds.Contains(YavscConstants.RoleClaimType))
|
||||
|
||||
if (claimAdds.Contains(Constants.RoleClaimType))
|
||||
{
|
||||
var roles = await this._userManager.GetRolesAsync(user);
|
||||
if (roles.Count()>0)
|
||||
{
|
||||
claims.AddRange(roles.Select(r => new Claim(YavscConstants.RoleClaimType, r)));
|
||||
claims.AddRange(roles.Select(r => new Claim(Constants.RoleClaimType, r)));
|
||||
}
|
||||
}
|
||||
return claims;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Yavsc.ViewModels.Account
|
|||
public class ExternalLoginConfirmationViewModel
|
||||
{
|
||||
[Required]
|
||||
[YaStringLength(2,YavscConstants.MaxUserNameLength)]
|
||||
[YaRegularExpression(YavscConstants.UserNameRegExp)]
|
||||
[YaStringLength(2,Constants.MaxUserNameLength)]
|
||||
[YaRegularExpression(Constants.UserNameRegExp)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace cli {
|
|||
private CommandArgument _destArg;
|
||||
private CancellationTokenSource _tokenSource;
|
||||
|
||||
public Streamer(ILoggerFactory loggerFactory,
|
||||
public Streamer(ILoggerFactory loggerFactory,
|
||||
IOptions<ConnectionSettings> cxSettings,
|
||||
IOptions<UserConnectionSettings> userCxSettings
|
||||
)
|
||||
|
|
@ -38,7 +38,7 @@ namespace cli {
|
|||
|
||||
_sourceArg = target.Argument("source", "Source file to send, use '-' for standard input", false);
|
||||
_destArg = target.Argument("destination", "destination file name", false);
|
||||
|
||||
|
||||
target.HelpOption("-? | -h | --help");
|
||||
});
|
||||
streamCmd.OnExecute(async() => await DoExecute());
|
||||
|
|
@ -47,7 +47,7 @@ namespace cli {
|
|||
|
||||
private async Task <int> DoExecute()
|
||||
{
|
||||
|
||||
|
||||
if (_sourceArg.Value != "-")
|
||||
{
|
||||
var fi = new FileInfo(_sourceArg.Value);
|
||||
|
|
@ -80,7 +80,7 @@ namespace cli {
|
|||
_logger.LogInformation("Connecting to " + url);
|
||||
await _client.ConnectAsync(new Uri(url), _tokenSource.Token);
|
||||
_logger.LogInformation("Connected");
|
||||
const int bufLen = Yavsc.YavscConstants.WebSocketsMaxBufLen;
|
||||
const int bufLen = Yavsc.Constants.WebSocketsMaxBufLen;
|
||||
byte [] buffer = new byte[bufLen];
|
||||
const int offset=0;
|
||||
int read;
|
||||
|
|
@ -90,7 +90,7 @@ namespace cli {
|
|||
do
|
||||
{
|
||||
read = await stream.ReadAsync(buffer, offset, bufLen);
|
||||
lastFrame = read < Yavsc.YavscConstants.WebSocketsMaxBufLen;
|
||||
lastFrame = read < Yavsc.Constants.WebSocketsMaxBufLen;
|
||||
ArraySegment<byte> segment = new ArraySegment<byte>(buffer, offset, read);
|
||||
await _client.SendAsync(segment, pckType, lastFrame, _tokenSource.Token);
|
||||
_logger.LogInformation($"sent {segment.Count} ");
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ namespace cli
|
|||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
public string StreamingUrl { get {
|
||||
return Port==0 ? $"ws://{Authority}"+YavscConstants.StreamingPath:
|
||||
$"ws://{Authority}:{Port}"+YavscConstants.StreamingPath;
|
||||
return Port==0 ? $"ws://{Authority}"+Constants.StreamingPath:
|
||||
$"ws://{Authority}:{Port}"+Constants.StreamingPath;
|
||||
} }
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue