Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Authentication From Trunk Branch. #205

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ src/js/_DS_Store

#User uploaded produce_images images
static/images/produce_images
static/images/id_images

9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ DO_BUCKET_NAME=REPLACE_ME
DO_KEY_ID=REPLACE_ME
DO_SECRET=REPLACE_ME
DO_ENDPOINT=REPLACE_ME
TOKEN_SIGN=REPLACE_ME
AUTH_STATEGY=REPLACE_ME
CONFIRM_URL=REPLACE_ME
TWILIO_ACCOUNT_SID=REPLACE_ME
TWILIO_AUTH_TOKEN=REPLACE_ME
```
Expand Down Expand Up @@ -160,12 +163,15 @@ node sequelise_auto_export.js

The generated models can be found in `./models`

- Creating sequelize migration (which creates a js file in migrations folder and will need to be commited)
- Creating sequelize migration (which creates a js file in migrations folder and will need to be
commited)

```bash
npx sequelize migration:create --name name_of_new_db_column
```

Run the migration

```bash
npx sequelize db:migrate --url ‘mysql://username:password@localhost:3306/databasename'
```
Expand Down Expand Up @@ -262,6 +268,7 @@ $ heroku run npx sequelize-cli db:migrate --url 'mysql://root:password@mysql_hos
```

Alternatively

```
$ heroku run npm run build -a name-of-app
```
Expand Down
58 changes: 58 additions & 0 deletions migrations/20220429215904-add_new_user_columns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
/**
* Add altering commands here.
*
* Example:
* await queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/
await queryInterface.addColumn('user', 'userId', {
type: Sequelize.STRING(255),
});
await queryInterface.addColumn('user', 'user_uuid', {
type: Sequelize.STRING(255),
});
await queryInterface.addColumn('user', 'farmName', {
type: Sequelize.STRING(255),
});
await queryInterface.addColumn('user', 'organisationName', {
type: Sequelize.STRING(255),
});
await queryInterface.addColumn('user', 'organisationType', {
type: Sequelize.STRING(255),
});
await queryInterface.addColumn('user', 'city', {
type: Sequelize.STRING(255),
});
await queryInterface.addColumn('user', 'emailVerificationToken', {
type: Sequelize.STRING(255),
});
await queryInterface.addColumn('user', 'isEmailVerified', {
type: Sequelize.BOOLEAN,
});
await queryInterface.addColumn('user', 'isAdminVerified', {
type: Sequelize.BOOLEAN,
});
},

down: async (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/

await queryInterface.removeColumn('user', 'userId');
await queryInterface.removeColumn('user', 'user_uuid');
await queryInterface.removeColumn('user', 'farmName');
await queryInterface.removeColumn('user', 'organisationName');
await queryInterface.removeColumn('user', 'organisationType');
await queryInterface.removeColumn('user', 'city');
await queryInterface.removeColumn('user', 'emailVerificationToken');
await queryInterface.removeColumn('user', 'isEmailVerified');
await queryInterface.removeColumn('user', 'isAdminVerified');
},
};
44 changes: 23 additions & 21 deletions migrations/20220604131504-remove-primary-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,31 @@ $npm run build-dev
module.exports = {
up: async (queryInterface, Sequelize) => {
// logic for transforming into the new state
await queryInterface.removeIndex('foodprint_config', 'PRIMARY')
.then(queryInterface.removeIndex('foodprint_harvest', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_produce', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_produce_price', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_qrcount', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_storage', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_subscription', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_weeklyview', 'PRIMARY'))
.then(queryInterface.removeIndex('market_subscription', 'PRIMARY'))
.then(queryInterface.removeIndex('user', 'PRIMARY'));
await queryInterface
.removeIndex('foodprint_config', 'PRIMARY')
.then(queryInterface.removeIndex('foodprint_harvest', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_produce', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_produce_price', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_qrcount', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_storage', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_subscription', 'PRIMARY'))
.then(queryInterface.removeIndex('foodprint_weeklyview', 'PRIMARY'))
.then(queryInterface.removeIndex('market_subscription', 'PRIMARY'))
.then(queryInterface.removeIndex('user', 'PRIMARY'));
},

down: async (queryInterface, Sequelize) => {
// logic for reverting the changes
await queryInterface.addIndex('foodprint_config', 'PRIMARY')
.then(queryInterface.addIndex('foodprint_harvest', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_produce', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_produce_price', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_qrcount', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_storage', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_subscription', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_weeklyview', 'PRIMARY'))
.then(queryInterface.addIndex('market_subscription', 'PRIMARY'))
.then(queryInterface.addIndex('user', 'PRIMARY'));
}
await queryInterface
.addIndex('foodprint_config', 'PRIMARY')
.then(queryInterface.addIndex('foodprint_harvest', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_produce', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_produce_price', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_qrcount', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_storage', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_subscription', 'PRIMARY'))
.then(queryInterface.addIndex('foodprint_weeklyview', 'PRIMARY'))
.then(queryInterface.addIndex('market_subscription', 'PRIMARY'))
.then(queryInterface.addIndex('user', 'PRIMARY'));
},
};
42 changes: 39 additions & 3 deletions models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ module.exports = function (sequelize, DataTypes) {
allowNull: false,
primaryKey: true,
},
user_uuid: {
type: DataTypes.STRING(255),
allowNull: true,
},
userId: {
type: DataTypes.STRING(255),
allowNull: true,
},
firstName: {
type: DataTypes.STRING(255),
allowNull: true,
Expand Down Expand Up @@ -39,10 +47,21 @@ module.exports = function (sequelize, DataTypes) {
type: DataTypes.STRING(255),
allowNull: true,
},
createdAt: {
type: DataTypes.DATE,
farmName: {
type: DataTypes.STRING(255),
allowNull: true,
},
organisationName: {
type: DataTypes.STRING(255),
allowNull: true,
},
organisationType: {
type: DataTypes.STRING(255),
allowNull: true,
},
city: {
type: DataTypes.STRING(255),
allowNull: true,
defaultValue: Sequelize.Sequelize.literal('CURRENT_TIMESTAMP'),
},
registrationChannel: {
type: DataTypes.STRING(255),
Expand All @@ -52,6 +71,23 @@ module.exports = function (sequelize, DataTypes) {
type: DataTypes.BLOB,
allowNull: true,
},
emailVerificationToken: {
type: DataTypes.STRING(255),
allowNull: true,
},
isEmailVerified: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
isAdminVerified: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
createdAt: {
type: DataTypes.DATE,
allowNull: true,
defaultValue: Sequelize.Sequelize.literal('CURRENT_TIMESTAMP'),
},
user_identifier_image_url: {
type: DataTypes.STRING(255),
allowNull: true,
Expand Down
Loading