Update part5

This commit is contained in:
Richard Feldman
2018-08-13 06:08:36 -04:00
parent fd3ceff2d2
commit 91438546ba
19 changed files with 883 additions and 532 deletions

View File

@@ -1,4 +1,4 @@
module Viewer exposing (Viewer, cred, decoder, email, encode, profile)
module Viewer exposing (Viewer, cred, decoder, email, encode, minPasswordChars, profile)
{-| The logged-in user currently viewing this page.
-}
@@ -47,6 +47,13 @@ email (Viewer info) =
info.email
{-| Passwords must be at least this many characters long!
-}
minPasswordChars : Int
minPasswordChars =
6
-- SERIALIZATION
@@ -56,9 +63,16 @@ encode (Viewer info) =
Encode.object
[ ( "email", Email.encode info.email )
, ( "username", Username.encode (Cred.username info.cred) )
, ( "bio", Maybe.withDefault Encode.null (Maybe.map Encode.string (Profile.bio info.profile)) )
, ( "image", Avatar.encode (Profile.avatar info.profile) )
, ( "token", Cred.encodeToken info.cred )
, ( "bio"
, case Profile.bio info.profile of
Just bio ->
Encode.string bio
Nothing ->
Encode.null
)
]