aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 81b9296..2c40580 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -5302,11 +5302,15 @@ namespace QuickMedia {
homeserver = "https://" + homeserver;
std::string err_msg;
- std::string username = login_inputs->inputs[0]->get_text();
- size_t at_index = username.find('@');
- if(at_index != std::string::npos)
- username.erase(username.begin() + at_index, username.end());
- if(matrix->login(username, login_inputs->inputs[1]->get_text(), homeserver, err_msg) == PluginResult::OK) {
+ std::string username = strip(login_inputs->inputs[0]->get_text());
+ std::string username_matrix_id = extract_user_name_from_user_id(username);
+ if(username_matrix_id.empty()) {
+ username_matrix_id = extract_user_name_from_email(username);
+ if(username_matrix_id.empty())
+ username_matrix_id = username;
+ }
+
+ if(matrix->login(username_matrix_id, login_inputs->inputs[1]->get_text(), homeserver, err_msg) == PluginResult::OK) {
login_finish();
return PluginResult::OK;
} else {