mirror of
https://github.com/status-im/open-bounty.git
synced 2025-02-04 05:34:37 +00:00
Testnet usage related fixes
This commit is contained in:
parent
f5a4c54920
commit
d8965025d1
@ -12,7 +12,8 @@
|
|||||||
[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
|
||||||
@ -33,7 +34,7 @@
|
|||||||
(create-user token user))))
|
(create-user token user))))
|
||||||
|
|
||||||
(defroutes redirect-routes
|
(defroutes redirect-routes
|
||||||
(GET "/callback" [code state]
|
(GET (str (root-path) "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)
|
||||||
@ -41,10 +42,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 "/")
|
(response/redirect (root-path))
|
||||||
(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 "/")
|
(assoc (response/redirect (root-path))
|
||||||
:session {:identity user}))))))
|
:session {:identity user}))))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user