summaryrefslogtreecommitdiff
path: root/libpurple
diff options
context:
space:
mode:
authorGary Kramlich <grim@reaperworld.com>2023-03-10 01:10:24 -0600
committerGary Kramlich <grim@reaperworld.com>2023-03-10 01:10:24 -0600
commit36dee2d7f7b622d9e1ecf873b4bfa4779179e13d (patch)
tree6e7bebebddd551d41fd31076bdea2b652c8f57d0 /libpurple
parent0dac061bb1aedad6a67b9954d52d194be6294219 (diff)
downloadpidgin-36dee2d7f7b622d9e1ecf873b4bfa4779179e13d.tar.gz
IRCv3: Set the SASL login name to the current nick if not set during connection
This _should_ help users make sure they authenticate as the correct user. They are still able to manually specify a SASL Login Name, but if it isn't set when a connection is attempted, it will be set to the nick defined on the account. This should also fix the scenario where a user is adding the account to Pidgin but already has the same account connected because the login name will be the nick they entered not the one that's chosen if there's a nick collision. Testing Done: Connected an IRCv3 account with the `SASL Login Name` unset and verified it was set after connecting. Then set the `SASL Login Name` to something else, attempted connection, verified a SASL failure and verified that the `SASL Login Name` changed persisted. Reviewed at https://reviews.imfreedom.org/r/2329/
Diffstat (limited to 'libpurple')
-rw-r--r--libpurple/protocols/ircv3/purpleircv3connection.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libpurple/protocols/ircv3/purpleircv3connection.c b/libpurple/protocols/ircv3/purpleircv3connection.c
index 5520103fb1..70c00667c3 100644
--- a/libpurple/protocols/ircv3/purpleircv3connection.c
+++ b/libpurple/protocols/ircv3/purpleircv3connection.c
@@ -423,8 +423,9 @@ purple_ircv3_connection_constructed(GObject *obj) {
PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(obj);
PurpleIRCv3ConnectionPrivate *priv = NULL;
PurpleAccount *account = NULL;
- gchar **userparts = NULL;
- const gchar *username = NULL;
+ char **userparts = NULL;
+ const char *sasl_name = NULL;
+ const char *username = NULL;
G_OBJECT_CLASS(purple_ircv3_connection_parent_class)->constructed(obj);
@@ -437,6 +438,16 @@ purple_ircv3_connection_constructed(GObject *obj) {
purple_connection_set_display_name(PURPLE_CONNECTION(connection),
userparts[0]);
priv->server_name = g_strdup(userparts[1]);
+
+ /* Check if the SASL login name is not set. If it isn't set, set it to the
+ * current nick.
+ */
+ sasl_name = purple_account_get_string(account, "sasl-login-name", "");
+ if(purple_strempty(sasl_name)) {
+ purple_account_set_string(account, "sasl-login-name", userparts[0]);
+ }
+
+ /* Free the userparts vector. */
g_strfreev(userparts);
/* Finally create our objects. */