-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented delete authenticator #122
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
954d6fb
Added support for non generic AppwriteResult for when there is no con…
pingu2k4 4b180d5
Implemented Delete Authenticator
pingu2k4 fd19dbf
Changed how we are handling text input such as type, so that we get b…
pingu2k4 f0c69ff
Added shared tests to cover all new code
pingu2k4 1afad7b
Added all client tests for new code
pingu2k4 5ec12d9
Added utils for server to match client and added server tests
pingu2k4 2dbfda8
Update README.md
pingu2k4 344d026
Fixed CodeFactor issues manually
pingu2k4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,73 @@ | ||
using OneOf; | ||
using OneOf.Types; | ||
|
||
namespace PinguApps.Appwrite.Shared; | ||
|
||
/// <summary> | ||
/// The result of all API calls | ||
/// </summary> | ||
/// <typeparam name="TResult">the type of response expected on success</typeparam> | ||
public class AppwriteResult<TResult> | ||
public class AppwriteResult | ||
{ | ||
public AppwriteResult(OneOf<TResult, AppwriteError, InternalError> result) | ||
public AppwriteResult(OneOf<Success, AppwriteError, InternalError> result) | ||
{ | ||
Result = result; | ||
} | ||
|
||
protected AppwriteResult() | ||
{ | ||
|
||
} | ||
|
||
/// <summary> | ||
/// The result of making the API call. Can be <see cref="TResult"/>, <see cref="AppwriteError"/> or <see cref="InternalError"/> depending on what happened | ||
/// The result of making the API call. Can be <see cref="OneOf.Types.Success"/>, <see cref="AppwriteError"/> or <see cref="InternalError"/> depending on what happened | ||
/// </summary> | ||
public OneOf<TResult, AppwriteError, InternalError> Result { get; } | ||
public OneOf<Success, AppwriteError, InternalError> Result { get; } | ||
|
||
/// <summary> | ||
/// Indicates the API call was successful | ||
/// </summary> | ||
public bool Success => Result.IsT0; | ||
public virtual bool Success => Result.IsT0; | ||
|
||
/// <summary> | ||
/// Indicates there is an error | ||
/// </summary> | ||
public bool IsError => Result.IsT1 || Result.IsT2; | ||
public virtual bool IsError => Result.IsT1 || Result.IsT2; | ||
|
||
/// <summary> | ||
/// Indicates that there was an error thrown within Appwrite | ||
/// </summary> | ||
public bool IsAppwriteError => Result.IsT1; | ||
public virtual bool IsAppwriteError => Result.IsT1; | ||
|
||
/// <summary> | ||
/// Indicates that there was an error thrown within the SDK | ||
/// </summary> | ||
public bool IsInternalError => Result.IsT2; | ||
public virtual bool IsInternalError => Result.IsT2; | ||
} | ||
|
||
|
||
/// <inheritdoc/> | ||
/// <typeparam name="TResult">the type of response expected on success</typeparam> | ||
public class AppwriteResult<TResult> : AppwriteResult | ||
{ | ||
public AppwriteResult(OneOf<TResult, AppwriteError, InternalError> result) | ||
{ | ||
Result = result; | ||
} | ||
|
||
/// <summary> | ||
/// /// The result of making the API call. Can be <see cref="TResult"/>, <see cref="AppwriteError"/> or <see cref="InternalError"/> depending on what happened | ||
/// </summary> | ||
public new OneOf<TResult, AppwriteError, InternalError> Result { get; } | ||
|
||
/// <inheritdoc/> | ||
public override bool Success => Result.IsT0; | ||
|
||
/// <inheritdoc/> | ||
public override bool IsError => Result.IsT1 || Result.IsT2; | ||
|
||
/// <inheritdoc/> | ||
public override bool IsAppwriteError => Result.IsT1; | ||
|
||
/// <inheritdoc/> | ||
public override bool IsInternalError => Result.IsT2; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/PinguApps.Appwrite.Shared/Requests/AddAuthenticatorRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
using PinguApps.Appwrite.Shared.Requests.Validators; | ||
|
||
namespace PinguApps.Appwrite.Shared.Requests; | ||
public class AddAuthenticatorRequest : BaseRequest<AddAuthenticatorRequest, AddAuthenticatorRequestValidator> | ||
{ | ||
/// <summary> | ||
/// Type of authenticator. Must be `totp` | ||
/// </summary> | ||
[JsonIgnore] | ||
public string Type { get; set; } = "totp"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/PinguApps.Appwrite.Shared/Requests/DeleteAuthenticatorRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Text.Json.Serialization; | ||
using PinguApps.Appwrite.Shared.Requests.Validators; | ||
|
||
namespace PinguApps.Appwrite.Shared.Requests; | ||
|
||
/// <summary> | ||
/// The request for deleting an authenticator | ||
/// </summary> | ||
public class DeleteAuthenticatorRequest : BaseRequest<DeleteAuthenticatorRequest, DeleteAuthenticatorRequestValidator> | ||
{ | ||
/// <summary> | ||
/// Type of authenticator | ||
/// </summary> | ||
[JsonIgnore] | ||
public string Type { get; set; } = "totp"; | ||
|
||
/// <summary> | ||
/// Valid verification token | ||
/// </summary> | ||
[JsonPropertyName("otp")] | ||
public string Otp { get; set; } = string.Empty; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/PinguApps.Appwrite.Shared/Requests/Validators/AddAuthenticatorRequestValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using FluentValidation; | ||
|
||
namespace PinguApps.Appwrite.Shared.Requests.Validators; | ||
public class AddAuthenticatorRequestValidator : AbstractValidator<AddAuthenticatorRequest> | ||
{ | ||
public AddAuthenticatorRequestValidator() | ||
{ | ||
RuleFor(x => x.Type).NotEmpty(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/PinguApps.Appwrite.Shared/Requests/Validators/DeleteAuthenticatorRequestValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using FluentValidation; | ||
|
||
namespace PinguApps.Appwrite.Shared.Requests.Validators; | ||
public class DeleteAuthenticatorRequestValidator : AbstractValidator<DeleteAuthenticatorRequest> | ||
{ | ||
public DeleteAuthenticatorRequestValidator() | ||
{ | ||
RuleFor(x => x.Type).NotEmpty(); | ||
RuleFor(x => x.Otp).NotEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A closing brace should not be preceded by a blank line.