[gnome-software] snap: Set the GS auth required error code when we need auth



commit deeb15208b9d3120d3614e6d00d53ff5f415db3b
Author: Iain Lane <iain orangesquash org uk>
Date:   Mon Jun 26 16:14:37 2017 +0100

    snap: Set the GS auth required error code when we need auth
    
    With the previous commit, this causes GS to prompt the user to log in if
    they're not when they try to install a snap.

 plugins/snap/gs-plugin-snap.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/plugins/snap/gs-plugin-snap.c b/plugins/snap/gs-plugin-snap.c
index b268a13..c5fa846 100644
--- a/plugins/snap/gs-plugin-snap.c
+++ b/plugins/snap/gs-plugin-snap.c
@@ -542,6 +542,8 @@ gs_plugin_app_install (GsPlugin *plugin,
 {
        g_autoptr(SnapdClient) client = NULL;
 
+       g_autoptr (GError) local_error = NULL;
+
        /* We can only install apps we know of */
        if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0)
                return TRUE;
@@ -550,7 +552,13 @@ gs_plugin_app_install (GsPlugin *plugin,
        client = get_client (plugin, cancellable, error);
        if (client == NULL)
                return FALSE;
-       if (!snapd_client_install_sync (client, gs_app_get_id (app), NULL, progress_cb, app, cancellable, 
error)) {
+       if (!snapd_client_install_sync (client, gs_app_get_id (app), NULL, progress_cb, app, cancellable, 
&local_error)) {
+               if (local_error && local_error->code == SNAPD_ERROR_AUTH_DATA_REQUIRED) {
+                       g_set_error_literal (error,
+                                            GS_PLUGIN_ERROR,
+                                            GS_PLUGIN_ERROR_AUTH_REQUIRED,
+                                            "Requires authentication with @snapd");
+               }
                gs_app_set_state_recover (app);
                return FALSE;
        }


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