public async Task <ActionResult> ConfirmCode(string code) { string sessionID = CookieHelper.PBSessionID; PBPersonSessionDto personSession = await this.privatBankManager.ConfirmSmsCodeAsync(sessionID, code); if (personSession != null) { this.Login(personSession.ID); } return(this.RedirectToAction("Index", "Home", null)); }
public async Task <ActionResult> SelectNumber(string numberId) { ActionResult result = null; string sessionID = CookieHelper.PBSessionID; PBPersonSessionDto personSession = await this.privatBankManager.SelectNumber(sessionID, numberId); if (personSession != null) { CookieHelper.PBSessionID = personSession.ID; result = this.RedirectToAction("ConfirmCode", "Account"); } return(result); }
public async Task <PBPersonSessionDto> GetPersonSessionAsyncTest(string sessionId, string login, string password) { string apiEndpoint = "api/p24BusinessAuth/createSession"; Dictionary <string, string> parameters = new Dictionary <string, string>() { { "sessionId", sessionId }, { "login", login }, { "password", password } }; string test = await this.GetPOSTResponseStringAsync(apiEndpoint, parameters); //string test = "{\"id\":\"session-id\",\"clientId\":\"client-id\",\"expiresIn\":1418703284,\"message\":[{\"id\":\"1111111\",\"number\":\"050...111\"},{\"id\":\"1111112\",\"number\":\"068...112\"},{\"id\":\"1111112\",\"number\":\"095...113\"}],\"roles\":[\"ROLE_CLIENT\"]}"; dynamic test1 = JsonConvert.DeserializeObject <dynamic>(test); PBPersonSessionDto personSessionDto = new PBPersonSessionDto(); personSessionDto.ID = test1.id; personSessionDto.ClientId = test1.clientId; personSessionDto.ExpiresIn = test1.expiresIn; if (test1.message.Type == JTokenType.String) { personSessionDto.Message = test1.message; } else if (test1.message.Type == JTokenType.Array) { foreach (dynamic test2 in test1.message) { personSessionDto.PhoneNumbers.Add(new PBPersonSessionDto.PhoneNumber() { Id = test2.id, Number = test2.number, }); } } else { throw new Exception("Something went wrong with PB API."); } return(personSessionDto); }
public async Task <ActionResult> LoginToPB(string login, string password) { ActionResult result = null; PBSessionDto session = await this.privatBankManager.GetSessionAsync(); PBPersonSessionDto personSession = await this.privatBankManager .GetPersonSessionAsync(session.ID, login, password); if (string.IsNullOrEmpty(personSession.Message)) { CookieHelper.PBSessionID = personSession.ID; List <PhoneNumberViewModel> numbers = new List <PhoneNumberViewModel>(); foreach (var number in personSession.PhoneNumbers) { numbers.Add(new PhoneNumberViewModel() { Id = number.Id, Number = number.Number, }); } result = this.View("SelectNumber", numbers.ToArray()); } else if (personSession.Message.StartsWith("Authentication successful")) { this.Login(personSession.ID); result = this.RedirectToAction("Index", "Home", null); } else { CookieHelper.PBSessionID = personSession.ID; result = this.RedirectToAction("ConfirmCode", "Account"); } return(result); }