ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs
/// <summary>
///     Deletes the MobileAuthenticator of given bots if an ASF 2FA module is active on them.
/// </summary>
Deletes the MobileAuthenticator of given bots if an ASF 2FA module is active on them.
Deletes the MobileAuthenticator of given bots if an ASF 2FA module is active on them .
[HttpDelete]
	[ProducesResponseType(typeof(GenericResponse<IReadOnlyDictionary<string, GenericResponse<string>>>), (int) HttpStatusCode.OK)]
	[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
	public async Task<ActionResult<GenericResponse>> Delete(string botNames) {
		if (string.IsNullOrEmpty(botNames)) {
			throw new ArgumentNullException(nameof(botNames));
		}
		HashSet<Bot>? bots = Bot.GetBots(botNames);
		if ((bots == null) || (bots.Count == 0)) {
			return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)));
		}
		IList<(bool Success, string? Message)> results = await Utilities.InParallel(bots.Select(static bot => Task.Run(bot.RemoveAuthenticator))).ConfigureAwait(false);
		Dictionary<string, GenericResponse<string>> result = new(bots.Count, Bot.BotsComparer);
		foreach (Bot bot in bots) {
			(bool success, string? message) = results[result.Count];
			result[bot.BotName] = new GenericResponse<string>(success, message);
		}
		return Ok(new GenericResponse<IReadOnlyDictionary<string, GenericResponse<string>>>(result));
	}
[ HttpDelete ] [ ProducesResponseType ( typeof ( GenericResponse < IReadOnlyDictionary < string , GenericResponse < string > > > ) , ( int ) HttpStatusCode . OK ) ] [ ProducesResponseType ( typeof ( GenericResponse ) , ( int ) HttpStatusCode . BadRequest ) ] public async Task < ActionResult < GenericResponse > > Delete ( string botNames ) { if ( string . IsNullOrEmpty ( botNames ) ) { throw new ArgumentNullException ( nameof ( botNames ) ) ; } HashSet < Bot > ? bots = Bot . GetBots ( botNames ) ; if ( ( bots == null ) || ( bots . Count == 0 ) ) { return BadRequest ( new GenericResponse ( false , string . Format ( CultureInfo . CurrentCulture , Strings . BotNotFound , botNames ) ) ) ; } IList < ( bool Success , string ? Message ) > results = await Utilities . InParallel ( bots . Select ( static bot => Task . Run ( bot . RemoveAuthenticator ) ) ) . ConfigureAwait ( false ) ; Dictionary < string , GenericResponse < string > > result = new ( bots . Count , Bot . BotsComparer ) ; foreach ( Bot bot in bots ) { ( bool success , string ? message ) = results [ result . Count ] ; result [ bot . BotName ] = new GenericResponse < string > ( success , message ) ; } return Ok ( new GenericResponse < IReadOnlyDictionary < string , GenericResponse < string > > > ( result ) ) ; }
Deletes the MobileAuthenticator of given bots if an ASF 2FA module is active on them.
Deletes the MobileAuthenticator of given bots if an ASF 2FA module is active on them .
botNames
string