webapp: Defaults to sharing box.com account info with friends, allowing one-click enabling of the repository.

This commit is contained in:
Joey Hess 2012-11-28 13:31:49 -04:00
parent 6991f47e9e
commit 8dd1d9aaf9
6 changed files with 42 additions and 24 deletions

View file

@ -34,7 +34,7 @@ data CredPairStorage = CredPairStorage
{- Stores creds in a remote's configuration, if the remote allows
- that. Otherwise, caches them locally. -}
setRemoteCredPair :: RemoteConfig -> CredPairStorage -> Annex RemoteConfig
setRemoteCredPair c storage = go =<< getRemoteCredPair' c storage
setRemoteCredPair c storage = go =<< getRemoteCredPair c storage
where
go (Just creds)
| embedCreds c = case credPairRemoteKey storage of
@ -58,8 +58,8 @@ setRemoteCredPair c storage = go =<< getRemoteCredPair' c storage
{- Gets a remote's credpair, from the environment if set, otherwise
- from the cache in gitAnnexCredsDir, or failing that, from the
- value in RemoteConfig. -}
getRemoteCredPair :: String -> RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
getRemoteCredPair this c storage = maybe missing (return . Just) =<< getRemoteCredPair' c storage
getRemoteCredPairFor :: String -> RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
getRemoteCredPairFor this c storage = maybe missing (return . Just) =<< getRemoteCredPair c storage
where
(loginvar, passwordvar) = credPairEnvironment storage
missing = do
@ -70,8 +70,8 @@ getRemoteCredPair this c storage = maybe missing (return . Just) =<< getRemoteCr
]
return Nothing
getRemoteCredPair' :: RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
getRemoteCredPair' c storage = maybe fromcache (return . Just) =<< fromenv
getRemoteCredPair :: RemoteConfig -> CredPairStorage -> Annex (Maybe CredPair)
getRemoteCredPair c storage = maybe fromcache (return . Just) =<< fromenv
where
fromenv = liftIO $ getEnvCredPair storage
fromcache = maybe fromconfig (return . Just) =<< readCacheCredPair storage
@ -103,8 +103,6 @@ getEnvCredPair storage = liftM2 (,)
(uenv, penv) = credPairEnvironment storage
get = catchMaybeIO . getEnv
{- Stores a CredPair in the environment. -}
setEnvCredPair :: CredPair -> CredPairStorage -> IO ()
setEnvCredPair (l, p) storage = do