Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UserStore by saving/removing the role from the user #13066

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

MikeAlhayek
Copy link
Member

Fix #13065

@jtkech this is a patch for the PR we last merged. seems that this was missed.

@jtkech
Copy link
Member

jtkech commented Jan 10, 2023

Okay

Hmm, just as a reminder

When you introduced the is User directive in place of the (User)user casting, I also noticed that it changed a little the behavior, if not a User before it would fail on the casting, now it silently do nothing, but seems to not be so important.

Hmm, that said in the following, if the userToken is null and user not a User in place of failing on the (User)user casting, it would now fail at the end on a null userToken, if we follow the goal to not throw maybe a missing null check on the userToken.

        if (userToken == null && user is User u)
        {
            userToken = new UserToken
            {
                LoginProvider = loginProvider,
                Name = name
            };

            u.UserTokens.Add(userToken);
        }

        // Encrypt the token
        userToken.Value = _dataProtectionProvider.CreateProtector(TokenProtector).Protect(value);

@jtkech jtkech merged commit aa631dd into OrchardCMS:main Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User to roles are not saving
2 participants