Ferreteria/sql/user token: Difference between revisions

From Woozle Writes Code
Jump to navigation Jump to search
(more secure)
(no longer requires pre-existing email address)
Line 3: Line 3:
* '''History''':
* '''History''':
** '''2013-10-03''' created
** '''2013-10-03''' created
** '''2013-12-24''' changed to no longer require a pre-existing email address (using SQL adapted for ATC but never used)
==SQL==
==SQL==
<mysql>CREATE TABLE `user_tokens` (
<mysql>CREATE TABLE `user_tokens` (
   `ID_Email`             INT NOT NULL COMMENT "ID of email address being authorized",
   `ID`                   INT NOT NULL AUTO_INCREMENT,
  `Email`      VARCHAR(256) NOT NULL COMMENT "email address being authorized",
   `TokenHash` VARBINARY(128) NOT NULL COMMENT "hash for [token+salt]",
   `TokenHash` VARBINARY(128) NOT NULL COMMENT "hash for [token+salt]",
   `TokenSalt` VARBINARY(128) NOT NULL COMMENT "random prefix for hash",
   `TokenSalt` VARBINARY(128) NOT NULL COMMENT "random prefix for hash",
   `WhenExp`        DATETIME NOT NULL COMMENT "when the token expires (and should be deleted)",
   `WhenExp`        DATETIME NOT NULL COMMENT "when the token expires (and should be deleted)",
  PRIMARY KEY(`ID_Email`)
  UNIQUE KEY(`Email`),
  PRIMARY KEY(`ID`)
)
)
ENGINE = MYISAM;</mysql>
ENGINE = MYISAM;</mysql>

Revision as of 15:42, 24 December 2013

About

  • Purpose: for storing tokens that authorize users to change things associated with an email address (mainly password)
  • History:
    • 2013-10-03 created
    • 2013-12-24 changed to no longer require a pre-existing email address (using SQL adapted for ATC but never used)

SQL

<mysql>CREATE TABLE `user_tokens` (

 `ID`                   INT NOT NULL AUTO_INCREMENT,
 `Email`       VARCHAR(256) NOT NULL COMMENT "email address being authorized",
 `TokenHash` VARBINARY(128) NOT NULL COMMENT "hash for [token+salt]",
 `TokenSalt` VARBINARY(128) NOT NULL COMMENT "random prefix for hash",
 `WhenExp`         DATETIME NOT NULL COMMENT "when the token expires (and should be deleted)",
  UNIQUE KEY(`Email`),
  PRIMARY KEY(`ID`)

) ENGINE = MYISAM;</mysql>