Ejemplo n.º 1
0
        public void Handle(YodleeLoginUserCommand handledCommand)
        {
            InfoAccumulator info = new InfoAccumulator();

            if (!ValidateModel(handledCommand, info))
            {
                SendReply(info, handledCommand);
                return;
            }

            YodleeLoginUser3dPartyCommand commandToSend = CreateLoginUserCommand(handledCommand);

            SendCommand(ThirdPartyService.Address, commandToSend, handledCommand);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the login user command.
        /// First goes to DB to fetch available account and then populates command with fetched parameters
        /// </summary>
        /// <param name="handledCommand">The handled command.</param>
        /// <returns></returns>
        private YodleeLoginUser3dPartyCommand CreateLoginUserCommand(YodleeLoginUserCommand handledCommand)
        {
            YodleeUserAccount userAccount = YodleeQueries.BookUserAccount(handledCommand.CustomerId);

            YodleeLoginUser3dPartyCommand commandToSend = new YodleeLoginUser3dPartyCommand
            {
                PasswordEncrypted = userAccount.Password,
                UserName          = userAccount.Username,
                MessageId         = handledCommand.MessageId,
                CobrandToken      = handledCommand.CobrandToken,

                CustomerId = handledCommand.CustomerId, //stores 'state' to be able to book another user account if yodlee return error on login
                SiteId     = handledCommand.SiteId      //stores 'state' to be able to book another user account if yodlee return error on login
            };

            return(commandToSend);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Handle(YodleeLoginUser3dPartyCommand command)
        {
            InfoAccumulator info = new InfoAccumulator();

            if (ValidateModel(command, info))
            {
                SendReply(info, command);
                return;
            }

            //created request
            YUserLoginRequest loginRequest = new YUserLoginRequest()
                                             .SetCobrandSessionToken(command.CobrandToken)
                                             .SetUserName(command.UserName)
                                             .SetUserPassword(EncryptionUtils.Decrypt(command.PasswordEncrypted));

            //send REST request to yodlee
            var yUserLoginResponse = Yodlee.LoginUser(loginRequest)
                                     .Result;

            //handle yodlee response
            if (yUserLoginResponse.HasError)
            {
                string errorMessage = yUserLoginResponse.GetError()
                                      .ErrorMessage;

                Log.Error(errorMessage);
                info.AddError(errorMessage);
            }

            SendReply(info, command, resp => {
                if (!yUserLoginResponse.HasError)
                {
                    resp.UserToken     = yUserLoginResponse.userContext.conversationCredentials.sessionToken;
                    resp.IsLoginFailed = false;
                }
                else
                {
                    resp.IsLoginFailed = true;
                }
            });
        }
Ejemplo n.º 4
0
        public void Handle(YodleeLoginUser3dPartyCommandResponse handledResponse)
        {
            //at this point command not failed but may get error (failed user login)
            if (handledResponse.IsLoginFailed)
            {
                //recover state
                YodleeLoginUserCommand fakeCommand = new YodleeLoginUserCommand {
                    CustomerId = handledResponse.CustomerId, //recovers saved state
                    SiteId     = handledResponse.SiteId,     //recovers saved state
                };

                YodleeLoginUser3dPartyCommand commandToSend = CreateLoginUserCommand(fakeCommand);

                //copies infrastructure related info, to insure proper error handling
                CopyHeaders(@from: handledResponse, to: commandToSend);
                Bus.Send(ThirdPartyService.Address, commandToSend);
            }
            else
            {
                ReplyToOrigin(handledResponse, resp => {
                    resp.UserToken = handledResponse.UserToken;
                });
            }
        }