Password

From Sense/Net 6.0 Wiki

Jump to: navigation, search

[edit] Summary

Password is used for defining a Field that stores a password as hashed text.

Data Type

At the core of the system the data type of a PasswordField is String RepositoryDataType. If a value different from a number is given the Field will not save that value and an error will occur (and exception will be thrown).


[edit] Example

This below is a fragment of the XML code of the Content Type Definition, which defines the operation of the given content's field. This fragment creates a field in the content type definition which users to enter binaries to the given content type.. As you can see this is done in a very simple way. This particular fragment is cut from a longer xml code, and it describes the field where you can specify any binary code of a content.

Minimal example

<Field name="FieldName" type="Password">
   <Title>The Title Of The Field</Title>
</Field>

Regular example

<Field name="Field" type="Password">
   <Title>The Title Of The Field</Title>
   <Description>Description of the Field</Description>
   <Bind property="PasswordHash" />
   <Configuration>
      <ReenterTitle>Password confirmation:</ReenterTitle>
   </Configuration>
</Field>

Full featured example

<Field name="FieldName" type="Password">
   <Title>The Title Of The Field</Title>
   <Description>Description of the Field</Description>
   <Bind property="PasswordHash" />
   <Configuration handler="SenseNet.ContentRepository.Fields.PasswordFieldSetting">
      <Compulsory>true</Compulsory>
      <ReenterTitle>Password confirmation:</ReenterTitle>
      <ReenterDescription>Please re-enter the password to ensure no typos have been made</ReenterDescription>
      <ReadOnly>false</ReadOnly>
   </Configuration>
</Field>

Now let's see what these lines are responsible for.

<Title>The Title Of The Field</Title>

This line stands for the Title of the field in the Content Type Definition. Whatever you type here will be displayed on the datasheet of the given content.

<Description>Description of the Field</Description>

This line is responsible for displaying a short description of the required information you want users to enter.

<Configuration handler="SenseNet.ContentRepository.Fields.NullFieldSetting">
   <Compulsory>true</Compulsory>
   <ReenterTitle>Password confirmation:</ReenterTitle>
   <ReenterDescription>Please re-enter the password to ensure no typos have been made</ReenterDescription>
   <ReadOnly>false</ReadOnly>
</Configuration>
  • A custom FieldSetting can be defined by assigning value to the handler attribute of the Configuration tag. This is an advanced feature. (code 103)
  • The Bind tag indicates that the field should be mapped to the PasswordHash field already defined in the system.
  • The Compulsory tag indicates whether the Field should be filled out. If it is true, empty value is not allowed.
  • The ReenterTitle tag specifies the text that will be written as the title of the input text field where the password has to be confirmed.
  • The ReenterDescription tag specifies the text that will be written as the description of the input text field where the password has to be confirmed.
  • The ReadOnly tag decides whether the Field value can be changed within a View. When set to true the value cannot be changed (see ReadOnly fields and properties) (Note that setting this a password field to read only is a rare scenario)


Here is an example of this field in practice:


Image:Password_content_field.jpg


Click here if you want to know more about Content Type Fields and the configurations of them.

[edit] Related Pages:

Personal tools