Revert "Testnet usage related fixes"

This reverts commit d8965025d1.
This commit is contained in:
Teemu Patja 2017-06-02 11:00:28 +03:00
parent a90c9569e2
commit 12671cd2c3
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
1 changed files with 4 additions and 5 deletions

View File

@ -12,8 +12,7 @@
[clojure.tools.logging :as log] [clojure.tools.logging :as log]
[clojure.string :as str])) [clojure.string :as str]))
(defn root-path []
(if (env :on-testnet) "/test" "/"))
(defn- create-user [token user] (defn- create-user [token user]
(let [{name :name (let [{name :name
@ -34,7 +33,7 @@
(create-user token user)))) (create-user token user))))
(defroutes redirect-routes (defroutes redirect-routes
(GET (str (root-path) "callback") [code state] (GET "/callback" [code state]
(let [resp (github/post-for-token code state) (let [resp (github/post-for-token code state)
body (keywordize-keys (codec/form-decode (:body resp))) body (keywordize-keys (codec/form-decode (:body resp)))
scope (:scope body) scope (:scope body)
@ -42,10 +41,10 @@
(log/debug "github sign-in callback, response body:" body) (log/debug "github sign-in callback, response body:" body)
(if (:error body) (if (:error body)
;; Why does Mist browser sends two redirects at the same time? The latter results in 401 error. ;; Why does Mist browser sends two redirects at the same time? The latter results in 401 error.
(response/redirect (root-path)) (response/redirect "/")
(let [admin-token? (str/includes? scope "repo") (let [admin-token? (str/includes? scope "repo")
token-key (if admin-token? :admin-token :token) token-key (if admin-token? :admin-token :token)
user (assoc (get-or-create-user access-token) user (assoc (get-or-create-user access-token)
token-key access-token)] token-key access-token)]
(assoc (response/redirect (root-path)) (assoc (response/redirect "/")
:session {:identity user})))))) :session {:identity user}))))))