Jump to content

Secret field: Difference between revisions

From EPrints Documentation
Moj (talk | contribs)
No edit summary
Updated field page to make structure more consistent to other fields.
 
Line 1: Line 1:
{{fieldtypes}}
== Description ==
This field stores a secret value like a password.  This is basically the same as an [[Id field]] but the input is masked and not loaded from the database into the input form.
== Inheritance ==
* [[Metadata]]
* [[Metadata]]
** [[Text field]]
** [[Id field]]
*** [[Secret field]]
*** [[Secret field]]


== Description ==
== Additional Properties ==
As for [[Id field#Additional_Properties|Id fields]] except for:
{| border="1" cellpadding="3" cellspacing="0"
! Name !! Default Value !! Required? !! Description !! Notes
|-
| '''repeat_secret''' || <tt>0</tt> || NO || Whether you need to input the secret twice to verify it has been typed in correctly. ||
|-
| '''sql_index''' || <tt>0</tt> || NO || Whether field should be index for quicker lookup by the database. || Different from [[Metadata]] default (<tt>1</tt>).
|}
 
== Required Phrases ==
If <tt>repeat_secret => 1</tt> then the additional phrase in the following form is required:
datasetid + "_fieldname_" + fieldname + "_confirm"
E.g.
user_fieldname_password_confirm


== Properties ==
== Database ==
Secret ields are stored in the database as
fieldname VARCHAR(255)


No extra properties.
== API ==
See [[API:EPrints/MetaField/Namedset|API page]].


== Required Phrases ==
== Examples ==
Most basic example.
{
    name => 'secret',
    type => 'secret',
}
Crypt the value before it is stored in the database:
{
    name => 'password',
    type => 'secret',
    fromform => \&EPrints::Utils::crypt_password,
}
Also do not display the field in the [[EPrints_Glossary#Data_object|data object]]'s [[EPrints Glossary#Details tab|Details tab]].
{
    name => 'password',
    type => 'secret',
    show_in_html => 0,
    fromform => \&EPrints::Utils::crypt_password,
}

Latest revision as of 20:51, 15 April 2023


Description[edit]

This field stores a secret value like a password. This is basically the same as an Id field but the input is masked and not loaded from the database into the input form.

Inheritance[edit]

Additional Properties[edit]

As for Id fields except for:

Name Default Value Required? Description Notes
repeat_secret 0 NO Whether you need to input the secret twice to verify it has been typed in correctly.
sql_index 0 NO Whether field should be index for quicker lookup by the database. Different from Metadata default (1).

Required Phrases[edit]

If repeat_secret => 1 then the additional phrase in the following form is required:

datasetid + "_fieldname_" + fieldname + "_confirm"

E.g.

user_fieldname_password_confirm

Database[edit]

Secret ields are stored in the database as

fieldname VARCHAR(255)

API[edit]

See API page.

Examples[edit]

Most basic example.

{
   name => 'secret', 
   type => 'secret',
}

Crypt the value before it is stored in the database:

{
   name => 'password', 
   type => 'secret',
   fromform => \&EPrints::Utils::crypt_password, 
}

Also do not display the field in the data object's Details tab.

{
   name => 'password', 
   type => 'secret',
   show_in_html => 0,
   fromform => \&EPrints::Utils::crypt_password, 
}