-
-
Save aanchirinah/9b6f11c9ca7c88bdbb5629ba41118adf to your computer and use it in GitHub Desktop.
Migration file for Verification Token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
up: function(queryInterface, Sequelize) { | |
return queryInterface.createTable('VerificationTokens', { | |
id: { | |
allowNull: false, | |
autoIncrement: true, | |
primaryKey: true, | |
type: Sequelize.INTEGER | |
}, | |
userId: { | |
type: Sequelize.INTEGER, | |
allowNull: false, | |
onUpdate: "cascade", | |
onDelete: "cascade", | |
references: { model: "Users", key: "id" } | |
}, | |
token: { | |
type: Sequelize.STRING, | |
allowNull: false | |
}, | |
createdAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
}, | |
updatedAt: { | |
allowNull: false, | |
type: Sequelize.DATE | |
} | |
}).then(() => { | |
console.log('created VerificationToken table'); | |
return queryInterface.sequelize.query(` | |
CREATE EVENT expireToken | |
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY | |
DO | |
DELETE FROM verification_tokens WHERE createdAt < DATE_SUB(NOW(), INTERVAL 1 DAY); | |
`) | |
}).then(() => { console.log('expireToken event created') }); | |
}, | |
down: function(queryInterface) { | |
return queryInterface.dropTable('VerificationTokens') | |
.then(() => { | |
console.log(‘VericationTokens table dropped’) | |
return queryInterface.sequelize.query(`DROP EVENT IF EXISTS expireToken`); | |
}).then(() => { console.log(‘expireToken event dropped’) }) | |
} | |
}; |
Hey man. I followed everything. but I'm getting this error
syntax error at or near "expireToken"
I'm using postgrsql as database. cron events aren't being set. can you help?
@ShejaEddy, thanks for pointing this out, I have actually revised this implementation now using JWT tokens , so there is no need to store expireTokens
I will update the article soon.
so, it's possible to set expiry date in JWT tokens then expect them to not
be valid after sometimes?
…On Mon, Feb 17, 2020 at 1:47 PM Audax ***@***.***> wrote:
Hey man. I followed everything. but I'm getting this error syntax error
at or near "expireToken" I'm using postgrsql as database. cron events
aren't being set. can you help?
@ShejaEddy <https://github.com/ShejaEddy>, thanks for pointing this out,
I have actually revised this implementation now using JWT tokens , so there
is no need to store expireTokens I will update the article soon.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/9b6f11c9ca7c88bdbb5629ba41118adf?email_source=notifications&email_token=ALXZC3ZQWWK63SPYBZGLRPDRDJ2MLA5CNFSM4KWP5NYKYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAGCCEK#gistcomment-3179589>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALXZC32WJBYMWSU4RTND7BTRDJ2MLANCNFSM4KWP5NYA>
.
Yes @ShejaEddy and you resend the email verification in the callback that validates the JWT token
Hey @aanchirinah this tutorials looks good, waiting for the updated version.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey man. I followed everything. but I'm getting this error
syntax error at or near "expireToken"
I'm using postgrsql as database. cron events aren't being set. can you help?