From 0316fc948dd77b91b0ccf508826f66a175cb1e83 Mon Sep 17 00:00:00 2001 From: vnugent Date: Sun, 5 Nov 2023 21:22:21 -0500 Subject: user/acc updates and fix social oauth --- .../src/AccountsEntryPoint.cs | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'plugins/VNLib.Plugins.Essentials.Accounts/src/AccountsEntryPoint.cs') diff --git a/plugins/VNLib.Plugins.Essentials.Accounts/src/AccountsEntryPoint.cs b/plugins/VNLib.Plugins.Essentials.Accounts/src/AccountsEntryPoint.cs index 5f171cd..d524902 100644 --- a/plugins/VNLib.Plugins.Essentials.Accounts/src/AccountsEntryPoint.cs +++ b/plugins/VNLib.Plugins.Essentials.Accounts/src/AccountsEntryPoint.cs @@ -29,7 +29,6 @@ using System.ComponentModel.Design; using FluentValidation.Results; using VNLib.Utils; -using VNLib.Utils.Memory; using VNLib.Utils.Logging; using VNLib.Plugins.Attributes; using VNLib.Plugins.Essentials.Users; @@ -40,9 +39,11 @@ using VNLib.Plugins.Essentials.Accounts.SecurityProvider; using VNLib.Plugins.Extensions.Loading; using VNLib.Plugins.Extensions.Loading.Users; using VNLib.Plugins.Extensions.Loading.Routing; +using VNLib.Utils.Memory; namespace VNLib.Plugins.Essentials.Accounts { + public sealed class AccountsEntryPoint : PluginBase { @@ -139,7 +140,6 @@ namespace VNLib.Plugins.Essentials.Accounts ArgumentList args = new(cmd.Split(' ')); IUserManager Users = this.GetOrCreateSingleton(); - IPasswordHashingProvider Passwords = this.GetOrCreateSingleton(); string? username = args.GetArgument("-u"); string? password = args.GetArgument("-p"); @@ -187,13 +187,18 @@ Commands: privLevel = AccountUtil.MINIMUM_LEVEL; } - //Hash the password - using PrivateString passHash = Passwords.Hash(password); + //Create the user creation request + UserCreationRequest creation = new() + { + EmailAddress = username, + InitialStatus = UserStatus.Active, + Privileges = privLevel, + Password = PrivateString.ToPrivateString(password, false) + }; + //Create the user - using IUser user = await Users.CreateUserAsync(username, passHash, privLevel); - - //Set active flag - user.Status = UserStatus.Active; + using IUser user = await Users.CreateUserAsync(creation, null); + //Set local account user.SetAccountOrigin(AccountUtil.LOCAL_ACCOUNT_ORIGIN); @@ -210,9 +215,6 @@ Commands: break; } - //Hash the password - using PrivateString passHash = Passwords.Hash(password); - //Get the user using IUser? user = await Users.GetUserFromEmailAsync(username); @@ -223,7 +225,7 @@ Commands: } //Set the password - await Users.UpdatePassAsync(user, passHash); + await Users.UpdatePasswordAsync(user, password); Log.Information("Successfully reset password for {id}", username); } -- cgit