diff --git a/Client/src/js/ttc/TTCCommon.js b/Client/src/js/ttc/TTCCommon.js index 6333a9df95055081c7bd8af62af8da69a4a2db7e..a9467841fbfdeaffbc1e11dc884f1214d8ebae13 100644 --- a/Client/src/js/ttc/TTCCommon.js +++ b/Client/src/js/ttc/TTCCommon.js @@ -68,6 +68,7 @@ itasks.ttc.common.attachTaskHandlers = function(comp,taskId){ case "itasks.tui.Time": case "itasks.tui.Username": case "itasks.tui.Currency": + case "itasks.tui.Password": case "textarea": case "numberfield": case "datefield": diff --git a/Client/src/js/tui/PasswordControl.js b/Client/src/js/tui/PasswordControl.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f3556efa42c9b3289d60a5848cc89d07ffff3dbd 100644 --- a/Client/src/js/tui/PasswordControl.js +++ b/Client/src/js/tui/PasswordControl.js @@ -0,0 +1,20 @@ +Ext.ns('itasks.tui'); + +itasks.tui.PasswordControl = Ext.extend(Ext.form.TextField,{ + width: 100, + fieldClass: 'x-form-field', + + initComponent: function(){ + this.hideLabel = this.fieldLabel == null; + this.fieldLabel = itasks.util.fieldLabel(this.optional,this.fieldLabel); + this.allowBlank = this.optional; + this.inputType = 'password'; + + if(this.value == "") delete this.value; + + itasks.tui.PasswordControl.superclass.initComponent.apply(this,arguments); + } + +}); + +Ext.reg('itasks.tui.Password',itasks.tui.PasswordControl); \ No newline at end of file diff --git a/Language/src/Domains/CommonDomain.dcl b/Language/src/Domains/CommonDomain.dcl index 7d9c7c230f6a26254b73559b5047a751df7cec0a..3b748c02bdf41231a8dbd4a45125badec0ce2432 100644 --- a/Language/src/Domains/CommonDomain.dcl +++ b/Language/src/Domains/CommonDomain.dcl @@ -11,7 +11,6 @@ from InteractionTasks import class html, generic gMakeSharedCopy, generic gMakeL // Strings with special meanings :: EmailAddress = EmailAddress String :: URL = URL String -:: Password = Password String :: PhoneNr = PhoneNr String // Plain text notes diff --git a/Language/src/Domains/CommonDomain.icl b/Language/src/Domains/CommonDomain.icl index 6684bd60e4c13316e01a0f50f9bce9a4e2e067f1..ae17ba3f6cfed4a21962ee9c42497e46284f78a7 100644 --- a/Language/src/Domains/CommonDomain.icl +++ b/Language/src/Domains/CommonDomain.icl @@ -7,8 +7,8 @@ import Text, Time derive gPrint EmailAddress, Password, Note, Date, Time, DateTime, Currency derive gParse EmailAddress, Password, Note, Date, Time, DateTime, Currency -derive gVisualize EmailAddress, Password, DateTime -derive gUpdate EmailAddress, Password, Note, DateTime +derive gVisualize EmailAddress, DateTime +derive gUpdate EmailAddress, Note, DateTime derive gMerge EmailAddress, Password, Note, Date, Time, DateTime, Currency derive gMakeSharedCopy EmailAddress, Password, Note, Date, Time, DateTime, Currency derive gMakeLocalCopy EmailAddress, Password, Note, Date, Time, DateTime, Currency @@ -16,6 +16,22 @@ derive gLexOrd Currency derive bimap Maybe, (,) +//VValue a DataMask +gVisualize{|Password|} old new vst=:{vizType,label,idPrefix,currentPath,useLabels,optional,valid} + = case vizType of + VEditorDefinition = ([TUIFragment (TUIPasswordControl {TUIBasicControl | name = dp2s currentPath, id = id, value = oldV, fieldLabel = labelAttr useLabels label, optional = optional})] + , 1 + , {VSt | vst & currentPath = stepDataPath currentPath, valid = stillValid currentPath old optional valid}) + VEditorUpdate + | oldV <> newV = ([TUIUpdate (TUISetValue id newV)] + , 1 + , {VSt | vst & currentPath = stepDataPath currentPath, valid = stillValid currentPath new optional valid}) + _ = ([TextFragment (foldr (+++) "" (repeatn (size oldV) "*"))],1,{VSt | vst & currentPath = stepDataPath currentPath, valid = stillValid currentPath old optional valid}) +where + id = dp2id idPrefix currentPath + oldV = value2s currentPath old + newV = value2s currentPath new + gVisualize{|Date|} old new vst=:{vizType,label,idPrefix,currentPath,useLabels,optional,valid} = case vizType of VEditorDefinition = ([TUIFragment (TUIDateControl {TUIBasicControl|name = dp2s currentPath, id = id, value = oldV, fieldLabel = labelAttr useLabels label, optional = optional})] @@ -91,7 +107,17 @@ where value dp (VValue v dm) = if (isMasked dp dm) (decFormat (toInt v)) "" id = dp2id idPrefix currentPath - + +gUpdate{|Password|} _ ust=:{USt|mode=UDCreate} + = (Password "", ust) +gUpdate{|Password|} s ust=:{USt|mode=UDSearch,searchPath,currentPath,update} + | currentPath == searchPath + = (Password update, toggleMask {USt | ust & mode = UDDone}) + | otherwise + = (s, {USt|ust & currentPath = stepDataPath currentPath}) +gUpdate{|Password|} s ust=:{USt|mode=UDMask,currentPath,mask} + = (s, {USt|ust & currentPath = stepDataPath currentPath, mask = appendToMask currentPath mask}) + gUpdate{|Date|} _ ust=:{USt|mode=UDCreate,world} # (date,world) = currentDate world = (date, {USt|ust & world = world}) diff --git a/Server/src/Framework/Data/UserDB.icl b/Server/src/Framework/Data/UserDB.icl index 1f83f5e89e5fcc05cbc99b659a29fc3b67aab4b4..b168c02c97de7f3c292aad0d12a4ba17bff7a739 100644 --- a/Server/src/Framework/Data/UserDB.icl +++ b/Server/src/Framework/Data/UserDB.icl @@ -4,15 +4,17 @@ import StdEnv, StdMaybe import StdGeneric import TSt, Util, StdDebug -derive JSONEncode User -derive JSONDecode User +from Types import :: Password(..) + +derive JSONEncode User, Password +derive JSONDecode User, Password derive bimap (,), Maybe unknownUser :: User -unknownUser = {User | userName = "unknown", displayName = "Unknown user", password = "", roles = []} +unknownUser = {User | userName = "unknown", displayName = "Unknown user", password = Password "", roles = []} rootUser :: User -rootUser = {User | userName = "root", displayName = "Root", password = "", roles = []} +rootUser = {User | userName = "root", displayName = "Root", password = Password "", roles = []} getUser :: !UserName !*TSt -> (!User,!*TSt) getUser (UserName "root" _) tst @@ -65,7 +67,7 @@ authenticateUser username password tst = (Nothing, tst) | otherwise # (users, tst) = userStore id tst - = case [u \\ u <- users | u.userName == username && u.password == password] of + = case [u \\ u <- users | u.userName == username && u.password == (Password password)] of [user] = (Just user, tst) _ = (Nothing, tst) diff --git a/Server/src/Framework/GenVisualize.icl b/Server/src/Framework/GenVisualize.icl index 6ac9b9ea5d20323f541cbf61b4420cc8d696eb1d..303bdab37e2f58b41e0d0783613fa9fab0bc8851 100644 --- a/Server/src/Framework/GenVisualize.icl +++ b/Server/src/Framework/GenVisualize.icl @@ -869,7 +869,7 @@ getId (TUIDateControl d) = Just d.TUIBasicControl.id getId (TUITimeControl d) = Just d.TUIBasicControl.id getId (TUICurrencyControl d) = Just d.TUICurrencyControl.id getId (TUIUsernameControl d) = Just d.TUIBasicControl.id - +getId (TUIPasswordControl d) = Just d.TUIBasicControl.id getId (TUILabel) = Nothing getId (TUIButton d) = Just d.TUIButton.id diff --git a/Server/src/Framework/TUIDefinition.dcl b/Server/src/Framework/TUIDefinition.dcl index 81d3bf9e521ba1816397507a9176ce26331d1ba9..dc60e477d1e611f4f6c100edab2407f481a881c6 100644 --- a/Server/src/Framework/TUIDefinition.dcl +++ b/Server/src/Framework/TUIDefinition.dcl @@ -27,7 +27,8 @@ derive JSONEncode TUIDef, TUIUpdate | TUIBoolControl TUIBasicControl | TUINoteControl TUIBasicControl | TUIDateControl TUIBasicControl - | TUITimeControl TUIBasicControl + | TUITimeControl TUIBasicControl + | TUIPasswordControl TUIBasicControl | TUICurrencyControl TUICurrencyControl | TUIUsernameControl TUIBasicControl | TUIButton TUIButton diff --git a/Server/src/Framework/TUIDefinition.icl b/Server/src/Framework/TUIDefinition.icl index 4130f8b5fb1ba1ac70b528e1d9264c8623975889..8246345587ed7016a47b707db45ab83113ff3619 100644 --- a/Server/src/Framework/TUIDefinition.icl +++ b/Server/src/Framework/TUIDefinition.icl @@ -40,7 +40,7 @@ JSONEncode{|TUIDef|} (TUIDateControl r) c = addXType "itasks.tui.Date" (JSONEnco JSONEncode{|TUIDef|} (TUITimeControl r) c = addXType "itasks.tui.Time" (JSONEncode{|*|} r c) JSONEncode{|TUIDef|} (TUICurrencyControl r) c = addXType "itasks.tui.Currency" (JSONEncode{|*|} r c) JSONEncode{|TUIDef|} (TUIUsernameControl r) c = addXType "itasks.tui.Username" (JSONEncode{|*|} r c) - +JSONEncode{|TUIDef|} (TUIPasswordControl r) c = addXType "itasks.tui.Password" (JSONEncode{|*|} r c) addXType :: String [String] -> [String] addXType xtype [x:xs] = [x,"\"xtype\" : \"",xtype,"\", ":xs] \ No newline at end of file diff --git a/Server/src/Framework/Types.dcl b/Server/src/Framework/Types.dcl index fe882c891972fd895399951d3fe2e3f46c0730d0..0183e5f4210f362e13e27f5857cf9718aac50c2c 100644 --- a/Server/src/Framework/Types.dcl +++ b/Server/src/Framework/Types.dcl @@ -7,7 +7,7 @@ definition module Types from TSt import :: TSt from TaskTree import :: TaskProperties, :: GroupedBehaviour from Html import :: HtmlTag -from CommonDomain import :: Note +from CommonDomain import :: Note, :: Password from StdString import class toString from iTasks import class iTask @@ -23,6 +23,7 @@ derive JSONDecode Document instance toString TaskPriority instance toString UserName +instance toString Password class toUserName a :: a -> UserName instance toUserName String @@ -35,16 +36,19 @@ instance fromUserName (String,String) instance == UserName instance == User +instance == Password :: Role :== String :: UserId :== String :: DisplayName :== String +:: Password = Password String + :: UserName = UserName !UserId !DisplayName :: User = { userName :: !UserId - , password :: !String + , password :: !Password , displayName :: !DisplayName , roles :: ![Role] } diff --git a/Server/src/Framework/Types.icl b/Server/src/Framework/Types.icl index 378055e410341db427b20183718dbf2f4ac4ddc8..0606b2bfef87392774ff1954487dee9e2ad2b232 100644 --- a/Server/src/Framework/Types.icl +++ b/Server/src/Framework/Types.icl @@ -27,6 +27,10 @@ where | disp == "" = id | otherwise = disp+++" <"+++id+++">" +instance toString Password +where + toString (Password p) = p + class toUserName a :: a -> UserName instance toUserName String @@ -68,6 +72,10 @@ instance == User where (==) a b = a.userName == b.userName +instance == Password +where + (==) (Password a) (Password b) = a == b + // Document emptyDoc :: Document emptyDoc = {type = Local, content = EmptyDocument}