From fb85b646035d55719f0a2fed58acb002a0e2b1d6 Mon Sep 17 00:00:00 2001 From: ecrombag Date: Tue, 6 Apr 2010 14:47:28 +0000 Subject: [PATCH] Added first version of Password Control git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@947 63da3aa8-80fd-4f01-9db8-e6ea747a3da2 --- Client/src/js/ttc/TTCCommon.js | 1 + Client/src/js/tui/PasswordControl.js | 20 ++++++++++++++++ Language/src/Domains/CommonDomain.dcl | 1 - Language/src/Domains/CommonDomain.icl | 32 +++++++++++++++++++++++--- Server/src/Framework/Data/UserDB.icl | 12 ++++++---- Server/src/Framework/GenVisualize.icl | 2 +- Server/src/Framework/TUIDefinition.dcl | 3 ++- Server/src/Framework/TUIDefinition.icl | 2 +- Server/src/Framework/Types.dcl | 8 +++++-- Server/src/Framework/Types.icl | 8 +++++++ 10 files changed, 75 insertions(+), 14 deletions(-) diff --git a/Client/src/js/ttc/TTCCommon.js b/Client/src/js/ttc/TTCCommon.js index 6333a9df9..a9467841f 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 e69de29bb..f3556efa4 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 7d9c7c230..3b748c02b 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 6684bd60e..ae17ba3f6 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 1f83f5e89..b168c02c9 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 6ac9b9ea5..303bdab37 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 81d3bf9e5..dc60e477d 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 4130f8b5f..824634558 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 fe882c891..0183e5f42 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 378055e41..0606b2bfe 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} -- GitLab