Skip to content

Commit

Permalink
Merge pull request #58 from saidone75/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
saidone75 authored May 24, 2024
2 parents 40a99b7 + 8ad217d commit e2eaae2
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/weller/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,28 @@
(reset! config (parse-values @config resolve-placeholder)))
(catch Exception e (t/log! :warn (.getMessage e)))))

(defn ticket
"Validates and returns the ticket in `config` atom if present, otherwise returns a new one and stores it in `config`."
[]
(let [ticket (get-in @config [:alfresco :ticket])]
(if (= (:status (auth/validate-ticket ticket)) 200)
ticket
(get-in
(swap! config assoc :alfresco
(assoc (:alfresco @config)
:ticket
(get-in (auth/create-ticket
(get-in @config [:alfresco :user])
(get-in @config [:alfresco :password]))
[:body :entry])))
[:alfresco :ticket]))))

(defn configure
[]
(run!
load-cfg-file
(map expand-home cfg-files))
;; configure CRAL
(cral.config/configure (:alfresco @config))
;; authenticate on Alfresco and store ticket
(swap! config assoc :alfresco
(assoc (:alfresco @config) :ticket (get-in (auth/create-ticket (get-in @config [:alfresco :user]) (get-in @config [:alfresco :password])) [:body :entry])))
(t/log! :trace @config))

(defn ticket
;; TODO
;; - validate ticket
;; - if expired request e new one
[]
(get-in @config [:alfresco :ticket]))
(ticket)
(t/log! :trace @config))

0 comments on commit e2eaae2

Please sign in to comment.