a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend/core] Add optional --password option when creating user at startup

pancakes 5f14c4ed 0753ad06

+7 -4
+6 -3
Iceshrimp.Backend/Core/Extensions/WebApplicationExtensions.cs
··· 274 274 275 275 if (args.FirstOrDefault(userMgmtCommands.Contains) is { } cmd) 276 276 { 277 - if (args is not [not null, var username]) 277 + if (args is not [not null, var username, ..]) 278 278 { 279 - app.Logger.LogError("Invalid syntax. Usage: {cmd} <username>", cmd); 279 + app.Logger.LogError("Invalid syntax. Usage: {cmd} <username> [--password <password>]", cmd); 280 280 Environment.Exit(1); 281 281 return null!; 282 282 } 283 283 284 284 if (cmd is "--create-user" or "--create-admin-user") 285 285 { 286 - var password = CryptographyHelpers.GenerateRandomString(16); 286 + if (args is not [_, _, "--password", var password]) 287 + { 288 + password = CryptographyHelpers.GenerateRandomString(16); 289 + } 287 290 app.Logger.LogInformation("Creating user {username}...", username); 288 291 var userSvc = provider.GetRequiredService<UserService>(); 289 292 await userSvc.CreateLocalUserAsync(username, password, null, force: true);
+1 -1
Iceshrimp.Backend/Core/Services/UserService.cs
··· 458 458 throw new GracefulException(HttpStatusCode.BadRequest, "User already exists"); 459 459 if (await db.UsedUsernames.AnyAsync(p => p.Username.ToLower() == username.ToLowerInvariant())) 460 460 throw new GracefulException(HttpStatusCode.BadRequest, "Username was already used"); 461 - if (password.Length < 8) 461 + if (password.Length < 8 && !force) 462 462 throw GracefulException.BadRequest("Password must be at least 8 characters long"); 463 463 464 464 var keypair = RSA.Create(4096);