mirror of
https://github.com/claunia/marechai.git
synced 2026-07-08 17:57:08 +00:00
Implement a new feature where users receive 5 invitation codes when they confirm their email.
Backend changes:
- Extend InvitationCodeGenerator with GenerateForOwnerAsync() for batch code creation
- Mint 5 codes on email confirmation (not registration) in AuthController.ConfirmEmailAsync
- Add GET /invitation-codes/mine (self-service) endpoint for users to view their own codes
- Add POST /users/{id}/invitation-codes (admin-only) endpoint to grant additional codes
- Create MyInvitationCodeDto and GrantInvitationCodesRequest DTOs
Frontend changes:
- Add "My Invitation Codes" tab to Profile.razor with list of user's codes
- Unused codes rendered normally with copy-to-clipboard button
- Used codes shown with strikethrough (no user identity revealed)
- Add "Give Invitation Codes" action to admin Users page
- Dialog prompts for count (1-50) of codes to grant to selected user
- Success/error messages displayed after granting
- Extend InvitationCodesService.GetMyAsync() and UsersService.GrantInvitationCodesAsync()
- Regenerate Kiota API client from updated OpenAPI schema
No database schema changes required - existing InvitationCode fields accommodate both
registration-issued and admin-granted codes.
222 lines
14 KiB
C#
222 lines
14 KiB
C#
// <auto-generated/>
|
|
#pragma warning disable CS0618
|
|
using Marechai.ApiClient.Models;
|
|
using Marechai.ApiClient.Users.Item.InvitationCodes;
|
|
using Marechai.ApiClient.Users.Item.Password;
|
|
using Marechai.ApiClient.Users.Item.Roles;
|
|
using Marechai.ApiClient.Users.Item.TwoFactor;
|
|
using Microsoft.Kiota.Abstractions.Extensions;
|
|
using Microsoft.Kiota.Abstractions.Serialization;
|
|
using Microsoft.Kiota.Abstractions;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using System.Threading;
|
|
using System;
|
|
namespace Marechai.ApiClient.Users.Item
|
|
{
|
|
/// <summary>
|
|
/// Builds and executes requests for operations under \users\{id}
|
|
/// </summary>
|
|
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
|
|
public partial class UsersItemRequestBuilder : BaseRequestBuilder
|
|
{
|
|
/// <summary>The invitationCodes property</summary>
|
|
public global::Marechai.ApiClient.Users.Item.InvitationCodes.InvitationCodesRequestBuilder InvitationCodes
|
|
{
|
|
get => new global::Marechai.ApiClient.Users.Item.InvitationCodes.InvitationCodesRequestBuilder(PathParameters, RequestAdapter);
|
|
}
|
|
/// <summary>The password property</summary>
|
|
public global::Marechai.ApiClient.Users.Item.Password.PasswordRequestBuilder Password
|
|
{
|
|
get => new global::Marechai.ApiClient.Users.Item.Password.PasswordRequestBuilder(PathParameters, RequestAdapter);
|
|
}
|
|
/// <summary>The roles property</summary>
|
|
public global::Marechai.ApiClient.Users.Item.Roles.RolesRequestBuilder Roles
|
|
{
|
|
get => new global::Marechai.ApiClient.Users.Item.Roles.RolesRequestBuilder(PathParameters, RequestAdapter);
|
|
}
|
|
/// <summary>The twoFactor property</summary>
|
|
public global::Marechai.ApiClient.Users.Item.TwoFactor.TwoFactorRequestBuilder TwoFactor
|
|
{
|
|
get => new global::Marechai.ApiClient.Users.Item.TwoFactor.TwoFactorRequestBuilder(PathParameters, RequestAdapter);
|
|
}
|
|
/// <summary>
|
|
/// Instantiates a new <see cref="global::Marechai.ApiClient.Users.Item.UsersItemRequestBuilder"/> and sets the default values.
|
|
/// </summary>
|
|
/// <param name="pathParameters">Path parameters for the request</param>
|
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
|
public UsersItemRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}", pathParameters)
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// Instantiates a new <see cref="global::Marechai.ApiClient.Users.Item.UsersItemRequestBuilder"/> and sets the default values.
|
|
/// </summary>
|
|
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
|
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
|
public UsersItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/users/{id}", rawUrl)
|
|
{
|
|
}
|
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 401 status code</exception>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 403 status code</exception>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 404 status code</exception>
|
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
|
#nullable enable
|
|
public async Task DeleteAsync(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
|
|
{
|
|
#nullable restore
|
|
#else
|
|
public async Task DeleteAsync(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
|
|
{
|
|
#endif
|
|
var requestInfo = ToDeleteRequestInformation(requestConfiguration);
|
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
|
|
{
|
|
{ "401", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
{ "403", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
{ "404", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
};
|
|
await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false);
|
|
}
|
|
/// <returns>A <see cref="global::Marechai.ApiClient.Models.UserDto"/></returns>
|
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 401 status code</exception>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 403 status code</exception>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 404 status code</exception>
|
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
|
#nullable enable
|
|
public async Task<global::Marechai.ApiClient.Models.UserDto?> GetAsync(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
|
|
{
|
|
#nullable restore
|
|
#else
|
|
public async Task<global::Marechai.ApiClient.Models.UserDto> GetAsync(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
|
|
{
|
|
#endif
|
|
var requestInfo = ToGetRequestInformation(requestConfiguration);
|
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
|
|
{
|
|
{ "401", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
{ "403", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
{ "404", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
};
|
|
return await RequestAdapter.SendAsync<global::Marechai.ApiClient.Models.UserDto>(requestInfo, global::Marechai.ApiClient.Models.UserDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
|
|
}
|
|
/// <returns>A <see cref="global::Marechai.ApiClient.Models.UserDto"/></returns>
|
|
/// <param name="body">The request body</param>
|
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 400 status code</exception>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 401 status code</exception>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 403 status code</exception>
|
|
/// <exception cref="global::Marechai.ApiClient.Models.ProblemDetails">When receiving a 404 status code</exception>
|
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
|
#nullable enable
|
|
public async Task<global::Marechai.ApiClient.Models.UserDto?> PutAsync(global::Marechai.ApiClient.Models.UpdateUserRequest body, Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
|
|
{
|
|
#nullable restore
|
|
#else
|
|
public async Task<global::Marechai.ApiClient.Models.UserDto> PutAsync(global::Marechai.ApiClient.Models.UpdateUserRequest body, Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default, CancellationToken cancellationToken = default)
|
|
{
|
|
#endif
|
|
if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body));
|
|
var requestInfo = ToPutRequestInformation(body, requestConfiguration);
|
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
|
|
{
|
|
{ "400", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
{ "401", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
{ "403", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
{ "404", global::Marechai.ApiClient.Models.ProblemDetails.CreateFromDiscriminatorValue },
|
|
};
|
|
return await RequestAdapter.SendAsync<global::Marechai.ApiClient.Models.UserDto>(requestInfo, global::Marechai.ApiClient.Models.UserDto.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
|
|
}
|
|
/// <returns>A <see cref="RequestInformation"/></returns>
|
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
|
#nullable enable
|
|
public RequestInformation ToDeleteRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default)
|
|
{
|
|
#nullable restore
|
|
#else
|
|
public RequestInformation ToDeleteRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default)
|
|
{
|
|
#endif
|
|
var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters);
|
|
requestInfo.Configure(requestConfiguration);
|
|
requestInfo.Headers.TryAdd("Accept", "application/json, text/plain;q=0.9");
|
|
return requestInfo;
|
|
}
|
|
/// <returns>A <see cref="RequestInformation"/></returns>
|
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
|
#nullable enable
|
|
public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default)
|
|
{
|
|
#nullable restore
|
|
#else
|
|
public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default)
|
|
{
|
|
#endif
|
|
var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters);
|
|
requestInfo.Configure(requestConfiguration);
|
|
requestInfo.Headers.TryAdd("Accept", "application/json");
|
|
return requestInfo;
|
|
}
|
|
/// <returns>A <see cref="RequestInformation"/></returns>
|
|
/// <param name="body">The request body</param>
|
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
|
#nullable enable
|
|
public RequestInformation ToPutRequestInformation(global::Marechai.ApiClient.Models.UpdateUserRequest body, Action<RequestConfiguration<DefaultQueryParameters>>? requestConfiguration = default)
|
|
{
|
|
#nullable restore
|
|
#else
|
|
public RequestInformation ToPutRequestInformation(global::Marechai.ApiClient.Models.UpdateUserRequest body, Action<RequestConfiguration<DefaultQueryParameters>> requestConfiguration = default)
|
|
{
|
|
#endif
|
|
if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body));
|
|
var requestInfo = new RequestInformation(Method.PUT, UrlTemplate, PathParameters);
|
|
requestInfo.Configure(requestConfiguration);
|
|
requestInfo.Headers.TryAdd("Accept", "application/json");
|
|
requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
|
|
return requestInfo;
|
|
}
|
|
/// <summary>
|
|
/// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored.
|
|
/// </summary>
|
|
/// <returns>A <see cref="global::Marechai.ApiClient.Users.Item.UsersItemRequestBuilder"/></returns>
|
|
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
|
|
public global::Marechai.ApiClient.Users.Item.UsersItemRequestBuilder WithUrl(string rawUrl)
|
|
{
|
|
return new global::Marechai.ApiClient.Users.Item.UsersItemRequestBuilder(rawUrl, RequestAdapter);
|
|
}
|
|
/// <summary>
|
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
|
/// </summary>
|
|
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
|
|
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
|
|
public partial class UsersItemRequestBuilderDeleteRequestConfiguration : RequestConfiguration<DefaultQueryParameters>
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
|
/// </summary>
|
|
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
|
|
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
|
|
public partial class UsersItemRequestBuilderGetRequestConfiguration : RequestConfiguration<DefaultQueryParameters>
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
|
/// </summary>
|
|
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
|
|
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
|
|
public partial class UsersItemRequestBuilderPutRequestConfiguration : RequestConfiguration<DefaultQueryParameters>
|
|
{
|
|
}
|
|
}
|
|
}
|
|
#pragma warning restore CS0618
|