File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,15 @@ public async Task<IActionResult> OnPostAsync()
7070 // register new app user account
7171 var result = await _um . CreateAsync ( new AppUser { UserName = UserName , Email = Email } , Password ) ;
7272
73+ if ( ! result . Succeeded )
74+ {
75+ foreach ( var er in result . Errors )
76+ {
77+ ModelState . AddModelError ( "Custom" , er . Description ) ;
78+ return Page ( ) ;
79+ }
80+ }
81+
7382 // add user as author to app database
7483 var user = _db . Authors . Single ( a => a . AppUserName == UserName ) ;
7584 if ( user == null )
Original file line number Diff line number Diff line change @@ -45,9 +45,16 @@ public void ConfigureServices(IServiceCollection services)
4545
4646 services . AddDbContext < AppDbContext > ( AppSettings . DbOptions , ServiceLifetime . Transient ) ;
4747
48- services . AddIdentity < AppUser , IdentityRole > ( )
49- . AddEntityFrameworkStores < AppDbContext > ( )
50- . AddDefaultTokenProviders ( ) ;
48+ services . AddIdentity < AppUser , IdentityRole > ( options => {
49+ options . Password . RequireDigit = false ;
50+ options . Password . RequiredLength = 6 ;
51+ options . Password . RequireNonAlphanumeric = false ;
52+ options . Password . RequireUppercase = false ;
53+ options . Password . RequireLowercase = false ;
54+ options . User . AllowedUserNameCharacters = null ;
55+ } )
56+ . AddEntityFrameworkStores < AppDbContext > ( )
57+ . AddDefaultTokenProviders ( ) ;
5158
5259 services . AddLogging ( loggingBuilder =>
5360 loggingBuilder . AddSerilog ( dispose : true ) ) ;
You can’t perform that action at this time.
0 commit comments