Client login now handles response correctly.
[?]
Jan 18, 2016, 10:27 PM
HO2PFRABW6BBTE4MUKUTEGXCMJS46WGVBCNWOHO4OL52DVAB4YDACDependencies
- [2]
EW2XN7KUUpdate docker build, clean up migration for payments tables. - [3]
ARX7SHY5Begin work on login UI. - [4]
Z3M53KTLAdrift. - [5]
RPAJLHMTChange to use UUIDs instead of ints for primary keys. - [6]
2XQD6KKKAdd invitation logic and clean up DBProg error handling. - [7]
MGOF7IUFUpdate TASKS list to reflect completed projects. - [8]
BROSTG5KBeginning of modularization of server. - [9]
NEDDHXUKReformat via stylish-haskell - [10]
O722AOKEAdd route to allow crediting of events to users/projects. - [11]
O5FVTOM6Undo JSON silliness, enable a couple more routes. - [12]
RB2ETNIFAdd skeletal PureScript client project. - [13]
IZEVQF62Work in progress replacing sqlite with postgres. - [14]
GCVQD44VCreate amends endpoint, switch to UUID primary keys - [*]
4ZLEDBK7Initial attempts at dockerizing, cabal isn't cooperating. - [*]
DXIGERDTChange order of Docker build to avoid rebuilding the universe. - [*]
V2VDN77HEnable postgres configuration via environment variable for Heroku. - [*]
LCBJULKEFix swapped default and key in QConfig. - [*]
ADMKQQGCInitial empty Snap project.
Change contents
- edit in Dockerfile at line 18
# apt-get install -y --no-install-recommends wget && \# echo 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main' > /etc/apt/sources.list.d/pgdg.list && \# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \# Install npm, then use it to get purescript, pulp and bowerRUN apt-get install -y --no-install-recommends nodejsRUN apt-get install -y --no-install-recommends npmRUN npm install -g npm# Fix executable name used by the purescript npm installerRUN ln -s /usr/bin/nodejs /usr/local/bin/node - edit in Dockerfile at line 61
# Build the client application and install it where snap can serve itADD ./client /opt/aftok/clientWORKDIR /opt/aftok/clientRUN npm installRUN bower installRUN pulp buildRUN pulp browserify --optimise --to dist/aftok.jsADD ./dist /opt/aftok/server/static - replacement in client/src/Main.purs at line 5
import Control.Alt ((<|>))--import Control.Alt ((<|>)) - edit in client/src/Main.purs at line 9
import Control.Monad.Eff.Console (CONSOLE(), log) - replacement in client/src/Main.purs at line 11
import Data.Either (Either(..))import Data.Maybe (Maybe(..))--import Data.Either (Either(..)) - replacement in client/src/Main.purs at line 14
import Data.Foreign.Class (readProp)--import Data.Foreign.Class (readProp) - edit in client/src/Main.purs at line 16
import Data.Functor.Eff (liftEff) - replacement in client/src/Main.purs at line 26
import Network.HTTP.Affjax (AJAX(), post)import Network.HTTP.Affjax (AJAX(), affjax)import Network.HTTP.Methodimport Network.HTTP.StatusCode - replacement in client/src/Main.purs at line 43
type AppEffects eff = HalogenEffects (ajax :: AJAX | eff)type AppEffects eff = HalogenEffects (console :: CONSOLE, ajax :: AJAX | eff) - replacement in client/src/Main.purs at line 92
_ <- liftAff' (fetchJS user pass)result <- liftAff' (login user pass)_ <- liftEff case result ofOK -> log "Login succeeded"Forbidden -> log "Password incorrect"Error m -> log m.message - edit in client/src/Main.purs at line 98
data LoginResponse= OK| Forbidden| Error { status :: StatusCode, message :: String } - replacement in client/src/Main.purs at line 105
fetchJS :: forall eff. String -> String -> Aff (ajax :: AJAX | eff) StringfetchJS user pass = doresult <- post "https://aftok.com/login" userlet response = result.responsereturn case readProp "js" response <|> readProp "error" response ofRight js -> jsLeft _ -> "Invalid response"login :: forall eff. String -> String -> Aff (ajax :: AJAX | eff) LoginResponselogin user pass = doresult <- affjax $ { method: POST, url: "/login", headers: [], content: Nothing :: Maybe String, username: Just user, password: Just pass}pure $ case result.status ofStatusCode 403 -> ForbiddenStatusCode 200 -> OKother -> Error { status: other , message: result.response } - edit in server/Aftok/QConfig.hs at line 32
, staticAssetPath :: System.IO.FilePath - edit in server/Aftok/QConfig.hs at line 66
<*> C.lookupDefault "/opt/aftok/server/static/" cfg "staticAssetPath" - edit in server/Main.hs at line 24
import Snap.Snaplet.Auth.Backends.PostgresqlSimple - edit in server/Main.hs at line 25
import Snap.Snaplet.Auth.Backends.PostgresqlSimple - edit in server/Main.hs at line 27
import Snap.Util.FileServe (serveDirectory) - replacement in server/Main.hs at line 43
let loginRoute = requireLogin >> redirect "/home"registerRoute = void $ method POST registerHandleracceptInviteRoute = void $ method POST acceptInvitationHandlerlet loginRoute = method GET requireLogin >> redirect "/home"xhrLoginRoute = void $ method POST requireLoginregisterRoute = void $ method POST registerHandleracceptInviteRoute = void $ method POST acceptInvitationHandler - edit in server/Main.hs at line 68
addRoutes [ ("static", serveDirectory $ staticAssetPath cfg) - replacement in server/Main.hs at line 71
addRoutes [ ("login", loginRoute), ("login", loginRoute), ("login", xhrLoginRoute)