Skip to content

Commit 51f8c45

Browse files
Merge pull request #1 from Walid-Abdulrazik/Walid-Abdulrazik-patch-1
Update AccountController.cs
2 parents ee4d3ca + 2e64190 commit 51f8c45

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/Skoruba.IdentityServer4.STS.Identity/Controllers/AccountController.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ public IActionResult Register(string returnUrl = null)
596596
[HttpPost]
597597
[AllowAnonymous]
598598
[ValidateAntiForgeryToken]
599-
public async Task<IActionResult> Register(RegisterViewModel model, string returnUrl = null)
599+
public async Task<IActionResult> Register(RegisterViewModel model, string returnUrl = null, bool IsCalledFromRegisterWithoutUsername = false)
600600
{
601601
returnUrl = returnUrl ?? Url.Content("~/");
602602

@@ -633,7 +633,21 @@ public async Task<IActionResult> Register(RegisterViewModel model, string return
633633
AddErrors(result);
634634

635635
// If we got this far, something failed, redisplay form
636-
return View(model);
636+
if (IsCalledFromRegisterWithoutUsername)
637+
{
638+
var registerWithoutUsernameModel = new RegisterWithoutUsernameViewModel
639+
{
640+
Email = model.Email,
641+
Password = model.Password,
642+
ConfirmPassword = model.ConfirmPassword
643+
};
644+
645+
return View("RegisterWithoutUsername", registerWithoutUsernameModel);
646+
}
647+
else
648+
{
649+
return View(model);
650+
}
637651
}
638652

639653
[HttpPost]
@@ -649,10 +663,9 @@ public async Task<IActionResult> RegisterWithoutUsername(RegisterWithoutUsername
649663
ConfirmPassword = model.ConfirmPassword
650664
};
651665

652-
return await Register(registerModel, returnUrl);
666+
return await Register(registerModel, returnUrl, true);
653667
}
654668

655-
656669
/*****************************************/
657670
/* helper APIs for the AccountController */
658671
/*****************************************/
@@ -798,4 +811,4 @@ private async Task<LoggedOutViewModel> BuildLoggedOutViewModelAsync(string logou
798811
return vm;
799812
}
800813
}
801-
}
814+
}

0 commit comments

Comments
 (0)