Skip to content

Commit

Permalink
added ui token expiry-date
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei committed Jan 13, 2025
1 parent cba4dcd commit 4eeffe5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/efactura_mea/db/db_ops.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
(defn fetch-company-refresh-token [db cif]
(:refresh_token (first (f/select-company-token-data db {:cif cif}))))

(defn fetch-company-token-expiration-date [db cif]

This comment has been minimized.

Copy link
@ieugen

ieugen Jan 13, 2025

Member

Ce se întâmplă cu funcția asta dacă nu are activată integrarea?

(:expiration_date (first (f/select-company-token-data db {:cif cif}))))

(defn fetch-mesaje [db cif page per-page]
(let [offset-num (* (dec page) per-page)]
(f/select-facturi-descarcate db {:cif cif :limit per-page :offset offset-num})))
Expand Down
11 changes: 10 additions & 1 deletion src/efactura_mea/web/anaf_integrare.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
[hiccup2.core :as h]
[muuntaja.core :as m]
[reitit.core :as r]
[ring.util.response :as rur]))
[ring.util.response :as rur]
[java-time.api :as jt])
(:import
[java.time.temporal ChronoUnit]))

;; todo:
;; - funcționalitate de revocare a tokenului - în caz de compromitere
Expand Down Expand Up @@ -177,6 +180,12 @@
(log/info e (str "Exception" (ex-cause e)))
(throw e))))))

(defn days-until-expiration [expiration-str]
(let [now (jt/local-date-time)
expiration (jt/zoned-date-time expiration-str)
days-difference (.between ChronoUnit/DAYS now expiration)]
days-difference))

(defn routes
[anaf-conf]
[["/login-anaf" (o2a/make-anaf-login-handler
Expand Down
13 changes: 8 additions & 5 deletions src/efactura_mea/web/companii/profil.clj
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
(ns efactura-mea.web.companii.profil
(:require
[efactura-mea.web.ui.componente :as ui :refer [title details-table]]
[efactura-mea.db.db-ops :as db :refer [get-company-data]]
[efactura-mea.db.facturi :as facturi :refer [select-acc-token-exp-date]]
[hiccup2.core :as h]))
[efactura-mea.db.db-ops :as db
:refer [get-company-data fetch-company-token-expiration-date]]
[hiccup2.core :as h]
[java-time.api :as jt]))

(defn afisare-profil-companie
[req]
(let [{:keys [path-params ds]} req
{:keys [cif]} path-params
company (get-company-data ds cif)
token-expiration-date (select-acc-token-exp-date ds {:cif cif})
token-expiration-date (fetch-company-token-expiration-date ds cif)
parse-exp-date (jt/zoned-date-time token-expiration-date)
{:keys [name website address desc_aut_status date_modified]} company
descarcare-automata-status (h/html [:span.has-text-weight-bold.is-uppercase desc_aut_status] " - " [:span.is-size-6 date_modified])
descarcare-automata-url (str "/descarcare-automata/" cif)
Expand All @@ -27,4 +29,5 @@
[:a {:href website} website]]]]
[:div.columns
[:div.column
(details-table {"Companie:" name "CIF:" cif "Website:" website "Adresă:" address "Dată expirare access_token: " token-expiration-date "Descărcare automată:" [:div#das descarcare-automata-link descarcare-automata-status]})]])))
(details-table {"Companie:" name "CIF:" cif "Website:" website "Adresă:" address "Dată expirare access_token: " parse-exp-date "Descărcare automată:" [:div#das descarcare-automata-link descarcare-automata-status]})]])))

0 comments on commit 4eeffe5

Please sign in to comment.