store xmpp creds from form
This commit is contained in:
parent
1d04dff4f0
commit
6803667f00
3 changed files with 26 additions and 9 deletions
|
@ -16,6 +16,7 @@ import Assistant.WebApp.SideBar
|
|||
import Assistant.WebApp.Utility
|
||||
import Assistant.WebApp.Configurators.Local
|
||||
import Assistant.DaemonStatus
|
||||
import Assistant.XMPP
|
||||
import Utility.Yesod
|
||||
import qualified Remote
|
||||
import qualified Types.Remote as Remote
|
||||
|
@ -33,6 +34,7 @@ getConfigR :: Handler RepHtml
|
|||
getConfigR = ifM (inFirstRun)
|
||||
( getFirstRepositoryR
|
||||
, bootstrap (Just Config) $ do
|
||||
xmppconfigured <- lift $ runAnnex False $ isJust <$> getXMPPCreds
|
||||
sideBarDisplay
|
||||
setTitle "Configuration"
|
||||
$(widgetFile "configurators/main")
|
||||
|
|
|
@ -31,8 +31,10 @@ import qualified Data.Text as T
|
|||
getXMPPR :: Handler RepHtml
|
||||
#ifdef WITH_XMPP
|
||||
getXMPPR = xmppPage $ do
|
||||
((result, form), enctype) <- lift $
|
||||
runFormGet $ renderBootstrap $ xmppAForm Nothing
|
||||
((result, form), enctype) <- lift $ do
|
||||
oldcreds <- runAnnex Nothing getXMPPCreds
|
||||
runFormGet $ renderBootstrap $ xmppAForm $
|
||||
creds2Form <$> oldcreds
|
||||
let showform problem = do
|
||||
let authtoken = webAppFormAuthToken
|
||||
$(widgetFile "configurators/xmpp")
|
||||
|
@ -41,7 +43,9 @@ getXMPPR = xmppPage $ do
|
|||
=<< liftIO (validateForm f)
|
||||
_ -> showform False
|
||||
where
|
||||
storecreds = error "TODO store"
|
||||
storecreds creds = do
|
||||
void $ runAnnex undefined $ setXMPPCreds creds
|
||||
redirect ConfigR
|
||||
#else
|
||||
getXMPPR = xmppPage $
|
||||
$(widgetFile "configurators/xmpp/disabled")
|
||||
|
@ -53,6 +57,9 @@ data XMPPForm = XMPPForm
|
|||
{ formJID :: Text
|
||||
, formPassword :: Text }
|
||||
|
||||
creds2Form :: XMPPCreds -> XMPPForm
|
||||
creds2Form c = XMPPForm (xmppJID c) (xmppPassword c)
|
||||
|
||||
xmppAForm :: (Maybe XMPPForm) -> AForm WebApp WebApp XMPPForm
|
||||
xmppAForm def = XMPPForm
|
||||
<$> areq jidField "Jabber address" (formJID <$> def)
|
||||
|
|
|
@ -8,9 +8,17 @@
|
|||
Distribute the files in this repository to other devices, #
|
||||
make backups, and more, by adding repositories.
|
||||
<div .span4>
|
||||
<h3>
|
||||
<a href="@{XMPPR}">
|
||||
Configure jabber account
|
||||
<p>
|
||||
Allow devices that are not in direct contact to keep in touch, #
|
||||
by configuring a jabber account.
|
||||
$if xmppconfigured
|
||||
<h3>
|
||||
<a href="@{XMPPR}">
|
||||
Re-configure jabber account
|
||||
<p>
|
||||
Your jabber account is set up, and will be used to keep #
|
||||
in touch with remote devices, and with your friends.
|
||||
$else
|
||||
<h3>
|
||||
<a href="@{XMPPR}">
|
||||
Configure jabber account
|
||||
<p>
|
||||
Keep in touch with remote devices, and with your friends, #
|
||||
by configuring a jabber account.
|
||||
|
|
Loading…
Reference in a new issue