示例#1
0
        /// <summary>
        /// Business logic for registering accounts from Single Sign On.
        /// </summary>
        /// <param name="registrationDto"></param>
        /// <returns></returns>
        public HttpResponseMessage RegisterPartialAccount(SsoRegistrationRequestDTO registrationDto)
        {
            // Validation Step
            if (_partialAccountLogic.Exists(registrationDto.Username) ||
                _accountLogic.Exists(registrationDto.Username))
            {
                return(new HttpResponseMessage(HttpStatusCode.Conflict));
            }

            // Add new PartialAccount to the database
            var partialAccount = new PartialAccount()
            {
                UserName    = registrationDto.Username,
                Password    = registrationDto.HashedPassword,
                AccountType = registrationDto.RoleType
            };

            // Add new attached Salt to the database connected with PartialAccount.
            var salt = new PartialAccountSalt()
            {
                PasswordSalt   = registrationDto.PasswordSalt,
                UserName       = registrationDto.Username,
                PartialAccount = partialAccount
            };

            _partialAccountSaltLogic.Create(salt);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
示例#2
0
        private HttpResponseMessage PartialAccountResetPasswordHelper(SsoResetPasswordRequestDTO resetPasswordDto,
                                                                      PartialAccount partialAccount)
        {
            // Update password for account
            partialAccount.Password = resetPasswordDto.HashedNewPassword;
            _partialAccountLogic.Update(partialAccount);

            // Update salt table related to account
            var partialAccountSalt = _partialAccountSaltLogic.GetSingle(resetPasswordDto.Username);

            partialAccountSalt.PasswordSalt = resetPasswordDto.PasswordSalt;
            _partialAccountSaltLogic.Update(partialAccountSalt);

            return(new HttpResponseMessage(HttpStatusCode.OK));
        }
示例#3
0
        public void AccountToPartial()
        {
            Account account = new Account();

            account.Id          = RandomGuid();
            account.Alias       = RandomGuidString();
            account.CreatedDate = RandomDate();
            account.User        = GetFullUser();

            AccountToPartialAccountMap map     = new AccountToPartialAccountMap();
            PartialAccount             partial = map.Create(account);

            Assert.IsNotNull(partial);
            Assert.AreEqual(account.Alias, partial.Alias);
            AssertEqual(account.User, partial.User);
        }
示例#4
0
        /// <summary>
        /// Login for PartialAccount route.
        /// </summary>
        /// <param name="loginDto"></param>
        /// <param name="partialAccount"></param>
        /// <returns></returns>
        private HttpResponseMessage PartialAccountLoginHelper(SsoLoginRequestDTO loginDto, PartialAccount partialAccount)
        {
            // Provide Partial Account RoleType
            loginDto.RoleType = partialAccount.AccountType;

            // Generate our token for them.
            var partialAccountToken = SsoJwtManager.Instance.GenerateToken(loginDto);

            return(new HttpResponseMessage
            {
                Content = new StringContent(UrlConstants.BaseAppClient + "partial-registration?jwt=" + partialAccountToken),
                StatusCode = HttpStatusCode.OK
            });
        }
示例#5
0
 public void Delete(PartialAccount partialAccount)
 {
     _partialAccountRepository.Delete(partialAccount);
 }
示例#6
0
 public void Update(PartialAccount partialAccount)
 {
     _partialAccountRepository.Update(partialAccount);
 }
示例#7
0
 public void Create(PartialAccount partialAccount)
 {
     _partialAccountRepository.Insert(partialAccount);
 }