public virtual async Task <IActionResult> SetUsernameAsync([FromBody][Required] SetUsername <TIdentity> setUsername, CancellationToken cancellationToken = default) { await this.IdentityManager .SetUsernameAsync(setUsername, cancellationToken); return(this.Ok()); }
// Handles the persistence of username. void Persist(InputField input) { if (input.text.Length > 0) { SetUsername su = new SetUsername(); su.call(input.text); } }
public Parser Create( EnvironmentInit environmentInit = null, NewFile newFile = null, PluginInstall pluginInstall = null, PluginUninstall pluginUninstall = null, PluginList pluginList = null, SetUsername setEnvironmentSetting = null, TemplateInstall templateInstall = null, TemplateUninstall templateUninstall = null) { // if environmentInit hasn't been provided (for testing) then assign the Command Handler environmentInit ??= EnvironmentInitHandler.ExecuteAsync; newFile ??= NewFileHandler.ExecuteAsync; pluginInstall ??= PluginInstallHandler.ExecuteAsync; pluginUninstall ??= PluginUninstallHandler.ExecuteAsync; pluginList ??= PluginListHandler.ExecuteAsync; setEnvironmentSetting ??= SetEnvironmentSettingHandler.ExecuteAsync; templateInstall ??= TemplatePackageInstallerHandler.ExecuteAsync; templateUninstall ??= TemplatePackageUninstallerHandler.ExecuteAsync; // Set up intrinsic commands that will always be available. RootCommand rootCommand = Root(); rootCommand.AddCommand(Environment()); rootCommand.AddCommand(NewFile()); rootCommand.AddCommand(Plugins()); rootCommand.AddCommand(Templates()); var commandBuilder = new CommandLineBuilder(rootCommand); try { foreach (Command command in this.commandPluginHost.Discover(this.appEnvironment.PluginPaths)) { commandBuilder.AddCommand(command); } } catch (DirectoryNotFoundException) { // If this is the first run, initialize the environment and default plugins Console.WriteLine("Error Detected: vellum environment uninitialized."); Parser parser = commandBuilder.UseDefaults().Build(); int result = parser.Invoke("environment init"); if (result == ReturnCodes.Ok) { // Now the environment has been re-initialized, try to discover the plugins again. foreach (Command command in this.commandPluginHost.Discover(this.appEnvironment.PluginPaths)) { commandBuilder.AddCommand(command); } } } return(commandBuilder.UseDefaults().Build());
/// <summary> /// Sets a username for a user. /// </summary> /// <param name="setUsername">The <see cref="SetUsername"/>.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param> /// <returns>Void.</returns> public virtual async Task SetUsernameAsync(SetUsername setUsername, CancellationToken cancellationToken = default) { if (setUsername == null) { throw new ArgumentNullException(nameof(setUsername)); } var user = await this.UserManager .FindByIdAsync(setUsername.UserId); await this.UserManager .SetUserNameAsync(user, setUsername.NewUsername); }