about summary refs log tree commit diff
path: root/src/Accounts.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Accounts.hs')
-rw-r--r--src/Accounts.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Accounts.hs b/src/Accounts.hs
index c18a599a30a7..97ffaf43d058 100644
--- a/src/Accounts.hs
+++ b/src/Accounts.hs
@@ -1,12 +1,26 @@
+{-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE OverloadedStrings #-}
 --------------------------------------------------------------------------------
 module Accounts where
 --------------------------------------------------------------------------------
 import Database.SQLite.Simple
 
+import qualified PendingAccounts
 import qualified Types as T
 --------------------------------------------------------------------------------
 
+-- | Delete the account in PendingAccounts and create on in Accounts.
+transferFromPending :: FilePath -> T.PendingAccount -> IO ()
+transferFromPending dbFile T.PendingAccount{..} = withConnection dbFile $
+  \conn -> withTransaction conn $ do
+    PendingAccounts.delete dbFile pendingAccountUsername
+    execute conn "INSERT INTO Accounts (username,password,email,role) VALUES (?,?,?,?)"
+      ( pendingAccountUsername
+      , pendingAccountPassword
+      , pendingAccountEmail
+      , pendingAccountRole
+      )
+
 -- | Create a new account in the Accounts table.
 create :: FilePath -> T.Username -> T.ClearTextPassword -> T.Email -> T.Role -> IO ()
 create dbFile username password email role = withConnection dbFile $ \conn -> do