Пример #1
0
        public RegistrationResult InvalidApplication(string reason)
        {
            var result = new RegistrationResult();

            CurrentApplication.Status      = ApplicationStatus.Invalid;
            result.Application             = CurrentApplication;
            result.Application.UserMessage = reason;
            return(result);
        }
Пример #2
0
        public RegistrationResult ApplyForMembership(Application app)
        {
            var result = new RegistrationResult();

            CurrentApplication             = app;
            result.Application             = app;
            result.Application.UserMessage = "Welcome!";

            if (EmailOrPasswordNotPresent())
            {
                return(InvalidApplication(Properties.Resources.EmailOrPasswordMissing));
            }

            if (EmailIsInvalid())
            {
                return(InvalidApplication(Properties.Resources.InvalidEmailMessage));
            }

            if (PasswordIsInvalid())
            {
                return(InvalidApplication(Properties.Resources.InvalidPassword));
            }

            if (!PasswordMatchesConfirmation())
            {
                return(InvalidApplication(Properties.Resources.PasswordConfirmationMissmatch));
            }

            if (EmailAlreadyRegistered())
            {
                return(InvalidApplication(Properties.Resources.EmailExists));
            }

            result.NewUser = AcceptApplication();
            var auth = new Authenticator().AuthenticateUser(new Credentials {
                Email = result.NewUser.Email, Password = CurrentApplication.Password
            });

            result.SessionToken = auth.Session.Id;
            return(result);
        }