Skip to content

Commit

Permalink
Remove debug calls, small margin tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
plexus committed Aug 18, 2024
1 parent 94fe8ab commit b4466e5
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 103 deletions.
118 changes: 59 additions & 59 deletions resources/public/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ body #app >main {

}

@keyframes session-card-pulse {

0%, 100% {
opacity: 1;
}

50% {
opacity: 0.5;
}

}

ul, ol {
list-style-type: none;
margin: var(--size-0);
Expand Down Expand Up @@ -97,18 +109,6 @@ body {
font-family: Open Sans, sans-serif;
}

@keyframes session-card-pulse {

0%, 100% {
opacity: 1;
}

50% {
opacity: 0.5;
}

}

.graphics-compass_logo path {
fill: var(--hoc-pink);
}
Expand Down Expand Up @@ -141,6 +141,53 @@ body {
animation: dash 1s linear forwards;
}

.co_gaiwan_compass_html_auth__popup {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--size-4);
}

.co_gaiwan_compass_html_auth__popup .top {
display: flex;
align-self: flex-end;
padding: var(--size-2);
}

.co_gaiwan_compass_html_auth__popup p {
margin: var(--size-4);
margin-top: var(--size-0);
}

.co_gaiwan_compass_html_auth__popup .discord-login {
margin-bottom: var(--size-4);
padding-top: var(--size-3);
padding-bottom: var(--size-3);
padding-left: var(--size-4);
padding-right: var(--size-4);
background-color: #7289da;
border-radius: var(--radius-2);
color: var(--gray-0);
text-align: center;
}

.co_gaiwan_compass_html_auth__popup .discord-login:hover {
text-decoration: none;
}

.co_gaiwan_compass_html_auth__popup .graphics-cross {
width: 3rem;
height: 2.25rem;
padding: 0.4rem;
--_icon-color: var(--text-1);
}

.co_gaiwan_compass_html_auth__popup .graphics-discord {
height: 2rem;
width: 2rem;
--_logo-color: var(--gray-0);
}

.co_gaiwan_compass_html_navigation__nav_bar {
display: flex;
align-items: center;
Expand Down Expand Up @@ -211,53 +258,6 @@ body {
opacity: 0.5;
}

.co_gaiwan_compass_html_auth__popup {
display: flex;
flex-direction: column;
align-items: center;
gap: var(--size-4);
}

.co_gaiwan_compass_html_auth__popup .top {
display: flex;
align-self: flex-end;
padding: var(--size-2);
}

.co_gaiwan_compass_html_auth__popup p {
margin: var(--size-4);
margin-top: var(--size-2);
}

.co_gaiwan_compass_html_auth__popup .discord-login {
margin-bottom: var(--size-4);
padding-top: var(--size-3);
padding-bottom: var(--size-3);
padding-left: var(--size-4);
padding-right: var(--size-4);
background-color: #7289da;
border-radius: var(--radius-2);
color: var(--gray-0);
text-align: center;
}

.co_gaiwan_compass_html_auth__popup .discord-login:hover {
text-decoration: none;
}

.co_gaiwan_compass_html_auth__popup .graphics-cross {
width: 3rem;
height: 2.25rem;
padding: 0.4rem;
--_icon-color: var(--text-1);
}

.co_gaiwan_compass_html_auth__popup .graphics-discord {
height: 2rem;
width: 2rem;
--_logo-color: var(--gray-0);
}

.co_gaiwan_compass_html_components__toggle_button {
color: var(--text-2);
}
Expand Down
3 changes: 3 additions & 0 deletions src/co/gaiwan/compass/db/queries.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
:where
[?e :session/title]]
(db/db))))

(defn all-users []
)
2 changes: 1 addition & 1 deletion src/co/gaiwan/compass/html/auth.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:flex-col :items-center
:gap-4
[:.top :flex :self-end :p-2]
[:p :m-4 :mt-2]
[:p :m-4 :mt-0]
[:.discord-login :mb-4 :py-3 :px-4
{:background-color "#7289da"
:border-radius t/--radius-2
Expand Down
78 changes: 36 additions & 42 deletions src/co/gaiwan/compass/routes/oauth.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,44 @@
(assoc :session (assoc session :oauth/state-id state)))))

(defn GET-discord-callback [{:keys [query-params session]}]
(doto
(let [{:strs [code state]} query-params
_
(prn code state)
{:keys [status body]} (oauth/exchange-code code)]
(prn status body)
(prn session)
(cond
(not= 200 status)
(-> (response/redirect "/" {:flash [:p
"Discord OAuth2 exchange failed."
[:pre (util/pprint-str body)]]})
(assoc :session {}))
(let [{:strs [code state]} query-params
{:keys [status body]} (oauth/exchange-code code)]
(cond
(not= 200 status)
(-> (response/redirect "/" {:flash [:p
"Discord OAuth2 exchange failed."
[:pre (util/pprint-str body)]]})
(assoc :session {}))

(not= state (str (:oauth/state-id session)))
(-> (response/redirect "/" {:flash [:p "Discord OAuth2 invalid state."]})
(assoc :session {}))
(not= state (str (:oauth/state-id session)))
(-> (response/redirect "/" {:flash [:p "Discord OAuth2 invalid state."]})
(assoc :session {}))

:else
(let [{:keys [access_token refresh_token expires_in]} body
{:keys [id global_name email username]} (discord/fetch-user-info access_token)
user-uuid (:user/uuid (d/entity (db/db) [:user/email email]) (random-uuid))
tx-data
[{:user/uuid user-uuid
:user/email email
:user/name global_name
:user/handle username
:discord/id id
:discord/access-token access_token
:discord/refresh-token refresh_token
:discord/expires-at (util/expires-in->instant expires_in)}]
{:keys [status]} (discord/join-server access_token)]
@(db/transact tx-data)
{:status 302
:headers {"Location" (:oauth/redirect-url (db/entity [:oauth/state-id (parse-uuid state)]) "/")}
:flash [:p "You are signed in!"
(case status
204 nil
201 [:br "You've also been added to "
[:a {:href (str "https://discord.com/channels/" (config/value :discord/server-id))}
"our Discord server"] "!"]
[:br "Unfortunately, adding you to our Discord server didn't work."])]
:session {:identity user-uuid}})))
prn))
:else
(let [{:keys [access_token refresh_token expires_in]} body
{:keys [id global_name email username]} (discord/fetch-user-info access_token)
user-uuid (:user/uuid (d/entity (db/db) [:user/email email]) (random-uuid))
tx-data
[{:user/uuid user-uuid
:user/email email
:user/name global_name
:user/handle username
:discord/id id
:discord/access-token access_token
:discord/refresh-token refresh_token
:discord/expires-at (util/expires-in->instant expires_in)}]
{:keys [status]} (discord/join-server access_token)]
@(db/transact tx-data)
{:status 302
:headers {"Location" (:oauth/redirect-url (db/entity [:oauth/state-id (parse-uuid state)]) "/")}
:flash [:p "You are signed in!"
(case status
204 nil
201 [:br "You've also been added to "
[:a {:href (str "https://discord.com/channels/" (config/value :discord/server-id))}
"our Discord server"] "!"]
[:br "Unfortunately, adding you to our Discord server didn't work."])]
:session {:identity user-uuid}}))))

(defn GET-login [req]
{:html/layout false
Expand Down
1 change: 0 additions & 1 deletion src/co/gaiwan/compass/routes/profiles.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

(defn params->profile-data
[{:keys [name title user-id] :as params}]
;; (prn :params params)
{:db/id (parse-long user-id)
:user/name name
:user/title title})
Expand Down

0 comments on commit b4466e5

Please sign in to comment.