summaryrefslogtreecommitdiff
path: root/src/scm/webid-oidc/client/gui/accounts-widget-logic.scm
diff options
context:
space:
mode:
Diffstat (limited to 'src/scm/webid-oidc/client/gui/accounts-widget-logic.scm')
-rw-r--r--src/scm/webid-oidc/client/gui/accounts-widget-logic.scm75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/scm/webid-oidc/client/gui/accounts-widget-logic.scm b/src/scm/webid-oidc/client/gui/accounts-widget-logic.scm
new file mode 100644
index 0000000..2ea9024
--- /dev/null
+++ b/src/scm/webid-oidc/client/gui/accounts-widget-logic.scm
@@ -0,0 +1,75 @@
+;; disfluid, implementation of the Solid specification
+;; Copyright (C) 2021 Vivien Kraus
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU Affero General Public License as
+;; published by the Free Software Foundation, either version 3 of the
+;; License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU Affero General Public License for more details.
+
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+(define-module (webid-oidc client gui accounts-widget-logic)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 exceptions)
+ #:use-module (ice-9 i18n)
+ #:use-module (ice-9 receive)
+ #:use-module (ice-9 optargs)
+ #:use-module (ice-9 pretty-print)
+ #:use-module (ice-9 threads)
+ #:use-module (srfi srfi-9)
+ #:use-module (srfi srfi-19)
+ #:use-module (srfi srfi-26)
+ #:use-module (webid-oidc errors)
+ #:use-module ((webid-oidc parameters) #:prefix p:)
+ #:use-module ((webid-oidc stubs) #:prefix stubs:)
+ #:use-module ((webid-oidc config) #:prefix config:)
+ #:use-module (webid-oidc web-i18n)
+ #:use-module (webid-oidc offloading)
+ #:use-module (webid-oidc client client)
+ #:use-module (webid-oidc client accounts)
+ #:use-module (webid-oidc client gui account-widget)
+ #:use-module ((webid-oidc client gui settings) #:prefix settings:)
+ #:use-module ((webid-oidc client gui clock) #:prefix clock:)
+ #:use-module (webid-oidc client gui application-hooks)
+ #:use-module (webid-oidc client gui authorizations-widget)
+ #:use-module (webid-oidc jwk)
+ #:use-module (webid-oidc oidc-id-token)
+ #:use-module (web uri)
+ #:use-module (web response)
+ #:use-module (rnrs bytevectors)
+ #:use-module (oop goops)
+ #:declarative? #t
+ #:duplicates (merge-generics)
+ #:export
+ (
+ add-account-button-clicked
+ ))
+
+(define (add-account-button-clicked issuer clear-issuer-entry!)
+ (define (as-host-name host)
+ (false-if-exception
+ (build-uri 'https #:host host)))
+ (match issuer
+ ((or (? string? (= string->uri (? uri? uri)))
+ (? string? (= as-host-name (? uri? uri))))
+ (clear-issuer-entry!)
+ (use-authorizations-widget
+ (lambda ()
+ (let ((new-account
+ (make <account>
+ #:issuer uri)))
+ (clock:wait
+ (lambda ()
+ (let ((old (settings:main-account))
+ (other (settings:other-accounts)))
+ (if old
+ (settings:other-accounts `(,new-account ,@other))
+ (settings:main-account new-account)))))))))
+ (else
+ (format (current-error-port) (G_ "Stub: please enter an URI or a host name...\n")))))