diff options
author | vnugent <public@vaughnnugent.com> | 2023-01-08 16:01:54 -0500 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-01-08 16:01:54 -0500 |
commit | de94d788e9a47432a7630a8215896b8dd3628599 (patch) | |
tree | 666dec06eef861d101cb6948aff52a3d354c8d73 /Plugins.Essentials/src/Users | |
parent | be6dc557a3b819248b014992eb96c1cb21f8112b (diff) |
Reorder + analyzer cleanup
Diffstat (limited to 'Plugins.Essentials/src/Users')
-rw-r--r-- | Plugins.Essentials/src/Users/IUser.cs | 74 | ||||
-rw-r--r-- | Plugins.Essentials/src/Users/IUserManager.cs | 103 | ||||
-rw-r--r-- | Plugins.Essentials/src/Users/UserCreationFailedException.cs | 47 | ||||
-rw-r--r-- | Plugins.Essentials/src/Users/UserDeleteException.cs | 44 | ||||
-rw-r--r-- | Plugins.Essentials/src/Users/UserExistsException.cs | 49 | ||||
-rw-r--r-- | Plugins.Essentials/src/Users/UserStatus.cs | 50 | ||||
-rw-r--r-- | Plugins.Essentials/src/Users/UserUpdateException.cs | 43 |
7 files changed, 0 insertions, 410 deletions
diff --git a/Plugins.Essentials/src/Users/IUser.cs b/Plugins.Essentials/src/Users/IUser.cs deleted file mode 100644 index 28c5305..0000000 --- a/Plugins.Essentials/src/Users/IUser.cs +++ /dev/null @@ -1,74 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: VNLib.Plugins.Essentials -* File: IUser.cs -* -* IUser.cs is part of VNLib.Plugins.Essentials which is part of the larger -* VNLib collection of libraries and utilities. -* -* VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* VNLib.Plugins.Essentials is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ - -using System; -using System.Collections.Generic; - -using VNLib.Utils; -using VNLib.Utils.Async; -using VNLib.Utils.Memory; - -#nullable enable - -namespace VNLib.Plugins.Essentials.Users -{ - /// <summary> - /// Represents an abstract user account - /// </summary> - public interface IUser : IAsyncExclusiveResource, IDisposable, IObjectStorage, IEnumerable<KeyValuePair<string, string>>, IIndexable<string, string> - { - /// <summary> - /// The user's privilage level - /// </summary> - ulong Privilages { get; } - /// <summary> - /// The user's ID - /// </summary> - string UserID { get; } - /// <summary> - /// Date the user's account was created - /// </summary> - DateTimeOffset Created { get; } - /// <summary> - /// The user's password hash if retreived from the backing store, otherwise null - /// </summary> - PrivateString? PassHash { get; } - /// <summary> - /// Status of account - /// </summary> - UserStatus Status { get; set; } - /// <summary> - /// Is the account only usable from local network? - /// </summary> - bool LocalOnly { get; set; } - /// <summary> - /// The user's email address - /// </summary> - string EmailAddress { get; set; } - /// <summary> - /// Marks the user for deletion on release - /// </summary> - void Delete(); - } -}
\ No newline at end of file diff --git a/Plugins.Essentials/src/Users/IUserManager.cs b/Plugins.Essentials/src/Users/IUserManager.cs deleted file mode 100644 index dd521e4..0000000 --- a/Plugins.Essentials/src/Users/IUserManager.cs +++ /dev/null @@ -1,103 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: VNLib.Plugins.Essentials -* File: IUserManager.cs -* -* IUserManager.cs is part of VNLib.Plugins.Essentials which is part of the larger -* VNLib collection of libraries and utilities. -* -* VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* VNLib.Plugins.Essentials is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ - -using System; -using System.Threading; -using System.Threading.Tasks; - -using VNLib.Utils; -using VNLib.Utils.Memory; - -#nullable enable - -namespace VNLib.Plugins.Essentials.Users -{ - /// <summary> - /// A backing store that provides user accounts - /// </summary> - public interface IUserManager - { - /// <summary> - /// Attempts to get a user object without their password from the database asynchronously - /// </summary> - /// <param name="userId">The id of the user</param> - /// <param name="cancellationToken">A token to cancel the operation</param> - /// <returns>The user's <see cref="IUser"/> object, null if the user was not found</returns> - /// <exception cref="ArgumentNullException"></exception> - Task<IUser?> GetUserFromIDAsync(string userId, CancellationToken cancellationToken = default); - /// <summary> - /// Attempts to get a user object without their password from the database asynchronously - /// </summary> - /// <param name="emailAddress">The user's email address</param> - /// <param name="cancellationToken">A token to cancel the operation</param> - /// <returns>The user's <see cref="IUser"/> object, null if the user was not found</returns> - /// <exception cref="ArgumentNullException"></exception> - Task<IUser?> GetUserFromEmailAsync(string emailAddress, CancellationToken cancellationToken = default); - /// <summary> - /// Attempts to get a user object with their password from the database on the current thread - /// </summary> - /// <param name="userid">The id of the user</param> - /// <param name="cancellation">A token to cancel the operation</param> - /// <returns>The user's <see cref="IUser"/> object, null if the user was not found</returns> - /// <exception cref="ArgumentNullException"></exception> - Task<IUser?> GetUserAndPassFromIDAsync(string userid, CancellationToken cancellation = default); - /// <summary> - /// Attempts to get a user object with their password from the database asynchronously - /// </summary> - /// <param name="emailAddress">The user's email address</param> - /// <param name="cancellationToken">A token to cancel the operation</param> - /// <returns>The user's <see cref="IUser"/> object, null if the user was not found</returns> - /// <exception cref="ArgumentNullException"></exception> - Task<IUser?> GetUserAndPassFromEmailAsync(string emailAddress, CancellationToken cancellationToken = default); - /// <summary> - /// Creates a new user in the current user's table and if successful returns the new user object (without password) - /// </summary> - /// <param name="userid">The user id</param> - /// <param name="privilages">A number representing the privilage level of the account</param> - /// <param name="passHash">Value to store in the password field</param> - /// <param name="cancellation">A token to cancel the operation</param> - /// <param name="emailAddress">The account email address</param> - /// <returns>An object representing a user's account if successful, null otherwise</returns> - /// <exception cref="UserExistsException"></exception> - /// <exception cref="ArgumentNullException"></exception> - /// <exception cref="UserCreationFailedException"></exception> - Task<IUser> CreateUserAsync(string userid, string emailAddress, ulong privilages, PrivateString passHash, CancellationToken cancellation = default); - /// <summary> - /// Updates a password associated with the specified user. If the update fails, the transaction - /// is rolled back. - /// </summary> - /// <param name="user">The user account to update the password of</param> - /// <param name="newPass">The new password to set</param> - /// <param name="cancellation">A token to cancel the operation</param> - /// <returns>The result of the operation, the result should be 1 (aka true)</returns> - Task<ERRNO> UpdatePassAsync(IUser user, PrivateString newPass, CancellationToken cancellation = default); - - /// <summary> - /// Gets the number of entries in the current user table - /// </summary> - /// <param name="cancellation">A token to cancel the operation</param> - /// <returns>The number of users in the table, or -1 if the operation failed</returns> - Task<long> GetUserCountAsync(CancellationToken cancellation = default); - } -}
\ No newline at end of file diff --git a/Plugins.Essentials/src/Users/UserCreationFailedException.cs b/Plugins.Essentials/src/Users/UserCreationFailedException.cs deleted file mode 100644 index 9f509ac..0000000 --- a/Plugins.Essentials/src/Users/UserCreationFailedException.cs +++ /dev/null @@ -1,47 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: VNLib.Plugins.Essentials -* File: UserCreationFailedException.cs -* -* UserCreationFailedException.cs is part of VNLib.Plugins.Essentials which is part of the larger -* VNLib collection of libraries and utilities. -* -* VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* VNLib.Plugins.Essentials is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ - -using System; -using System.Runtime.Serialization; -using VNLib.Utils.Resources; - -#nullable enable - -namespace VNLib.Plugins.Essentials.Users -{ - /// <summary> - /// Raised when a user creation operation has failed and could not be created - /// </summary> - public class UserCreationFailedException : ResourceUpdateFailedException - { - public UserCreationFailedException() - {} - public UserCreationFailedException(string message) : base(message) - {} - public UserCreationFailedException(string message, Exception innerException) : base(message, innerException) - {} - protected UserCreationFailedException(SerializationInfo info, StreamingContext context) : base(info, context) - {} - } -}
\ No newline at end of file diff --git a/Plugins.Essentials/src/Users/UserDeleteException.cs b/Plugins.Essentials/src/Users/UserDeleteException.cs deleted file mode 100644 index cd26543..0000000 --- a/Plugins.Essentials/src/Users/UserDeleteException.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: VNLib.Plugins.Essentials -* File: UserDeleteException.cs -* -* UserDeleteException.cs is part of VNLib.Plugins.Essentials which is part of the larger -* VNLib collection of libraries and utilities. -* -* VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* VNLib.Plugins.Essentials is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ - -using System; -using VNLib.Utils.Resources; - -namespace VNLib.Plugins.Essentials.Users -{ - /// <summary> - /// Raised when a user flagged for deletion could not be deleted. See the <see cref="Exception.InnerException"/> - /// for the Exception that cause the opertion to fail - /// </summary> - public class UserDeleteException : ResourceDeleteFailedException - { - public UserDeleteException(string message, Exception cause) : base(message, cause) { } - - public UserDeleteException() - {} - - public UserDeleteException(string message) : base(message) - {} - } -}
\ No newline at end of file diff --git a/Plugins.Essentials/src/Users/UserExistsException.cs b/Plugins.Essentials/src/Users/UserExistsException.cs deleted file mode 100644 index 5c63547..0000000 --- a/Plugins.Essentials/src/Users/UserExistsException.cs +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: VNLib.Plugins.Essentials -* File: UserExistsException.cs -* -* UserExistsException.cs is part of VNLib.Plugins.Essentials which is part of the larger -* VNLib collection of libraries and utilities. -* -* VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* VNLib.Plugins.Essentials is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ - -using System; -using System.Runtime.Serialization; - -namespace VNLib.Plugins.Essentials.Users -{ - /// <summary> - /// Raised when an <see cref="IUserManager"/> operation - /// fails because the user account already exists - /// </summary> - public class UserExistsException : UserCreationFailedException - { - ///<inheritdoc/> - public UserExistsException() - {} - ///<inheritdoc/> - public UserExistsException(string message) : base(message) - {} - ///<inheritdoc/> - public UserExistsException(string message, Exception innerException) : base(message, innerException) - {} - ///<inheritdoc/> - protected UserExistsException(SerializationInfo info, StreamingContext context) : base(info, context) - {} - } -}
\ No newline at end of file diff --git a/Plugins.Essentials/src/Users/UserStatus.cs b/Plugins.Essentials/src/Users/UserStatus.cs deleted file mode 100644 index 32aa63d..0000000 --- a/Plugins.Essentials/src/Users/UserStatus.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: VNLib.Plugins.Essentials -* File: UserStatus.cs -* -* UserStatus.cs is part of VNLib.Plugins.Essentials which is part of the larger -* VNLib collection of libraries and utilities. -* -* VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* VNLib.Plugins.Essentials is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ - -namespace VNLib.Plugins.Essentials.Users -{ - public enum UserStatus - { - /// <summary> - /// Unverified account state - /// </summary> - Unverified, - /// <summary> - /// Active account state. The account is fully functional - /// </summary> - Active, - /// <summary> - /// The account is suspended - /// </summary> - Suspended, - /// <summary> - /// The account is inactive as marked by the system - /// </summary> - Inactive, - /// <summary> - /// The account has been locked from access - /// </summary> - Locked - } -}
\ No newline at end of file diff --git a/Plugins.Essentials/src/Users/UserUpdateException.cs b/Plugins.Essentials/src/Users/UserUpdateException.cs deleted file mode 100644 index 391bb05..0000000 --- a/Plugins.Essentials/src/Users/UserUpdateException.cs +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2022 Vaughn Nugent -* -* Library: VNLib -* Package: VNLib.Plugins.Essentials -* File: UserUpdateException.cs -* -* UserUpdateException.cs is part of VNLib.Plugins.Essentials which is part of the larger -* VNLib collection of libraries and utilities. -* -* VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* VNLib.Plugins.Essentials is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ - -using System; -using VNLib.Utils.Resources; - -namespace VNLib.Plugins.Essentials.Users -{ - /// <summary> - /// Raised when a user-data object was modified and an update operation failed - /// </summary> - public class UserUpdateException : ResourceUpdateFailedException - { - public UserUpdateException(string message, Exception cause) : base(message, cause) { } - - public UserUpdateException() - {} - - public UserUpdateException(string message) : base(message) - {} - } -}
\ No newline at end of file |