0

Does anyone know how I can change (i.e., increase) the max allowed password length? The scaffolded login/register pages contain the attribute:

data-val-length="The Password must be at least 6 and at max 100 characters long." data-val-length-max="100" data-val-length-min="6" 

They prevent longer passwords. I've tried setting options.Stores.MaxLengthForKeys = 1024 but that did result in any noticeable changes in these attributes at run-time.

Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203
Merijn
  • 661
  • 1
  • 7
  • 21
  • Possible duplicate of [How do I set password options in Aspnet Core 2.1](https://stackoverflow.com/questions/53620708/how-do-i-set-password-options-in-aspnet-core-2-1) – Kirk Larkin May 28 '19 at 13:31

1 Answers1

1

The validation is specified as an attribute on the Password property on the page model. You'll have to scaffold in the Register.cshtml Razor Page and then modify it there.

If you haven't scaffolded in stuff from the Identity default UI before, just right-click on your project in the Solution Explorer and choose Add > New Scaffolded Item. Select the Identity item on the left, and then the only available scaffold presented, and choose OK. This will pop a dialog with a list of all the available Razor Pages in the default UI. Select the one(s) you want, and then OK again.

Once you have the page in your project, open the Register.cshtml.cs codebehind and find the Password property. Modify the attribute as you like.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444