Skip to content

Commit

Permalink
Merge pull request #100 from Andreev-Sergey/FixPassEncoding
Browse files Browse the repository at this point in the history
Fix Auth v3 when password contains Cyrillic characters
  • Loading branch information
Vladislav Skukov authored Dec 24, 2019
2 parents b0769a1 + f5f5ef0 commit c50c5ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/DiadocApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,10 @@ void DiadocApi::Authenticate(const std::wstring& login, const std::wstring& pass
wss << L"/V3/Authenticate?type=password" << std::flush;
Diadoc::Api::Proto::LoginPassword loginPassword;

loginPassword.set_login(std::string(login.begin(), login.end()));
loginPassword.set_password(std::string(password.begin(), password.end()));
static std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8conv;

loginPassword.set_login(utf8conv.to_bytes(login));
loginPassword.set_password(utf8conv.to_bytes(password));

auto response = PerformHttpRequestString(wss.str(), ToProtoBytes(loginPassword), POST);
token_ = StringHelper::Utf8ToUtf16(response);
Expand Down
2 changes: 2 additions & 0 deletions src/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@

#include <tchar.h>
#include <strsafe.h>
#include <locale>
#include <codecvt>
#include "trace.h"

0 comments on commit c50c5ce

Please sign in to comment.