Commit f96ed050 authored by Camil Staps's avatar Camil Staps 🚀

Merge branch 'add-minimal-multi-user-framework' into 'master'

Created a minimal framework for publishing password protected multi-user tasks

Closes #3

See merge request !411
parents da207307 db16b1a5
Pipeline #43639 passed with stage
in 8 minutes and 55 seconds
......@@ -32,7 +32,7 @@ from iTasks.Extensions.Document import :: Document
derive class iTask UserAccount, StoredUserAccount, StoredCredentials
// Shares
// User accounts in the iTasks store
//* All user accounts
userAccounts :: SDSLens () [StoredUserAccount] [StoredUserAccount]
......@@ -42,6 +42,14 @@ users :: SDSLens () [User] ()
//* Users with a specific role
usersWithRole :: !Role -> SDSLens () [User] ()
//* Alternative user account file, in a user defined location
userAccountsFile :: SDSLens FilePath [StoredUserAccount] [StoredUserAccount]
//* Utility lenses for looking up user accounts
userAccountIn :: (sds () [StoredUserAccount] [StoredUserAccount]) -> SDSLens UserId (Maybe StoredUserAccount) (Maybe StoredUserAccount) | RWShared sds
userTokenIn :: (sds () [StoredUserAccount] [StoredUserAccount]) -> SDSLens String (Maybe StoredUserAccount) () | RWShared sds
/**
* Authenticates a user by username and password
*
......@@ -52,6 +60,7 @@ usersWithRole :: !Role -> SDSLens () [User] ()
* @return A single user who matches the given credentials, or nothing of none or more than one exists.
*/
authenticateUser :: !Username !Password !Bool -> Task (Maybe User)
authenticateUserWith :: !Username !Password !Bool (sds UserId (Maybe StoredUserAccount) (Maybe StoredUserAccount)) -> Task (Maybe User) | RWShared sds
/**
* Check the browser cookies for a stored persistent login token
......@@ -60,6 +69,7 @@ authenticateUser :: !Username !Password !Bool -> Task (Maybe User)
* - If an invalid token is set, it returns Nothing
*/
authenticateUsingToken :: Task (Maybe User)
authenticateUsingTokenWith :: (sds String (Maybe StoredUserAccount) ()) -> Task (Maybe User) | RWShared sds
/**
* Clear any persistent authentication cookies
......@@ -72,8 +82,6 @@ clearAuthenticationToken :: Task ()
* @param the task to wrap
*/
doAuthenticated :: (Task a) -> Task a | iTask a
doAuthenticatedWith :: !(Credentials -> Task (Maybe User)) (Task a) -> Task a | iTask a
/**
......@@ -104,7 +112,20 @@ deleteUserFlow :: UserId -> Task StoredUserAccount
importUserFileFlow :: Task ()
exportUserFileFlow :: Task Document
changeOwnPasswordFlow :: !UserId -> Task ()
changeOwnPasswordFlowWith :: !UserId (sds UserId (Maybe StoredUserAccount) (Maybe StoredUserAccount)) -> Task () | RWShared sds
/**
* Do a task in a basic multi-user setting, users need to log in before they can do a task
*/
minimalMultiUserTask :: ((Task (Maybe User)) -> Task (Maybe User))
(User -> Task ()) (User -> Task ())
(User -> [(String,Task ())])
(sds UserId (Maybe StoredUserAccount) (Maybe StoredUserAccount))
(sds String (Maybe StoredUserAccount) ()) -> Task () | RWShared sds
/**
* Create set of user names handy for giving demo's: alice, bob, carol, ...
*/
importDemoUsersFlow :: Task [UserAccount]
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