-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into bg-fix-password-schema
- Loading branch information
Showing
7 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
server/database/migrations/20190731135151-create-session.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
export default { | ||
up: (queryInterface, Sequelize) => queryInterface.createTable('Sessions', { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
userId: { | ||
allowNull: false, | ||
type: Sequelize.INTEGER | ||
}, | ||
active: { | ||
allowNull: false, | ||
type: Sequelize.BOOLEAN, | ||
defaultValue: true | ||
}, | ||
devicePlatform: { | ||
allowNull: false, | ||
type: Sequelize.STRING, | ||
defaultValue: 'browser' | ||
}, | ||
expiresAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
ipAddress: { | ||
type: Sequelize.STRING | ||
}, | ||
token: { | ||
allowNull: false, | ||
type: Sequelize.STRING | ||
}, | ||
userAgent: { | ||
type: Sequelize.STRING | ||
}, | ||
createdAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
}, | ||
updatedAt: { | ||
allowNull: false, | ||
type: Sequelize.DATE | ||
} | ||
}), | ||
down: queryInterface => queryInterface.dropTable('Sessions') | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* istanbul ignore file */ | ||
|
||
import fs from 'fs'; | ||
import path from 'path'; | ||
import Sequelize from 'sequelize'; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export default (sequelize, DataTypes) => { | ||
const Session = sequelize.define( | ||
'Sessions', | ||
{ | ||
userId: DataTypes.INTEGER, | ||
active: DataTypes.BOOLEAN, | ||
devicePlatform: DataTypes.STRING, | ||
expiresAt: DataTypes.DATE, | ||
ipAddress: DataTypes.STRING, | ||
token: DataTypes.STRING, | ||
userAgent: DataTypes.STRING | ||
}, | ||
{} | ||
); | ||
return Session; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable max-len */ | ||
export default { | ||
up: queryInterface => queryInterface.bulkInsert( | ||
'Sessions', | ||
[ | ||
{ | ||
userId: 1, | ||
active: true, | ||
devicePlatform: 'browser', | ||
expiresAt: new Date('2020-10-10'), | ||
ipAddress: '121.234.188.49', | ||
token: | ||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', | ||
userAgent: | ||
'Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
}, | ||
{ | ||
userId: 2, | ||
active: true, | ||
devicePlatform: 'browser', | ||
expiresAt: new Date('2020-10-10'), | ||
ipAddress: '121.234.200.49', | ||
token: | ||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', | ||
userAgent: | ||
'Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36', | ||
createdAt: new Date(), | ||
updatedAt: new Date() | ||
} | ||
], | ||
{} | ||
), | ||
down: queryInterface => queryInterface.bulkDelete('Sessions', null, {}) | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import sessionMigration from './sessionMigration.test'; | ||
|
||
export default { sessionMigration }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import chai, { expect } from 'chai'; | ||
import models from '../../server/database/models'; | ||
|
||
const { Sessions } = models; | ||
|
||
describe('Session Model', () => { | ||
it('Successfully insert into session database', async () => { | ||
const session = await Sessions.create({ | ||
userId: 1, | ||
active: true, | ||
devicePlatform: 'browser', | ||
expiresAt: new Date('2020-10-10'), | ||
ipAddress: '121.234.188.49', | ||
token: | ||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c', | ||
userAgent: | ||
'Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36' | ||
}); | ||
expect(session).to.be.an('object'); | ||
}); | ||
}); | ||
|
||
export default chai; |
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