public override MembershipUser GetUser(string username, bool userIsOnline)
 {
     return(Cache.GetValue(username, (un) =>
     {
         N2.Security.Items.User u = Bridge.GetUser(username);
         if (u != null)
         {
             return u.GetMembershipUser(this.Name);
         }
         return null;
     }));
 }
Exemplo n.º 2
0
 public override MembershipUser GetUser(string username, bool userIsOnline)
 {
     N2.Security.Items.User u = Bridge.GetUser(username);
     if (u != null)
     {
         if (userIsOnline)
         {
             u.LastActivityDate = DateTime.Now;
             Bridge.Save(u);                     // JH
         }
         return(u.GetMembershipUser(this.Name));
     }
     return(null);
 }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            N2.Security.Items.User u = Bridge.GetUser(username);
            if (u != null)
            {
                status = MembershipCreateStatus.DuplicateUserName;
                return(null);
            }
            if (string.IsNullOrEmpty(username))
            {
                status = MembershipCreateStatus.InvalidUserName;
                return(null);
            }
            if (string.IsNullOrEmpty(password))
            {
                status = MembershipCreateStatus.InvalidPassword;
                return(null);
            }

            // TODO: RequiresUniqueEmail validation

            var args = new ValidatePasswordEventArgs(username, password, true);

            OnValidatingPassword(args);
            if (args.Cancel)
            {
                throw new MembershipCreateUserException("Create user cancelled", args.FailureInformation);
            }

            status = MembershipCreateStatus.Success;
            u      = Bridge.CreateUser(username, ToStoredPassword(password),        // JH
                                       email, passwordQuestion, passwordAnswer, isApproved, providerUserKey);

            Cache.Expire();
            MembershipUser m = u.GetMembershipUser(this.Name);

            return(m);
        }