summaryrefslogtreecommitdiff
path: root/src/scm/webid-oidc/authorization-page.scm
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-08-09 18:46:48 +0200
committerVivien Kraus <vivien@planete-kraus.eu>2021-08-13 01:06:38 +0200
commitded10e28782f289ad3db15320bcf619ab4336876 (patch)
tree32609fd9f1eb0d2f8a23105e09f193827d16a275 /src/scm/webid-oidc/authorization-page.scm
parent7b62790238902e10edb83c07286cf0643b097997 (diff)
Switch to a more sensible error reporting system
Diffstat (limited to 'src/scm/webid-oidc/authorization-page.scm')
-rw-r--r--src/scm/webid-oidc/authorization-page.scm91
1 files changed, 36 insertions, 55 deletions
diff --git a/src/scm/webid-oidc/authorization-page.scm b/src/scm/webid-oidc/authorization-page.scm
index 453275b..536137e 100644
--- a/src/scm/webid-oidc/authorization-page.scm
+++ b/src/scm/webid-oidc/authorization-page.scm
@@ -1,4 +1,4 @@
-;; webid-oidc, implementation of the Solid specification
+;; disfluid, implementation of the Solid specification
;; Copyright (C) 2020, 2021 Vivien Kraus
;; This program is free software: you can redistribute it and/or modify
@@ -16,60 +16,41 @@
(define-module (webid-oidc authorization-page)
#:use-module (webid-oidc errors)
+ #:use-module ((webid-oidc web-i18n) #:prefix i18n:)
#:use-module ((webid-oidc authorization-page-unsafe) #:prefix unsafe:)
- #:use-module (ice-9 i18n)
#:use-module (ice-9 string-fun)
#:use-module (ice-9 receive)
- #:use-module (ice-9 threads))
-
-(define locale-mutex
- (make-mutex))
-
-(define-syntax with-locale
- (syntax-rules ()
- ((with-locale web-locale . job)
- (let ((locale-with-underscore
- (if (equal? web-locale "C")
- ;; For the unit tests
- "C"
- (string-append
- (string-replace-substring web-locale "-" "_")
- ".UTF-8")))
- (previous-locale (setlocale LC_ALL)))
- (dynamic-wind
- (lambda ()
- (lock-mutex locale-mutex))
- (lambda ()
- (dynamic-wind
- (lambda ()
- (with-exception-handler
- (lambda (error)
- (raise-unknown-client-locale web-locale locale-with-underscore)
- (setlocale LC_ALL "C"))
- (lambda ()
- (setlocale LC_ALL locale-with-underscore))
- #:unwind? #t))
- (lambda () . job)
- (lambda ()
- (setlocale LC_ALL previous-locale))))
- (lambda ()
- (unlock-mutex locale-mutex)))))))
-
-(define-public (authorization-page
- locale credential-invalid? client-id post-uri)
- (with-locale
- locale
- (unsafe:authorization-page credential-invalid?
- client-id post-uri)))
-
-(define-public (error-no-client-id locale)
- (with-locale locale (unsafe:error-no-client-id)))
-
-(define-public (error-no-redirect-uri locale)
- (with-locale locale (unsafe:error-no-redirect-uri)))
-
-(define-public (error-application locale error)
- (with-locale locale (unsafe:error-application error)))
-
-(define-public (redirection locale client-id uri)
- (with-locale locale (unsafe:redirection client-id uri)))
+ #:use-module (ice-9 threads)
+ #:declarative? #t
+ #:export
+ (
+
+ authorization-page
+ error-no-client-id
+ error-no-redirect-uri
+ error-application
+ redirection
+
+ ))
+
+(define (authorization-page
+ locale credential-invalid? client-id post-uri)
+ (parameterize ((i18n:web-locale locale))
+ (unsafe:authorization-page credential-invalid?
+ client-id post-uri)))
+
+(define (error-no-client-id locale)
+ (parameterize ((i18n:web-locale locale))
+ (unsafe:error-no-client-id)))
+
+(define (error-no-redirect-uri locale)
+ (parameterize ((i18n:web-locale locale))
+ (unsafe:error-no-redirect-uri)))
+
+(define (error-application locale error)
+ (parameterize ((i18n:web-locale locale))
+ (unsafe:error-application error)))
+
+(define (redirection locale client-id uri)
+ (parameterize ((i18n:web-locale locale))
+ (unsafe:redirection client-id uri)))