[gnome-notes/fix-nextcloud-user-domain: 6/6] nextcloud-provider: change how to get user domain




commit 9395fdd89538521cba1b0fdf2e494a3bd01966c8
Author: Isaque Galdino <igaldino gmail com>
Date:   Wed Jun 9 10:07:39 2021 -0300

    nextcloud-provider: change how to get user domain
    
    In the past, the NextCloud user and domain(server) information were used
    for display only.
    
    With the change to call the NextCloud REST API directly, that
    information is also used to authenticate the user with the cloud provider.
    
    There was an issue when we had a '@' in the user id, e.g. user@email
    because the code was extracting that from the GOA presentation identity
    field which concats the user with the domain using a '@' as well, e.g.
    user@email@domain.
    
    When the code was split it to get user and domain, the information was
    messed up with user being 'user' and domain being 'email@domain'.
    
    Fix issue #171

 src/libbiji/provider/biji-nextcloud-provider.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)
---
diff --git a/src/libbiji/provider/biji-nextcloud-provider.c b/src/libbiji/provider/biji-nextcloud-provider.c
index 9ca091ae..e1c9d341 100644
--- a/src/libbiji/provider/biji-nextcloud-provider.c
+++ b/src/libbiji/provider/biji-nextcloud-provider.c
@@ -232,8 +232,6 @@ constructed (GObject *object)
 {
   BijiNextcloudProvider *self = (BijiNextcloudProvider *)object;
   GoaAccount *account = NULL;
-  const char *goa_id;
-  g_auto(GStrv) bjb_id = NULL;
   GoaPasswordBased *goa_pass = NULL;
   g_autoptr (GIcon) icon = NULL;
   g_autoptr (GError) error = NULL;
@@ -259,30 +257,14 @@ constructed (GObject *object)
   self->info.datasource = g_strdup_printf ("gn:goa-account:%s", self->info.unique_id);
   self->info.name = g_strdup (goa_account_get_provider_name (account));
 
-  goa_id = goa_account_get_presentation_identity (account);
-  if (goa_id)
-    {
-      bjb_id = g_strsplit (goa_id, "@", 2);
-      if (bjb_id[0])
-        {
-          self->info.user = g_strdup (bjb_id[0]);
-          if (bjb_id[1])
-            self->info.domain = g_strdup (bjb_id[1]);
-        }
-    }
+  self->info.user = g_strdup (goa_account_get_identity (account));
+  self->info.domain = g_strdup (g_strrstr (goa_account_get_presentation_identity (account), "@") + 1);
   if (!self->info.user || !self->info.domain)
     {
       biji_provider_abort (BIJI_PROVIDER (self));
       return;
     }
 
-  if (!goa_account_call_ensure_credentials_sync (account, NULL, NULL, NULL))
-    {
-      g_debug ("FAILED: goa_account_call_ensure_credentials_sync");
-      biji_provider_abort (BIJI_PROVIDER (self));
-      return;
-    }
-
   goa_pass = goa_object_peek_password_based (self->goa);
   if (!goa_pass ||
       !goa_password_based_call_get_password_sync (goa_pass,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]