Commit d657e8ca authored by Henri Jones's avatar Henri Jones

Ensure a default user exists when in development mode

parent 7d239c5b
Pipeline #62871273 passed with stages
in 8 minutes and 16 seconds
......@@ -158,8 +158,10 @@ Access the site in your browser at <http://localhost:3000>
### Using auth in development
If during development, you need to log in to the locally-running site, follow
these instructions:
You can log in to the locally-running site using the default user
`user@example.com` and passphrase `userpassphrase`.
To create a new account, follow these instructions:
As the development site does not normally send out emails (the authentication
approach for the live Snowdrift.coop system), you can get the necessary auth
......
......@@ -15,11 +15,11 @@ module Application
import Import
import Control.Monad.Logger (liftLoc, runLoggingT)
import Control.Monad.Logger (liftLoc, runLoggingT, runStdoutLoggingT)
import Crowdmatch
(crowdmatchManualMigrations, migrateCrowdmatch, stripeProduction)
import Database.Persist.Postgresql
(createPostgresqlPool, pgConnStr, pgPoolSize, runSqlPool)
(createPostgresqlPool, pgConnStr, pgPoolSize, runSqlConn, runSqlPool, withPostgresqlConn)
import Database.Persist.Sql (runMigrationSilent)
import Database.PostgreSQL.Simple (close, connectPostgreSQL)
import Language.Haskell.TH.Syntax (qLocation)
......@@ -144,6 +144,7 @@ getApplicationDev :: IO (Settings, Application)
getApplicationDev = do
settings <- getAppSettings
foundation <- makeFoundation settings
createDefaultDevelUser settings
wsettings <- getDevSettings $ warpSettings foundation
app <- makeApplication foundation
return (wsettings, app)
......@@ -155,6 +156,14 @@ getAppSettings = loadYamlSettings ["config/settings.yml"] [] useEnv
develMain :: IO ()
develMain = develMainHelper getApplicationDev
createDefaultDevelUser :: AppSettings -> IO ()
createDefaultDevelUser appSettings =
runStdoutLoggingT $ withPostgresqlConn
(pgConnStr $ appDatabaseConf appSettings)
(runSqlConn
(privilegedCreateUserBypass (AuthEmail "user@example.com")
(ClearPassphrase "userpassphrase")))
-- | The @main@ function for an executable running this site.
appMain :: IO ()
appMain = do
......@@ -183,6 +192,7 @@ getApplicationRepl :: IO (Int, App, Application)
getApplicationRepl = do
settings <- getAppSettings
foundation <- makeFoundation settings
createDefaultDevelUser settings
wsettings <- getDevSettings $ warpSettings foundation
app1 <- makeApplication foundation
return (getPort wsettings, foundation, app1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment