about summary refs log tree commit diff
path: root/client/src/Login.elm
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-02T20·27+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-02T20·27+0100
commitb9ed4a2dc170a3a4b6c1095cdfc79e49292f315d (patch)
treedb81e5f3fb515d9d5ca8003968c11b6b09591a82 /client/src/Login.elm
parentd6b91b93cbb42170249eb17eb7d0cb1c1a31f44a (diff)
Partially support federated login
Two things:
1. I've never attempted to support this before.
2. It seems surprisingly and perhaps deceptively simpler than what I
   expected. I'm unsure what to do once Google's API authenticates the user. I
   currently look-up the user's role, trips, etc. using their email address. The
   role is stored in the Accounts table alongside username, email, password. I
   will speak with the interviewer tomorrow about this.
Diffstat (limited to 'client/src/Login.elm')
-rw-r--r--client/src/Login.elm33
1 files changed, 30 insertions, 3 deletions
diff --git a/client/src/Login.elm b/client/src/Login.elm
index 083c4705609d..b1a436098afd 100644
--- a/client/src/Login.elm
+++ b/client/src/Login.elm
@@ -10,6 +10,16 @@ import UI
 import Utils
 
 
+googleSignIn : Html State.Msg
+googleSignIn =
+    div
+        [ class "g-signin2"
+        , attribute "onsuccess" "onSignIn"
+        , onClick State.GoogleSignIn
+        ]
+        []
+
+
 loginForm : State.Model -> Html State.Msg
 loginForm model =
     div
@@ -111,11 +121,28 @@ loginForm model =
                 ]
             , case model.loginTab of
                 State.LoginForm ->
-                    UI.simpleButton { handleClick = State.AttemptLogin, label = "Login" }
+                    div [ [ "flex", "space-around" ] |> Tailwind.use |> class ]
+                        [ UI.simpleButton
+                            { handleClick = State.AttemptLogin
+                            , label = "Login"
+                            }
+                        , div [ [ "pl-4" ] |> Tailwind.use |> class ] [ googleSignIn ]
+                        ]
 
                 State.SignUpForm ->
-                    if String.length model.username > 0 && String.length model.email > 0 && String.length model.password > 0 then
-                        UI.simpleButton { handleClick = State.AttemptSignUp, label = "Sign up" }
+                    if
+                        List.all identity
+                            [ String.length model.username > 0
+                            , String.length model.email > 0
+                            , String.length model.password > 0
+                            ]
+                    then
+                        div []
+                            [ UI.simpleButton
+                                { handleClick = State.AttemptSignUp
+                                , label = "Sign up"
+                                }
+                            ]
 
                     else
                         UI.disabledButton { label = "Sign up" }