Commit 7d2b7438 authored by Bas Lijnse's avatar Bas Lijnse

Added correct setting of "success" flag in worktab handler and added a basic...

Added correct setting of "success" flag in worktab handler and added a basic task for adding users from within a workflow.

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@709 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 0937d506
......@@ -45,6 +45,13 @@ getRoles :: ![UserId] -> Task [[String]]
*/
authenticateUser :: !String !String -> Task (Maybe User)
/**
* Add a new user
*/
createUser :: !String !String !String ![String] -> Task User
//Interactively choose a user
chooseUser :: !question -> Task User | html question
chooseUserWithRole :: !question !String -> Task User | html question
\ No newline at end of file
......@@ -14,6 +14,7 @@ from UserDB import qualified getDisplayNames
from UserDB import qualified getUserNames
from UserDB import qualified getRoles
from UserDB import qualified authenticateUser
from UserDB import qualified createUser
import InteractionTasks, CoreCombinators
......@@ -41,6 +42,10 @@ getRoles uids = mkInstantTask "getRoles" (UserDB@getRoles uids)
authenticateUser :: !String !String -> Task (Maybe User)
authenticateUser username password = mkInstantTask "authenticateUser" (UserDB@authenticateUser username password)
createUser :: !String !String !String ![String] -> Task User
createUser username password displayname roles
= mkInstantTask "createUser" (UserDB@createUser username password displayname roles)
chooseUser :: !question -> Task User | html question
chooseUser question
= getUsers
......
......@@ -81,4 +81,15 @@ getRoles :: ![Int] !*TSt -> (![[String]] , !*TSt)
* @return When successful, A triple of user id/ display name/ list of roles.
* @return The database handle
*/
authenticateUser :: !String !String !*TSt -> (!Maybe User, !*TSt)
\ No newline at end of file
authenticateUser :: !String !String !*TSt -> (!Maybe User, !*TSt)
/**
* Create a new user
*
* @param A user name
* @param A password
* @param A display name
* @param A list of roles
* @return A user
* @return The database handle
*/
createUser :: !String !String !String ![String] !*TSt -> (User,!*TSt)
\ No newline at end of file
......@@ -136,6 +136,17 @@ authenticateUser username password tst
[user] = (Just user, tst)
_ = (Nothing, tst)
createUser :: !String !String !String ![String] !*TSt -> (User,!*TSt)
createUser username password displayname roles tst
# (users, tst) = userStore id tst
# user = {userId= maxid users, userName = username, password = password, displayName = displayname, roles = roles}
# (users, tst) = userStore (\_-> [user:users]) tst
= (user,tst)
where
maxid [] = 1
maxid users = maxList [user.User.userId \\ user <- users] + 1
//Helper function which finds a property of a certain user
lookupUserProperty :: ![User] !(User -> a) !a !Int -> a
lookupUserProperty users selectFunction defaultValue userId
......
......@@ -28,7 +28,7 @@ handleWorkTabRequest req tst
// Update the task timestamps
# tst = updateTimeStamps properties.systemProps.TaskSystemProperties.processId tst
// Create the response
= let content = {TaskContent| properties = Just properties, subject = subject, content = panel, debug = debuginfo} in
= let content = {TaskContent| success = True, properties = Just properties, subject = subject, content = panel, debug = debuginfo} in
({http_emptyResponse & rsp_data = toJSON content}, tst)
| otherwise
......@@ -46,14 +46,15 @@ where
error msg tst
= ({http_emptyResponse & rsp_data = "{ \"success\" : false, \"error\" : \"" +++ msg +++ "\"}"}, tst)
redundant tst
= let content = {TaskContent| properties = Nothing, subject = [], content = TaskRedundant, debug = Nothing} in
= let content = {TaskContent| success = True, properties = Nothing, subject = [], content = TaskRedundant, debug = Nothing} in
({http_emptyResponse & rsp_data = toJSON content}, tst)
finished tst
= let content = {TaskContent| properties = Nothing, subject = [], content = TaskDone, debug = Nothing} in
= let content = {TaskContent| success = True, properties = Nothing, subject = [], content = TaskDone, debug = Nothing} in
({http_emptyResponse & rsp_data = toJSON content}, tst)
:: TaskContent =
{ properties :: Maybe TaskProperties
{ success :: Bool
, properties :: Maybe TaskProperties
, subject :: [String]
, content :: TaskPanel
, debug :: Maybe DebugInfo
......
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