LoginAPI & User Model

Kieran Sedgwick edited this page Dec 3, 2013 · 11 revisions

Webmaker User Data Model

    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    email: {
      type: DataTypes.STRING,
      allowNull: false,
      unique: true
    },
    username: {
      type: "VARCHAR(20)",
      allowNull: false,
      unique: true
    },
    fullName: {
      type: DataTypes.STRING,
      allowNull: false,
      unique: false
    },
    deletedAt: {
      type: DataTypes.DATE,
      allowNull: true
    },
    isAdmin: {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    isCollaborator: {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    isSuspended: {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    sendNotifications: {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    sendEngagements: {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    },
    sendEventCreationEmails: {
      type: DataTypes.BOOLEAN,
      defaultValue: true
    },
    wasMigrated: {
      type: DataTypes.BOOLEAN,
      defaultValue: false
    }
  }

Login RESTful APIs

  1. POST /user

     Purpose:
    
         Create a new Webmaker account.
    
     Call Parameters:
         n/a
    
     Expected info:
         Minimum:
    
         {
             email: STRING | Persona email,
             username: STRING
         }
    
     Return:
         {
              error: STRING,
              user: Webmaker User Object
         }
    
     Security:
       Persona credentials
    
  2. PUT /user/:email

     Purpose:
    
         Update a Webmaker profile
    
     Call Parameters:
        :email - the "email" parameter of the Webmaker User model (see schema at top of page)
    
     Expected info:
    
         A JSON object containing the attributes being updated
    
     Return:
         {
              err: STRING,
              user: Webmaker User Object (see schema at top of page)
         }
    
     Security:
         Basicauth for server-to-server. Persona credentials + associated admin account.
    
  3. GET /user/id/:id

     Purpose:
    
         Return a copy of the user's Webmaker User model object.
    
     Call Parameters:
        :id - the "id" parameter of the Webmaker User model (see schema at top of page)
    
     Expected info:
    
         N/A
    
     Return:
         {
              err: STRING,
              user: Webmaker User Object (see schema at top of page)
         }
    
     Security:
         Basicauth for server-to-server. Otherwise, persona credentials + associated webmaker account. Unless they have admin permissions, users can only retrieve their own account details.
    
  4. GET /user/username/:username

     Purpose:
    
         Return a copy of the user's Webmaker User model object
    
     Call Parameters:
        :username - the "username" parameter of the Webmaker User model (see schema at top of page)
    
     Expected info:
    
         N/A
    
     Return:
         {
              err: STRING,
              user: Webmaker User Object (see schema at top of page)
         }
    
     Security:
         Basicauth for server-to-server. Otherwise, persona credentials + associated webmaker account. Unless they have admin permissions, users can only retrieve their own account details.
    
  5. GET /user/email/:email

     Purpose:
    
         Return a copy of the user's Webmaker User model object.
    
     Call Parameters:
        :email - the "email" parameter of the Webmaker User model (see schema at top of page)
    
     Expected info:
    
         N/A
    
     Return:
         {
              err: STRING,
              user: Webmaker User Object (see schema at top of page)
         }
    
     Security:
         Basicauth for server-to-server. Otherwise, persona credentials + associated webmaker account. Unless they have admin permissions, users can only retrieve their own account details.
    
  6. DELETE /user/:email

     Purpose:
    
         Delete a User from the Webmaker database
    
     Call Parameters:
        :email - the "email" parameter of the Webmaker User model (see schema at top of page)
    
     Expected info:
    
         N/A
    
     Return:
         {
              err: STRING
         }
    
     Security:
         Basicauth for server-to-server. Persona credentials + associated admin account.
    
  7. PUT /account/update

     Purpose:
    
         Delete a User from the Webmaker database
    
     Call Parameters:
        :email - the "email" parameter of the Webmaker User model (see schema at top of page)
    
     Expected info:
    
         N/A
    
     Return:
         {
              err: STRING
         }
    
     Security:
         Basicauth for server-to-server. Persona credentials + associated admin account.
    
  8. POST /account/delete

     Purpose:
    
         Delete a User from the Webmaker database
    
     Call Parameters:
        :email - the "email" parameter of the Webmaker User model (see schema at top of page)
    
     Expected info:
    
         N/A
    
     Return:
         {
              err: STRING
         }
    
     Security:
         Basicauth for server-to-server. Persona credentials + associated admin account.