/// <summary> /// Method for matching a user based on an instance of class OpenIDUserInfo. /// </summary> /// <param name="userInfo">The instance of class OpenIDUserInfo that will be used to create the new user.</param> /// <returns>Instance of class User.</returns> public User MatchUser(OpenIDUserInfo userInfo) { // Create a new list of sources that should be used to match a user IList<UserSource> sources = new List<UserSource>(); // If present, add sources for the OpenID user ID returned by the Access Token issuer and the user's email address if (!String.IsNullOrWhiteSpace(userInfo.Sub)) sources.Add(new UserSource() { Name = userInfo.Issuer, Value = userInfo.Sub }); if (!String.IsNullOrWhiteSpace(userInfo.Email)) sources.Add(new UserSource() { Name = "Mail", Value = userInfo.Email }); // Attempt to match a user and return it return this.GetUser(null, sources); }
/// <summary> /// Method for creating a new user (of UserType Customer) based on an instance of class OpenIDUserInfo. /// </summary> /// <param name="userInfo">The instance of class OpenIDUserInfo that will be used to create the new user.</param> /// <returns>Instance of class User on success.</returns> public void CreateUser(OpenIDUserInfo userInfo) { // Create a new list of sources that should be used to match a user IList<UserSource> sources = new List<UserSource>(); // If present, add sources for the OpenID user ID returned by the Access Token issuer and the user's email address if (!String.IsNullOrWhiteSpace(userInfo.Sub)) sources.Add(new UserSource() { Name = userInfo.Issuer, Value = userInfo.Sub }); if (!String.IsNullOrWhiteSpace(userInfo.Email)) sources.Add(new UserSource() { Name = "Mail", Value = userInfo.Email }); // Check if the retrieved user info contains the first name and last name string firstName = (!String.IsNullOrWhiteSpace(userInfo.GivenName)) ? userInfo.GivenName : null; string lastName = (!String.IsNullOrWhiteSpace(userInfo.FamilyName)) ? userInfo.FamilyName : null; // Attempt to create a new user this.CreateUser(UserType.Customer, sources, firstName, null, lastName); }