Fixing SigninUserActivity bug.

The bug caused to always fail authentication if no username/password was present, even if the workflow context was a User.
This commit is contained in:
Sipke Schoorstra
2014-11-28 22:34:14 -08:00
parent 6b32f6db3c
commit aae36c5458

View File

@@ -50,16 +50,17 @@ namespace Orchard.Users.Activities {
var userNameOrEmail = activityContext.GetState<string>("UserNameOrEmail");
var password = activityContext.GetState<string>("Password");
var createPersistentCookie = IsTrueish(activityContext.GetState<string>("CreatePersistentCookie"));
var user = workflowContext.Content != null ? workflowContext.Content.As<IUser>() : default(IUser);
if (String.IsNullOrWhiteSpace(userNameOrEmail) || String.IsNullOrWhiteSpace(password)) {
yield return T("IncorrectUserNameOrPassword");
yield break;
if (user == null) {
if (String.IsNullOrWhiteSpace(userNameOrEmail) || String.IsNullOrWhiteSpace(password)) {
yield return T("IncorrectUserNameOrPassword");
yield break;
}
user = _membershipService.ValidateUser(userNameOrEmail, password);
}
var user = !String.IsNullOrWhiteSpace(userNameOrEmail)
? _membershipService.ValidateUser(userNameOrEmail, password)
: workflowContext.Content != null ? workflowContext.Content.As<UserPart>() : default(UserPart);
if (user == null) {
yield return T("IncorrectUserNameOrPassword");
yield break;