Skip to content

Commit

Permalink
0.6.0 Fix basic-auth sign in; improve UX of sign-in
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTom committed Jul 14, 2017
1 parent 61e261e commit 31e3795
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/dev/releases.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}]
[{"version_major":0,"version_minor":6,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Improve the UX of the sign-in page: swapping tags deletes existing sign in info.\n\nFixes\n=====\n\n* Fix sign in with login and password.\n"},{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}]
2 changes: 1 addition & 1 deletion app/prod/releases.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}]
[{"version_major":0,"version_minor":6,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Improve the UX of the sign-in page: swapping tags deletes existing sign in info.\n\nFixes\n=====\n\n* Fix sign in with login and password.\n"},{"version_major":0,"version_minor":5,"version_patch":0,"version_pre":null,"version_build":null,"name":null,"description":"\nChanges\n=======\n\n* Rename the application from \"Madek APP\" to \"Madek Exporter\".\n* Include release info.\n\nFixes\n=====\n\n* Fix export of meta-data of the Type MetaDatum::TextType.\n* Disconnect on the connection page will now delete the saved token, too.\n* Fix spelling and unnecessary involved language in many places.\n"}]
4 changes: 2 additions & 2 deletions bin/draft-gh-release
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def version
end

def commitish
JSON.parse(ENV['CIDER_CI_CURRENT_BRANCH_HEADS']).first.presence.try(:strip) \
|| `git log -n 1 --pretty='%H'`.strip
JSON.parse(ENV['CIDER_CI_CURRENT_BRANCH_HEADS'].presence || "[]").compact \
.first.presence.try(:strip) || `git log -n 1 --pretty='%H'`.strip
end

def create_data
Expand Down
69 changes: 44 additions & 25 deletions electron_front/src/all/madek/app/front/connection.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,8 @@
(when-let [p (.getPort gurl)]
(str ":" p)))))))

(defn compact-component []
[:span
(when-let [ce @connected-entity*]
[:span ce])
(when-let [ct @connected-target*]
[:span
"" ; utf-8 m-space!
[:span ct ]])])

(defn connect []
(let [req {:method :post
:json-params @form-data
:path "/connect"}]
(request/send-off
req {:title "Connect!"})))

(defn disconnect []
(let [req {:method :delete
:path "/connect"}]
(request/send-off
req {:title "Disconnect!"}
:callback (fn [_]
(swap! state/client-db assoc-in [:connection :form :password] nil)
(accountant/navigate! "/connection")))))
;;; data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn update-form-data [fun]
(swap! state/client-db
Expand All @@ -83,6 +61,42 @@
(reaction (or (:sign-in-method @form-data)
:token)))


;;; connect ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn compact-component []
[:span
(when-let [ce @connected-entity*]
[:span ce])
(when-let [ct @connected-target*]
[:span
"" ; utf-8 m-space!
[:span ct ]])])

(defn connect []
(let [req {:method :post
:json-params @form-data
:path "/connect"}]
(request/send-off
req {:title "Connect!"})))


;;; disconnect ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn clear-form-sign-in-data []
(update-form-data-value :login nil)
(update-form-data-value :password nil))

(defn disconnect []
(let [req {:method :delete
:path "/connect"}]
(request/send-off
req {:title "Disconnect!"}
:callback (fn [_]
(clear-form-sign-in-data)
(accountant/navigate! "/connection")))))


;;; form ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn base-url-form-component []
Expand Down Expand Up @@ -125,17 +139,22 @@
:on-change #(update-form-data-value
:password(-> % .-target .-value presence))}]])


(defn connect-form []
[:div.form
[base-url-form-component]
[:ul.nav.nav-tabs {:style {:margin-bottom "1em"}}
[:li {:class (when (= @sign-in-method* :token) "active")}
[:a {:href "#"
:on-click #(update-form-data-value :sign-in-method :token)}
:on-click (fn [_]
(clear-form-sign-in-data)
(update-form-data-value :sign-in-method :token))}
"Sign in with token"]]
[:li {:class (when (= @sign-in-method* :login) "active")}
[:a {:href "#"
:on-click #(update-form-data-value :sign-in-method :login)}
:on-click (fn [_]
(clear-form-sign-in-data)
(update-form-data-value :sign-in-method :login))}
"Sign in with login and password"]]]
[login-form-component]
[token-form-component]
Expand Down
2 changes: 1 addition & 1 deletion jvm_main/src/madek/app/server/connection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
;(logging-config/set-logger! :level :debug)
;(logging-config/set-logger! :level :info)
;(debug/debug-ns 'ring.middleware.resource)
(debug/debug-ns *ns*)
;(debug/debug-ns *ns*)
12 changes: 4 additions & 8 deletions jvm_main/src/madek/app/server/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@
(defn options-to-http-options [options]
(let [{login :login password :password
session-token :session-token} options]
(cond-> {}
(and (presence login)
(presence password)) (assoc :basic-auth
[login password])
(presence password) (assoc :basic-auth [password])
session-token (assoc :cookies
{"madek-session"
{:value session-token}}))))
(if (and (presence login)
(presence password))
{:basic-auth [login password]}
{:basic-auth [password]})))

(defn str
"Like clojure.core/str but maps keywords to strings without preceding colon."
Expand Down
23 changes: 22 additions & 1 deletion releases.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
### 5.0 #######################################################################
#### 0.6.0 #######################################################################

- version_major: 0
version_minor: 6
version_patch: 0
version_pre: NULL
version_build: NULL
name: NULL

description: |
Changes
=======
* Improve the UX of the sign-in page: swapping tags deletes existing sign in info.
Fixes
=====
* Fix sign in with login and password.
### 0.5.0 #######################################################################

- version_major: 0
version_minor: 5
Expand Down

0 comments on commit 31e3795

Please sign in to comment.