1
1
mirror of https://github.com/aelve/guide.git synced 2024-11-22 11:33:34 +03:00

Delete the admin user that came with the official database

This commit is contained in:
Artyom 2017-08-20 16:48:35 +03:00
parent c9fe5866e7
commit 2038d47229
No known key found for this signature in database
GPG Key ID: B8E35A33FF522710
2 changed files with 9 additions and 2 deletions

View File

@ -448,6 +448,7 @@ installTerminationCatcher thread = void $ do
-- The user won't be added if it exists already.
createAdminUser :: GuideApp ()
createAdminUser = do
dbUpdate DeleteAllUsers
pass <- T.toByteString . _adminPassword <$> getConfig
user <- makeUser "admin" "admin@guide.aelve.com" pass
void $ dbUpdate $ CreateUser (user & userIsAdmin .~ True)

View File

@ -79,7 +79,7 @@ module Guide.State
LoadSession(..), StoreSession(..),
DeleteSession(..), GetSessions(..),
GetUser(..), CreateUser(..), DeleteUser(..),
GetUser(..), CreateUser(..), DeleteUser(..), DeleteAllUsers(..),
LoginUser(..),
GetAdminUsers(..)
@ -750,6 +750,12 @@ deleteUser key = do
logoutUserGlobally key
setDirty
deleteAllUsers :: Acid.Update GlobalState ()
deleteAllUsers = do
mapM_ logoutUserGlobally . M.keys =<< use users
users .= mempty
setDirty
-- | Given an email address and a password, return the user if it exists
-- and the password is correct.
loginUser :: Text -> ByteString -> Acid.Query GlobalState (Either String User)
@ -813,7 +819,7 @@ makeAcidic ''GlobalState [
'loadSession, 'storeSession, 'deleteSession, 'getSessions,
-- users
'getUser, 'createUser, 'deleteUser,
'getUser, 'createUser, 'deleteUser, 'deleteAllUsers,
'loginUser,
'getAdminUsers