Add :dev-login for quick dev tasks when OAuth/GitHub app are not

required
This commit is contained in:
Vitaliy Vlasov 2018-04-04 14:23:24 +03:00 committed by Martin Klepsch
parent 4437e13657
commit 9008f675f3
4 changed files with 46 additions and 26 deletions

View File

@ -43,6 +43,13 @@ SELECT *
FROM users
WHERE id = :id;
-- :name get-user-by-login :? :1
-- :doc retrieve a user given GitHub login.
SELECT *
FROM users
WHERE login = :login;
-- :name get-repo-owner :? :1
SELECT *
FROM users u, repositories r

View File

@ -21,6 +21,11 @@
(jdbc/with-db-connection [con-db *db*]
(db/get-user con-db {:id user-id})))
(defn get-user-by-login
[login]
(jdbc/with-db-connection [con-db *db*]
(db/get-user-by-login con-db {:login login})))
(defn exists?
[user-id]
(jdbc/with-db-connection [con-db *db*]

View File

@ -23,7 +23,10 @@
:on-testnet? (env :on-testnet)}))
(defn landing-page []
(layout/render "index.html" {:authorize-url (github/signup-authorize-url)}))
(layout/render "index.html"
{:authorize-url (if (env :dev-login)
(str (env :server-address) "/callback_dev")
(github/signup-authorize-url))}))
(defn welcome-page []
(layout/render "welcome.html"))

View File

@ -59,4 +59,9 @@
(catch Throwable t
(log/error "Failed to create hubspot contact" t))))
(assoc (found (str (env :server-address) "/app"))
:session {:identity user}))))))
:session {:identity user})))))
(GET "/callback_dev" []
(assoc (found (str (env :server-address) "/app"))
:session {:identity (users/get-user-by-login (env :dev-login))}))
)