Exemplo n.º 1
0
        void ICredentialStore.CreateUser(string username, string password, string[] roles, string email, bool verified)
        {
            UserContainer userContainer = GetUserContainer(true);
            RoleContainer roleContainer = GetRoleContainer(true);

            User user = new User
            {
                Name = username,
                Password = password,
                Email = email,
                Verified = verified
            };
            foreach (string role in roles)
                user.RolesInternal.Add(roleContainer.GetRole(role));
            user.AddTo(userContainer);

            Context.Persister.Save(user);
        }
Exemplo n.º 2
0
 public UserRegisteredEventArgs(User user, object registrationForm)
 {
     User = user;
     RegistrationForm = registrationForm;
 }
Exemplo n.º 3
0
 public void VerifyUser(User user)
 {
     User typedUser = (User) user;
     typedUser.Nonce = null;
     typedUser.Verified = true;
     _persister.Save(typedUser);
 }
Exemplo n.º 4
0
 public void SaveNonce(User user, string nonce)
 {
     User typedUser = (User) user;
     typedUser.Nonce = nonce;
     typedUser.Verified = false;
     _persister.Save(typedUser);
 }
Exemplo n.º 5
0
        public UserVerificationResult Verify(string nonce, out User user)
        {
            if (string.IsNullOrEmpty(nonce))
                throw new ArgumentNullException("nonce");

            // Get user from store matching nonce.
            user = _store.GetUserByNonce(nonce);
            if (user == null)
                return UserVerificationResult.NoMatchingUser;

            if (user.Verified)
                return UserVerificationResult.AlreadyVerified;

            _store.VerifyUser(user);
            return UserVerificationResult.Verified;
        }
Exemplo n.º 6
0
        public void SendVerificationEmail(User user, string linkRoot, string recipientEmail,
			string senderEmail, string emailSubject, string emailBody)
        {
            // Check that emailBody contains {VERIFICATIONLINK}.
            if (!emailBody.Contains(VerificationLinkName))
                throw new ArgumentException("Email body must contain " + VerificationLinkName, "emailBody");

            // Construct nonce.
            string nonce = NonceUtility.GenerateNonce();
            string verificationLink = linkRoot + HttpUtility.UrlEncode(nonce);

            // Save nonce.
            _store.SaveNonce(user, nonce);

            // Construct email.
            emailBody = emailBody.Replace(VerificationLinkName, verificationLink);

            try
            {
                _mailSender.Send(senderEmail, recipientEmail, emailSubject, emailBody);
            }
            catch (Exception ex)
            {
                throw new ZeusException("Failed to send verification email to '" + recipientEmail + "'", ex);
            }
        }
Exemplo n.º 7
0
 public WebPrincipal(User membershipUser, FormsAuthenticationTicket ticket)
     : base(new WebIdentity(ticket), membershipUser.Roles)
 {
     MembershipUser = membershipUser;
 }