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

Merge to master #304

Merged
merged 3 commits into from
May 8, 2023
Merged
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
15 changes: 15 additions & 0 deletions db/migrations/20230508195724-ChangeUserEmailToCitext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.sequelize.query('CREATE EXTENSION IF NOT EXISTS citext;');
await queryInterface.changeColumn('users', 'email', {
type: Sequelize.CITEXT,
});
},

async down(queryInterface, Sequelize) {
await queryInterface.changeColumn('users', 'email', {
type: Sequelize.STRING
});
await queryInterface.sequelize.query('DROP EXTENSION citext;');
}
};
13 changes: 13 additions & 0 deletions db/migrations/20230508203447-ChangeInvitationEmailToCitext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.changeColumn('invitations', 'email', {
type: Sequelize.CITEXT,
});
},

async down(queryInterface, Sequelize) {
await queryInterface.changeColumn('invitations', 'email', {
type: Sequelize.STRING
});
}
};
3 changes: 3 additions & 0 deletions src/api/main/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export default () => {

return res.status(200).json({ error: false, data: user });
} catch (err) {
if (err.name === 'SequelizeUniqueConstraintError') {
return res.status(422).json({ error: true, data: { message: 'Email is already taken.' } });
}
return next(err);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/Invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { sequelize, DataTypes } from './db';

const Invitation = sequelize.define('invitation', {
email: {
type: DataTypes.STRING,
type: DataTypes.CITEXT,
allowNull: false,
unique: true
},
Expand Down
2 changes: 1 addition & 1 deletion src/models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ User.init({
},
googleId: DataTypes.STRING,
name: DataTypes.STRING,
email: DataTypes.STRING,
email: DataTypes.CITEXT,
encryptedPassword: DataTypes.STRING,
resetPasswordToken: DataTypes.STRING,
resetPasswordSentAt: DataTypes.DATE,
Expand Down